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();
}
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));
}
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;
}
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);
}
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());
}
Aggregations