Search in sources :

Example 1 with GenesisLoader

use of org.ethereum.core.genesis.GenesisLoader 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 GenesisLoader

use of org.ethereum.core.genesis.GenesisLoader in project rskj by rsksmart.

the class BlockChainImplTest method setup.

@Before
public void setup() {
    objects = new RskTestFactory() {

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

        @Override
        protected CompositeEthereumListener buildCompositeEthereumListener() {
            return new BlockExecutorTest.SimpleEthereumListener();
        }
    };
    config = objects.getRskSystemProperties();
    blockChain = objects.getBlockchain();
    blockStore = objects.getBlockStore();
    blockExecutor = objects.getBlockExecutor();
    listener = (BlockExecutorTest.SimpleEthereumListener) objects.getCompositeEthereumListener();
}
Also used : GenesisLoader(org.ethereum.core.genesis.GenesisLoader) TestGenesisLoader(co.rsk.core.genesis.TestGenesisLoader) CompositeEthereumListener(org.ethereum.listener.CompositeEthereumListener) RskTestFactory(org.ethereum.util.RskTestFactory) TestGenesisLoader(co.rsk.core.genesis.TestGenesisLoader) Before(org.junit.Before)

Example 3 with GenesisLoader

use of org.ethereum.core.genesis.GenesisLoader 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)

Aggregations

TestGenesisLoader (co.rsk.core.genesis.TestGenesisLoader)3 GenesisLoader (org.ethereum.core.genesis.GenesisLoader)3 Before (org.junit.Before)3 RskTestContext (org.ethereum.util.RskTestContext)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 CompositeEthereumListener (org.ethereum.listener.CompositeEthereumListener)1 RskTestFactory (org.ethereum.util.RskTestFactory)1