use of co.rsk.blockchain.utils.BlockGenerator in project rskj by rsksmart.
the class BlockHeadersMessageTest method getBlockHeader.
@Test
public void getBlockHeader() {
Block block = new BlockGenerator().getBlock(1);
BlockHeadersMessage message = new BlockHeadersMessage(block.getHeader());
Assert.assertSame(block.getHeader(), message.getBlockHeaders().get(0));
}
use of co.rsk.blockchain.utils.BlockGenerator in project rskj by rsksmart.
the class BlockRequestMessageTest method createWithBlockHash.
@Test
public void createWithBlockHash() {
byte[] hash = new BlockGenerator().getGenesisBlock().getHash().getBytes();
BlockRequestMessage message = new BlockRequestMessage(100, hash);
Assert.assertEquals(100, message.getId());
Assert.assertArrayEquals(hash, message.getBlockHash());
Assert.assertEquals(MessageType.BLOCK_REQUEST_MESSAGE, message.getMessageType());
}
use of co.rsk.blockchain.utils.BlockGenerator in project rskj by rsksmart.
the class BlockResponseMessageTest method createWithBlockHash.
@Test
public void createWithBlockHash() {
Block block = new BlockGenerator().getBlock(1);
BlockResponseMessage message = new BlockResponseMessage(100, block);
Assert.assertEquals(100, message.getId());
Assert.assertEquals(block.getHash(), message.getBlock().getHash());
Assert.assertEquals(MessageType.BLOCK_RESPONSE_MESSAGE, message.getMessageType());
}
use of co.rsk.blockchain.utils.BlockGenerator in project rskj by rsksmart.
the class BodyRequestMessageTest method createWithBlockHash.
@Test
public void createWithBlockHash() {
byte[] hash = new BlockGenerator().getGenesisBlock().getHash().getBytes();
BodyRequestMessage message = new BodyRequestMessage(100, hash);
Assert.assertEquals(100, message.getId());
Assert.assertArrayEquals(hash, message.getBlockHash());
Assert.assertEquals(MessageType.BODY_REQUEST_MESSAGE, message.getMessageType());
}
use of co.rsk.blockchain.utils.BlockGenerator in project rskj by rsksmart.
the class BodyResponseMessageTest method createMessage.
@Test
public void createMessage() {
List<Transaction> transactions = new ArrayList<>();
for (int k = 1; k <= 10; k++) transactions.add(createTransaction(k));
List<BlockHeader> uncles = new ArrayList<>();
BlockGenerator blockGenerator = new BlockGenerator();
Block parent = blockGenerator.getGenesisBlock();
for (int k = 1; k < 10; k++) {
Block block = blockGenerator.createChildBlock(parent);
uncles.add(block.getHeader());
parent = block;
}
BodyResponseMessage message = new BodyResponseMessage(100, transactions, uncles);
Assert.assertEquals(100, message.getId());
Assert.assertNotNull(message.getTransactions());
Assert.assertEquals(transactions.size(), message.getTransactions().size());
Assert.assertEquals(transactions, message.getTransactions());
Assert.assertNotNull(message.getUncles());
Assert.assertEquals(uncles.size(), message.getUncles().size());
for (int k = 0; k < uncles.size(); k++) Assert.assertArrayEquals(uncles.get(k).getEncoded(), message.getUncles().get(k).getEncoded());
}
Aggregations