use of co.rsk.net.Status in project rskj by rsksmart.
the class StatusMessageTest method createWithBestBlockNumberAndHash.
@Test
public void createWithBestBlockNumberAndHash() {
BlockGenerator blockGenerator = new BlockGenerator();
Block genesis = blockGenerator.getGenesisBlock();
Block block = blockGenerator.createChildBlock(genesis);
Status status = new Status(block.getNumber(), block.getHash().getBytes());
StatusMessage message = new StatusMessage(status);
Assert.assertEquals(MessageType.STATUS_MESSAGE, message.getMessageType());
Assert.assertSame(status, message.getStatus());
Assert.assertEquals(1, message.getStatus().getBestBlockNumber());
Assert.assertArrayEquals(block.getHash().getBytes(), message.getStatus().getBestBlockHash());
Assert.assertNull(message.getStatus().getBestBlockParentHash());
Assert.assertNull(message.getStatus().getTotalDifficulty());
}
use of co.rsk.net.Status in project rskj by rsksmart.
the class StatusMessageTest method createWithCompleteArguments.
@Test
public void createWithCompleteArguments() {
BlockGenerator blockGenerator = new BlockGenerator();
Block genesis = blockGenerator.getGenesisBlock();
Block block = blockGenerator.createChildBlock(genesis);
Status status = new Status(block.getNumber(), block.getHash().getBytes(), block.getParentHash().getBytes(), new BlockDifficulty(BigInteger.TEN));
StatusMessage message = new StatusMessage(status);
Assert.assertEquals(MessageType.STATUS_MESSAGE, message.getMessageType());
Assert.assertSame(status, message.getStatus());
Assert.assertEquals(1, message.getStatus().getBestBlockNumber());
Assert.assertArrayEquals(block.getHash().getBytes(), message.getStatus().getBestBlockHash());
Assert.assertNotNull(message.getStatus().getBestBlockParentHash());
Assert.assertArrayEquals(block.getParentHash().getBytes(), message.getStatus().getBestBlockParentHash());
Assert.assertNotNull(message.getStatus().getTotalDifficulty());
Assert.assertEquals(new BlockDifficulty(BigInteger.TEN), message.getStatus().getTotalDifficulty());
}
Aggregations