Search in sources :

Example 1 with TestSystemProperties

use of co.rsk.config.TestSystemProperties 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 2 with TestSystemProperties

use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.

the class BlockValidatorTest method blockTimeStampValidation.

private void blockTimeStampValidation(int validPeriod, long baseTimeStamp, BlockHeader header, Block block, NetworkParameters bitcoinNetworkParameters, boolean irisEnabled) {
    TestSystemProperties testSystemProperties = blockTimeStampValidationProperties(irisEnabled);
    TimeProvider timeProvider = mock(TimeProvider.class);
    when(timeProvider.currentTimeMillis()).thenReturn(baseTimeStamp * 1000 + validPeriod);
    BlockValidatorImpl validator = new BlockValidatorBuilder(testSystemProperties).addBlockTimeStampValidation(validPeriod, timeProvider, bitcoinNetworkParameters).build();
    when(header.getTimestamp()).thenReturn(baseTimeStamp + 2 * validPeriod);
    Assert.assertFalse(validator.isValid(block));
    when(header.getTimestamp()).thenReturn(baseTimeStamp + validPeriod);
    Assert.assertTrue(validator.isValid(block));
}
Also used : TimeProvider(co.rsk.util.TimeProvider) TestSystemProperties(co.rsk.config.TestSystemProperties)

Example 3 with TestSystemProperties

use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.

the class EnvironmentUtils method getEnvironmentWithBlockchainOfLength.

public static ExecutionEnvironment getEnvironmentWithBlockchainOfLength(int blockchainLength) {
    World world = new World();
    TestSystemProperties config = new TestSystemProperties();
    buildBlockchainOfLength(world, config, blockchainLength);
    ExecutionEnvironment executionEnvironment = mock(ExecutionEnvironment.class);
    when(executionEnvironment.getBlockStore()).thenReturn(world.getBlockStore());
    when(executionEnvironment.getBlock()).thenReturn(world.getBlockChain().getBestBlock());
    return executionEnvironment;
}
Also used : ExecutionEnvironment(co.rsk.pcc.ExecutionEnvironment) World(co.rsk.test.World) TestSystemProperties(co.rsk.config.TestSystemProperties)

Example 4 with TestSystemProperties

use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.

the class AltBN128Test method init.

@Before
public void init() {
    config = new TestSystemProperties();
    precompiledContracts = new PrecompiledContracts(config, null);
    activations = mock(ActivationConfig.ForBlock.class);
    when(activations.isActive(ConsensusRule.RSKIP137)).thenReturn(true);
    when(activations.isActive(ConsensusRule.RSKIP197)).thenReturn(false);
}
Also used : PrecompiledContracts(org.ethereum.vm.PrecompiledContracts) TestSystemProperties(co.rsk.config.TestSystemProperties) Before(org.junit.Before)

Example 5 with TestSystemProperties

use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.

the class ModuleDescriptionTest method getModulesFromTestNewRskSystemProperties.

@Test
public void getModulesFromTestNewRskSystemProperties() {
    TestSystemProperties config = new TestSystemProperties();
    List<ModuleDescription> modules = config.getRpcModules();
    Assert.assertNotNull(modules);
    Assert.assertFalse(modules.isEmpty());
    Assert.assertEquals(2, modules.size());
    ModuleDescription moduleEth = modules.get(0);
    Assert.assertEquals("eth", moduleEth.getName());
    Assert.assertEquals("1.0", moduleEth.getVersion());
    Assert.assertTrue(moduleEth.isEnabled());
    Assert.assertNotNull(moduleEth.getEnabledMethods());
    Assert.assertTrue(moduleEth.getEnabledMethods().isEmpty());
    Assert.assertNotNull(moduleEth.getDisabledMethods());
    Assert.assertTrue(moduleEth.getDisabledMethods().isEmpty());
    ModuleDescription moduleEvm = modules.get(1);
    Assert.assertEquals("evm", moduleEvm.getName());
    Assert.assertEquals("1.1", moduleEvm.getVersion());
    Assert.assertFalse(moduleEvm.isEnabled());
    Assert.assertNotNull(moduleEvm.getEnabledMethods());
    Assert.assertFalse(moduleEvm.getEnabledMethods().isEmpty());
    Assert.assertEquals(2, moduleEvm.getEnabledMethods().size());
    Assert.assertNotNull(moduleEvm.getDisabledMethods());
    Assert.assertFalse(moduleEvm.getDisabledMethods().isEmpty());
    Assert.assertEquals(2, moduleEvm.getDisabledMethods().size());
}
Also used : TestSystemProperties(co.rsk.config.TestSystemProperties) Test(org.junit.Test)

Aggregations

TestSystemProperties (co.rsk.config.TestSystemProperties)158 Test (org.junit.Test)130 BlockChainBuilder (co.rsk.test.builders.BlockChainBuilder)109 Blockchain (org.ethereum.core.Blockchain)78 SyncConfiguration (co.rsk.net.sync.SyncConfiguration)75 SimplePeer (co.rsk.net.simples.SimplePeer)69 Block (org.ethereum.core.Block)69 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)56 ConsensusValidationMainchainView (co.rsk.core.bc.ConsensusValidationMainchainView)23 EthereumListener (org.ethereum.listener.EthereumListener)23 BlockStore (org.ethereum.db.BlockStore)21 RskSystemProperties (co.rsk.config.RskSystemProperties)17 ActivationConfigsForTest (org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)16 Keccak256 (co.rsk.crypto.Keccak256)13 RepositoryLocator (co.rsk.db.RepositoryLocator)10 World (co.rsk.test.World)10 PrecompiledContracts (org.ethereum.vm.PrecompiledContracts)9 Ignore (org.junit.Ignore)9 TransactionExecutorFactory (co.rsk.core.TransactionExecutorFactory)8 AsyncNodeBlockProcessorListener (co.rsk.net.utils.AsyncNodeBlockProcessorListener)8