use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.
the class NodeBlockProcessorTest method processStatusHavingBestBlockInStore.
@Test
@Ignore("Ignored when Process status deleted on block processor")
public void processStatusHavingBestBlockInStore() throws UnknownHostException {
final BlockStore store = new BlockStore();
final Blockchain blockchain = BlockChainBuilder.ofSize(0);
BlockNodeInformation nodeInformation = new BlockNodeInformation();
SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
RskSystemProperties config = new RskSystemProperties();
BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
final SimpleMessageChannel sender = new SimpleMessageChannel();
BlockGenerator blockGenerator = new BlockGenerator();
final Block genesis = blockGenerator.getGenesisBlock();
final Block block = blockGenerator.createChildBlock(genesis);
store.saveBlock(block);
// final Status status = new Status(block.getNumber(), block.getHash());
// processor.processStatus(sender, status);
Assert.assertTrue(processor.getNodeInformation().getNodesByBlock(block.getHash().getBytes()).size() == 1);
Assert.assertEquals(1, store.size());
}
use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.
the class NodeBlockProcessorTest method processBlockAddingToBlockchain.
@Test
public void processBlockAddingToBlockchain() {
Blockchain blockchain = BlockChainBuilder.ofSize(10);
Assert.assertEquals(10, blockchain.getBestBlock().getNumber());
BlockStore store = new BlockStore();
Block genesis = blockchain.getBlockByNumber(0);
store.saveBlock(genesis);
Block block = new BlockGenerator().createChildBlock(blockchain.getBlockByNumber(10));
Assert.assertEquals(11, block.getNumber());
Assert.assertArrayEquals(blockchain.getBestBlockHash(), block.getParentHash().getBytes());
BlockNodeInformation nodeInformation = new BlockNodeInformation();
SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
RskSystemProperties config = new RskSystemProperties();
BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
processor.processBlock(null, block);
Assert.assertFalse(store.hasBlock(block));
Assert.assertEquals(11, blockchain.getBestBlock().getNumber());
Assert.assertArrayEquals(block.getHash().getBytes(), blockchain.getBestBlockHash());
Assert.assertEquals(1, store.size());
}
use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.
the class NodeBlockProcessorTest method noSyncingWithEmptyBlockchain.
@Test
public void noSyncingWithEmptyBlockchain() {
BlockStore store = new BlockStore();
Blockchain blockchain = BlockChainBuilder.ofSize(0);
BlockNodeInformation nodeInformation = new BlockNodeInformation();
SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
RskSystemProperties config = new RskSystemProperties();
BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
Assert.assertFalse(processor.hasBetterBlockToSync());
}
use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.
the class NodeBlockProcessorTest method canBeIgnoredForUncles.
@Test
public void canBeIgnoredForUncles() 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(15);
final RskSystemProperties config = new RskSystemProperties();
int uncleGenerationLimit = config.getBlockchainConfig().getCommonConstants().getUncleGenerationLimit();
final long blockNumberThatCanBeIgnored = blockchain.getBestBlock().getNumber() - 1 - uncleGenerationLimit;
BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
Assert.assertTrue(processor.canBeIgnoredForUnclesRewards(blockNumberThatCanBeIgnored));
Assert.assertFalse(processor.canBeIgnoredForUnclesRewards(blockNumberThatCanBeIgnored + 1));
}
use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.
the class NodeBlockProcessorTest method syncingWithEmptyBlockchainAndHighBestBlock.
@Test
@Ignore("Ignored when Process status deleted on block processor")
public void syncingWithEmptyBlockchainAndHighBestBlock() {
BlockStore store = new BlockStore();
Block block = new BlockGenerator().createBlock(30, 0);
Blockchain blockchain = BlockChainBuilder.ofSize(0);
BlockNodeInformation nodeInformation = new BlockNodeInformation();
SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
RskSystemProperties config = new RskSystemProperties();
BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
Assert.assertFalse(processor.hasBetterBlockToSync());
// Status status = new Status(block.getNumber(), block.getHash());
// processor.processStatus(new SimpleNodeChannel(null, null), status);
Assert.assertTrue(processor.hasBetterBlockToSync());
}
Aggregations