Search in sources :

Example 1 with RskTestFactory

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

the class MinerServerTest method setUp.

@Before
public void setUp() {
    RskTestFactory factory = new RskTestFactory(config) {

        @Override
        protected RepositoryLocator buildRepositoryLocator() {
            return Mockito.spy(super.buildRepositoryLocator());
        }
    };
    blockchain = factory.getMiningMainchainView();
    repositoryLocator = factory.getRepositoryLocator();
    blockStore = factory.getBlockStore();
    transactionPool = factory.getTransactionPool();
    blockFactory = factory.getBlockFactory();
    blockExecutor = factory.getBlockExecutor();
    minimumGasPriceCalculator = new MinimumGasPriceCalculator(Coin.ZERO);
    minerUtils = new MinerUtils();
}
Also used : RskTestFactory(org.ethereum.util.RskTestFactory) Before(org.junit.Before)

Example 2 with RskTestFactory

use of org.ethereum.util.RskTestFactory 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 RskTestFactory

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

the class MainNetMinerTest method setup.

@Before
public void setup() {
    config = spy(new TestSystemProperties());
    when(config.getNetworkConstants()).thenReturn(Constants.mainnet());
    when(config.getActivationConfig()).thenReturn(ActivationConfigsForTest.all());
    RskTestFactory factory = new RskTestFactory(config) {

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

                @Override
                public Genesis load() {
                    Genesis genesis = super.load();
                    genesis.getHeader().setDifficulty(new BlockDifficulty(BigInteger.valueOf(300000)));
                    return genesis;
                }
            };
        }
    };
    mainchainView = factory.getMiningMainchainView();
    transactionPool = factory.getTransactionPool();
    blockStore = factory.getBlockStore();
    blockProcessor = factory.getNodeBlockProcessor();
    repositoryLocator = factory.getRepositoryLocator();
    blockFactory = factory.getBlockFactory();
    blockExecutor = factory.getBlockExecutor();
}
Also used : BlockDifficulty(co.rsk.core.BlockDifficulty) Genesis(org.ethereum.core.Genesis) RskTestFactory(org.ethereum.util.RskTestFactory) TestGenesisLoader(co.rsk.core.genesis.TestGenesisLoader) TestSystemProperties(co.rsk.config.TestSystemProperties) Before(org.junit.Before)

Example 4 with RskTestFactory

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

the class Web3ImplSnapshotTest method setUp.

@Before
public void setUp() {
    factory = new RskTestFactory(config);
    blockchain = factory.getBlockchain();
    mainchainView = factory.getMiningMainchainView();
    blockFactory = factory.getBlockFactory();
}
Also used : RskTestFactory(org.ethereum.util.RskTestFactory) Before(org.junit.Before)

Example 5 with RskTestFactory

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

the class BlockchainLoaderTest method testLoadBlockchainWithInconsistentBlock.

@Test
public void testLoadBlockchainWithInconsistentBlock() {
    RskTestFactory objects = new RskTestFactory() {

        @Override
        protected synchronized RepositoryLocator buildRepositoryLocator() {
            RepositoryLocator repositoryLocatorSpy = spy(super.buildRepositoryLocator());
            doReturn(Optional.empty()).when(repositoryLocatorSpy).findSnapshotAt(any());
            return repositoryLocatorSpy;
        }

        @Override
        protected GenesisLoader buildGenesisLoader() {
            return new TestGenesisLoader(getTrieStore(), "blockchain_loader_genesis.json", BigInteger.ZERO, true, true, true);
        }
    };
    try {
        // calls loadBlockchain
        objects.getBlockchain();
        fail();
    } catch (RuntimeException e) {
        String errorMessage = String.format("Best block is not consistent with the state db. Consider using `%s` cli tool to rewind inconsistent blocks", RewindBlocks.class.getSimpleName());
        assertEquals(errorMessage, e.getMessage());
    }
}
Also used : RepositoryLocator(co.rsk.db.RepositoryLocator) RskTestFactory(org.ethereum.util.RskTestFactory) TestGenesisLoader(co.rsk.core.genesis.TestGenesisLoader) Test(org.junit.Test)

Aggregations

RskTestFactory (org.ethereum.util.RskTestFactory)13 Before (org.junit.Before)7 TestGenesisLoader (co.rsk.core.genesis.TestGenesisLoader)5 Blockchain (org.ethereum.core.Blockchain)5 Test (org.junit.Test)5 RepositoryLocator (co.rsk.db.RepositoryLocator)4 Block (org.ethereum.core.Block)3 BlockStore (org.ethereum.db.BlockStore)3 TestSystemProperties (co.rsk.config.TestSystemProperties)2 BlockDifficulty (co.rsk.core.BlockDifficulty)1 RskAddress (co.rsk.core.RskAddress)1 RepositorySnapshot (co.rsk.db.RepositorySnapshot)1 BlockBuilder (co.rsk.test.builders.BlockBuilder)1 ActivationConfig (org.ethereum.config.blockchain.upgrades.ActivationConfig)1 ConsensusRule (org.ethereum.config.blockchain.upgrades.ConsensusRule)1 Genesis (org.ethereum.core.Genesis)1 GenesisLoader (org.ethereum.core.genesis.GenesisLoader)1 CompositeEthereumListener (org.ethereum.listener.CompositeEthereumListener)1