use of co.rsk.net.simples.SimpleNode in project rskj by rsksmart.
the class OneNodeTest method buildBlockchainInReverse.
@Test
public void buildBlockchainInReverse() {
SimpleNode node = SimpleNode.createNode();
List<Block> blocks = new BlockGenerator().getBlockChain(getGenesis(), 10);
List<Block> reverse = new ArrayList<>();
for (Block block : blocks) reverse.add(0, block);
for (Block block : reverse) node.receiveMessageFrom(null, new BlockMessage(block));
Assert.assertEquals(blocks.size(), node.getBestBlock().getNumber());
Assert.assertEquals(blocks.get(blocks.size() - 1).getHash(), node.getBestBlock().getHash());
}
use of co.rsk.net.simples.SimpleNode in project rskj by rsksmart.
the class TwoNodeTest method buildBlockchainPartialAndSynchronize.
@Test
@Ignore
public void buildBlockchainPartialAndSynchronize() {
SimpleNode node1 = createNode(0);
SimpleNode node2 = createNode(0);
List<Block> blocks = new BlockGenerator().getBlockChain(10);
for (Block block : blocks) {
BlockMessage message = new BlockMessage(block);
node1.receiveMessageFrom(null, message);
if (block.getNumber() <= 5)
node2.receiveMessageFrom(null, message);
}
node1.sendStatusTo(node2);
Assert.assertEquals(10, node1.getBestBlock().getNumber());
Assert.assertEquals(10, node2.getBestBlock().getNumber());
Assert.assertEquals(node1.getBestBlock().getHash(), node2.getBestBlock().getHash());
}
use of co.rsk.net.simples.SimpleNode in project rskj by rsksmart.
the class OneNodeTest method buildBlockchain.
@Test
public void buildBlockchain() {
SimpleNode node = SimpleNode.createNode();
List<Block> blocks = new BlockGenerator().getBlockChain(getGenesis(), 10);
for (Block block : blocks) node.receiveMessageFrom(null, new BlockMessage(block));
Assert.assertEquals(blocks.size(), node.getBestBlock().getNumber());
Assert.assertEquals(blocks.get(blocks.size() - 1).getHash(), node.getBestBlock().getHash());
}
use of co.rsk.net.simples.SimpleNode in project rskj by rsksmart.
the class TwoNodeTest method createNode.
private static SimpleNode createNode(int size) {
final World world = new World();
final BlockStore store = new BlockStore();
final Blockchain blockchain = world.getBlockChain();
List<Block> blocks = new BlockGenerator().getBlockChain(blockchain.getBestBlock(), size);
for (Block b : blocks) blockchain.tryToConnect(b);
BlockNodeInformation nodeInformation = new BlockNodeInformation();
SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
RskSystemProperties config = new RskSystemProperties();
BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
NodeMessageHandler handler = new NodeMessageHandler(new RskSystemProperties(), processor, null, null, null, null, null, new DummyBlockValidationRule());
return new SimpleNode(handler);
}
use of co.rsk.net.simples.SimpleNode in project rskj by rsksmart.
the class TwoNodeTest method buildBlockchainAndSynchronize.
@Test
@Ignore
public void buildBlockchainAndSynchronize() {
SimpleNode node1 = createNode(100);
SimpleNode node2 = createNode(0);
node1.sendStatusTo(node2);
Assert.assertEquals(100, node1.getBestBlock().getNumber());
Assert.assertEquals(100, node2.getBestBlock().getNumber());
Assert.assertEquals(node1.getBestBlock().getHash(), node2.getBestBlock().getHash());
}
Aggregations