use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.
the class BridgeSupportTest method setUpOnEachTest.
@Before
public void setUpOnEachTest() {
config = new RskSystemProperties();
config.setBlockchainConfig(new RegTestConfig());
bridgeConstants = config.getBlockchainConfig().getCommonConstants().getBridgeConstants();
btcParams = bridgeConstants.getBtcParams();
}
use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.
the class BridgeSupportTest method testInitialChainHeadWithBtcCheckpoints.
@Test
public void testInitialChainHeadWithBtcCheckpoints() throws Exception {
config = new RskSystemProperties();
config.setBlockchainConfig(new TestNetConfig());
bridgeConstants = config.getBlockchainConfig().getCommonConstants().getBridgeConstants();
btcParams = bridgeConstants.getBtcParams();
Repository repository = new RepositoryImpl(config);
Repository track = repository.startTracking();
BridgeStorageProvider provider = new BridgeStorageProvider(track, PrecompiledContracts.BRIDGE_ADDR, config.getBlockchainConfig().getCommonConstants().getBridgeConstants());
BridgeSupport bridgeSupport = new BridgeSupport(config, track, mock(BridgeEventLogger.class), provider, null);
Assert.assertEquals(1229760, bridgeSupport.getBtcBlockStore().getChainHead().getHeight());
}
use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.
the class MainNetMinerTest method setup.
@Before
public void setup() {
config = new RskSystemProperties();
config.setBlockchainConfig(new FallbackMainNetConfig());
DIFFICULTY_CALCULATOR = new DifficultyCalculator(config);
World world = new World();
blockchain = world.getBlockChain();
}
use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.
the class BlockSyncServiceTest method sendBlockMessagesAndAddThemToBlockchainInReverseOrder.
@Test
public void sendBlockMessagesAndAddThemToBlockchainInReverseOrder() {
for (int i = 1; i < 52; i += 5) {
Blockchain blockchain = BlockChainBuilder.ofSize(10 * i);
BlockStore store = new BlockStore();
BlockNodeInformation nodeInformation = new BlockNodeInformation();
RskSystemProperties config = new RskSystemProperties();
BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, SyncConfiguration.IMMEDIATE_FOR_TESTING);
Assert.assertEquals(10 * i, blockchain.getBestBlock().getNumber());
Block initialBestBlock = blockchain.getBestBlock();
List<Block> extendedChain = new BlockGenerator().getBlockChain(blockchain.getBestBlock(), i);
Collections.reverse(extendedChain);
for (int j = 0; j < extendedChain.size() - 1; j++) {
Block block = extendedChain.get(j);
blockSyncService.processBlock(block, null, false);
// we don't have all the parents, so we wait to update the best chain
Assert.assertEquals(initialBestBlock.getNumber(), blockchain.getBestBlock().getNumber());
Assert.assertEquals(initialBestBlock.getHash(), blockchain.getBestBlock().getHash());
}
// the chain is complete, we have a new best block
Block closingBlock = extendedChain.get(extendedChain.size() - 1);
Block newBestBlock = extendedChain.get(0);
blockSyncService.processBlock(closingBlock, null, false);
Assert.assertEquals(newBestBlock.getNumber(), blockchain.getBestBlock().getNumber());
Assert.assertEquals(newBestBlock.getHash(), blockchain.getBestBlock().getHash());
}
}
use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.
the class NodeBlockProcessorTest method advancedBlock.
@Test
public void advancedBlock() throws UnknownHostException {
final BlockStore store = new BlockStore();
final MessageChannel sender = new SimpleMessageChannel();
final BlockNodeInformation nodeInformation = new BlockNodeInformation();
final SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
final Blockchain blockchain = BlockChainBuilder.ofSize(0);
final long advancedBlockNumber = syncConfiguration.getChunkSize() * syncConfiguration.getMaxSkeletonChunks() + blockchain.getBestBlock().getNumber() + 1;
RskSystemProperties config = new RskSystemProperties();
BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
Assert.assertTrue(processor.isAdvancedBlock(advancedBlockNumber));
Assert.assertFalse(processor.isAdvancedBlock(advancedBlockNumber - 1));
}
Aggregations