Search in sources :

Example 11 with RskTestContext

use of org.ethereum.util.RskTestContext in project rskj by rsksmart.

the class NodeRunnerSmokeTest method contextRecreationSmokeTest.

@Test
public void contextRecreationSmokeTest() {
    RskTestContext rskContext = new RskTestContext(new String[] { "--regtest" });
    assertThat(rskContext.getNodeRunner(), notNullValue());
    rskContext.close();
    assertTrue(rskContext.isClosed());
    // re-create context
    rskContext = new RskTestContext(new String[] { "--regtest" });
    assertThat(rskContext.getNodeRunner(), notNullValue());
    rskContext.close();
    assertTrue(rskContext.isClosed());
}
Also used : RskTestContext(org.ethereum.util.RskTestContext) Test(org.junit.Test)

Example 12 with RskTestContext

use of org.ethereum.util.RskTestContext in project rskj by rsksmart.

the class NodeRunnerSmokeTest method testnetSmokeTest.

@Test
public void testnetSmokeTest() {
    RskTestContext rskContext = new RskTestContext(new String[] { "--testnet" });
    assertThat(rskContext.getNodeRunner(), notNullValue());
    rskContext.close();
}
Also used : RskTestContext(org.ethereum.util.RskTestContext) Test(org.junit.Test)

Example 13 with RskTestContext

use of org.ethereum.util.RskTestContext in project rskj by rsksmart.

the class GenesisHashesTest method testnetHashTest.

@Test
public void testnetHashTest() {
    RskContext rskContext = new RskTestContext(new String[] { "--testnet" });
    // this triggers changes in the Genesis through the BlockChainLoader
    rskContext.getBlockchain();
    Genesis genesis = rskContext.getGenesis();
    assertThat(genesis.getHash(), is(new Keccak256("cabb7fbe88cd6d922042a32ffc08ce8b1fbb37d650b9d4e7dbfe2a7469adfa42")));
    rskContext.close();
}
Also used : RskTestContext(org.ethereum.util.RskTestContext) RskContext(co.rsk.RskContext) Genesis(org.ethereum.core.Genesis) Keccak256(co.rsk.crypto.Keccak256) Test(org.junit.Test)

Example 14 with RskTestContext

use of org.ethereum.util.RskTestContext in project rskj by rsksmart.

the class TransactionPoolImplTest method setUp.

@Before
public void setUp() {
    rskTestContext = new RskTestContext(new String[] { "--regtest" }) {

        @Override
        protected GenesisLoader buildGenesisLoader() {
            return new TestGenesisLoader(getTrieStore(), "rsk-unittests.json", BigInteger.ZERO, true, true, true);
        }

        @Override
        protected RepositoryLocator buildRepositoryLocator() {
            return spy(super.buildRepositoryLocator());
        }
    };
    blockChain = rskTestContext.getBlockchain();
    RepositoryLocator repositoryLocator = rskTestContext.getRepositoryLocator();
    repository = repositoryLocator.startTrackingAt(blockChain.getBestBlock().getHeader());
    signatureCache = spy(rskTestContext.getReceivedTxSignatureCache());
    transactionPool = new TransactionPoolImpl(rskTestContext.getRskSystemProperties(), repositoryLocator, rskTestContext.getBlockStore(), rskTestContext.getBlockFactory(), rskTestContext.getCompositeEthereumListener(), rskTestContext.getTransactionExecutorFactory(), signatureCache, 10, 100);
    // don't call start to avoid creating threads
    transactionPool.processBest(blockChain.getBestBlock());
    // this is to workaround the current test structure, which abuses the Repository by
    // modifying it in place
    doReturn(repository).when(repositoryLocator).snapshotAt(any());
}
Also used : GenesisLoader(org.ethereum.core.genesis.GenesisLoader) TestGenesisLoader(co.rsk.core.genesis.TestGenesisLoader) RepositoryLocator(co.rsk.db.RepositoryLocator) RskTestContext(org.ethereum.util.RskTestContext) TestGenesisLoader(co.rsk.core.genesis.TestGenesisLoader) Before(org.junit.Before)

Example 15 with RskTestContext

use of org.ethereum.util.RskTestContext in project rskj by rsksmart.

the class PreflightChecksUtilsTest method runChecks_invalidJavaVersion_exceptionIsThrown.

@Test
public void runChecks_invalidJavaVersion_exceptionIsThrown() throws Exception {
    expectedException.expect(PreflightCheckException.class);
    expectedException.expectMessage("Invalid Java Version '16'. Supported versions: 8 11");
    RskContext rskContext = new RskTestContext(new String[0]);
    PreflightChecksUtils preflightChecksUtilsSpy = spy(new PreflightChecksUtils(rskContext));
    when(preflightChecksUtilsSpy.getJavaVersion()).thenReturn("16");
    preflightChecksUtilsSpy.runChecks();
    rskContext.close();
}
Also used : RskTestContext(org.ethereum.util.RskTestContext) RskContext(co.rsk.RskContext) Test(org.junit.Test)

Aggregations

RskTestContext (org.ethereum.util.RskTestContext)16 Test (org.junit.Test)13 RskContext (co.rsk.RskContext)8 Before (org.junit.Before)3 TestGenesisLoader (co.rsk.core.genesis.TestGenesisLoader)2 Keccak256 (co.rsk.crypto.Keccak256)2 Genesis (org.ethereum.core.Genesis)2 GenesisLoader (org.ethereum.core.genesis.GenesisLoader)2 RskSystemProperties (co.rsk.config.RskSystemProperties)1 RepositoryLocator (co.rsk.db.RepositoryLocator)1 BlockValidator (co.rsk.validators.BlockValidator)1 ActivationConfig (org.ethereum.config.blockchain.upgrades.ActivationConfig)1 BlockStore (org.ethereum.db.BlockStore)1