Search in sources :

Example 1 with RskTestContext

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

the class BlockChainImplInvalidTest method setup.

@Before
public void setup() {
    objects = new RskTestContext(new String[0]) {

        @Override
        protected synchronized RskSystemProperties buildRskSystemProperties() {
            RskSystemProperties rskSystemProperties = super.buildRskSystemProperties();
            ActivationConfig activationConfigSpy = spy(rskSystemProperties.getActivationConfig());
            RskSystemProperties rskSystemPropertiesSpy = spy(rskSystemProperties);
            doReturn(true).when(activationConfigSpy).isActive(eq(ConsensusRule.RSKIP126), anyLong());
            doReturn(activationConfigSpy).when(rskSystemPropertiesSpy).getActivationConfig();
            return rskSystemPropertiesSpy;
        }

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

        @Override
        public BlockValidator buildBlockValidator() {
            return new BlockValidatorImpl(getBlockStore(), getBlockParentDependantValidationRule(), getBlockValidationRule());
        }
    };
    blockChain = objects.getBlockchain();
}
Also used : GenesisLoader(org.ethereum.core.genesis.GenesisLoader) TestGenesisLoader(co.rsk.core.genesis.TestGenesisLoader) RskTestContext(org.ethereum.util.RskTestContext) TestGenesisLoader(co.rsk.core.genesis.TestGenesisLoader) RskSystemProperties(co.rsk.config.RskSystemProperties) BlockValidator(co.rsk.validators.BlockValidator) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) Before(org.junit.Before)

Example 2 with RskTestContext

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

the class GenesisHashesTest method mainnetHashTest.

@Test
public void mainnetHashTest() {
    RskContext rskContext = new RskTestContext(new String[0]);
    // this triggers changes in the Genesis through the BlockChainLoader
    rskContext.getBlockchain();
    Genesis genesis = rskContext.getGenesis();
    assertThat(genesis.getHash(), is(new Keccak256("f88529d4ab262c0f4d042e9d8d3f2472848eaafe1a9b7213f57617eb40a9f9e0")));
    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 3 with RskTestContext

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

the class SnapshotManagerTest method setUp.

@Before
public void setUp() {
    testContext = new RskTestContext(new String[] { "--regtest" });
    blockchain = testContext.getBlockchain();
    minerServer = testContext.getMinerServer();
    minerClient = testContext.getMinerClient();
    transactionPool = testContext.getTransactionPool();
    BlockStore blockStore = testContext.getBlockStore();
    // don't call start to avoid creating threads
    transactionPool.processBest(blockchain.getBestBlock());
    manager = new SnapshotManager(blockchain, blockStore, transactionPool, mock(MinerServer.class));
}
Also used : RskTestContext(org.ethereum.util.RskTestContext) BlockStore(org.ethereum.db.BlockStore) Before(org.junit.Before)

Example 4 with RskTestContext

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

the class RskContextTest method getCliArgsSmokeTest.

@Test
public void getCliArgsSmokeTest() {
    RskTestContext devnetContext = new RskTestContext(new String[] { "--devnet" });
    assertThat(devnetContext.getCliArgs(), notNullValue());
    assertThat(devnetContext.getCliArgs().getFlags(), contains(NodeCliFlags.NETWORK_DEVNET));
    devnetContext.close();
}
Also used : RskTestContext(org.ethereum.util.RskTestContext) Test(org.junit.Test)

Example 5 with RskTestContext

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

the class PreflightChecksUtilsTest method runChecks_receivesSkipJavaCheck_skipsJavaChecks.

@Test
public void runChecks_receivesSkipJavaCheck_skipsJavaChecks() throws Exception {
    String[] args = { "--skip-java-check" };
    RskContext rskContext = new RskTestContext(args);
    PreflightChecksUtils preflightChecksUtilsSpy = spy(new PreflightChecksUtils(rskContext));
    when(preflightChecksUtilsSpy.getJavaVersion()).thenReturn(null);
    preflightChecksUtilsSpy.runChecks();
    verify(preflightChecksUtilsSpy, times(0)).getJavaVersion();
    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