@Override protected Map<BlockHeader, List<TransactionReceipt>> generateDataToBeRequested() { final Map<BlockHeader, List<TransactionReceipt>> expectedData = new HashMap<>(); for (long i = 0; i < 3; i++) { final BlockHeader header = blockchain.getBlockHeader(10 + i).get(); final List<TransactionReceipt> transactionReceipts = blockchain.getTxReceipts(header.getHash()).get(); expectedData.put(header, transactionReceipts); } return expectedData; }
for (int i = 0; i < blockCount; i++) { final BlockHeader header = blockchain.getBlockHeader(startBlock + i).get(); expectedReceipts.add(blockchain.getTxReceipts(header.getHash()).get()); blockHashes.add(header.getHash());
for (int i = 0; i < blockCount; i++) { final BlockHeader header = blockchain.getBlockHeader(startBlock + i).get(); expectedReceipts.add(blockchain.getTxReceipts(header.getHash()).get()); blockHashes.add(header.getHash());
private MutableBlockchain createShortChain(final long lastBlockToInclude) { final BlockHeader genesisHeader = blockchain.getBlockHeader(BlockHeader.GENESIS_BLOCK_NUMBER).get(); final BlockBody genesisBody = blockchain.getBlockBody(genesisHeader.getHash()).get(); final Block genesisBlock = new Block(genesisHeader, genesisBody); final MutableBlockchain shortChain = createInMemoryBlockchain(genesisBlock); long nextBlock = genesisHeader.getNumber() + 1; while (nextBlock <= lastBlockToInclude) { final BlockHeader header = blockchain.getBlockHeader(nextBlock).get(); final BlockBody body = blockchain.getBlockBody(header.getHash()).get(); final List<TransactionReceipt> receipts = blockchain.getTxReceipts(header.getHash()).get(); final Block block = new Block(header, body); shortChain.appendBlock(block, receipts); nextBlock++; } return shortChain; }
private MutableBlockchain createShortChain( final Blockchain blockchain, final long truncateAtBlockNumber) { final BlockHeader genesisHeader = blockchain.getBlockHeader(BlockHeader.GENESIS_BLOCK_NUMBER).get(); final BlockBody genesisBody = blockchain.getBlockBody(genesisHeader.getHash()).get(); final Block genesisBlock = new Block(genesisHeader, genesisBody); final MutableBlockchain shortChain = createInMemoryBlockchain(genesisBlock); long nextBlock = genesisHeader.getNumber() + 1; while (nextBlock <= truncateAtBlockNumber) { final BlockHeader header = blockchain.getBlockHeader(nextBlock).get(); final BlockBody body = blockchain.getBlockBody(header.getHash()).get(); final List<TransactionReceipt> receipts = blockchain.getTxReceipts(header.getHash()).get(); final Block block = new Block(header, body); shortChain.appendBlock(block, receipts); nextBlock++; } return shortChain; } }
private MutableBlockchain createShortChain(final long truncateAtBlockNumber) { final BlockHeader genesisHeader = blockchain.getBlockHeader(BlockHeader.GENESIS_BLOCK_NUMBER).get(); final BlockBody genesisBody = blockchain.getBlockBody(genesisHeader.getHash()).get(); final Block genesisBlock = new Block(genesisHeader, genesisBody); final MutableBlockchain shortChain = createInMemoryBlockchain(genesisBlock); long nextBlock = genesisHeader.getNumber() + 1; while (nextBlock <= truncateAtBlockNumber) { final BlockHeader header = blockchain.getBlockHeader(nextBlock).get(); final BlockBody body = blockchain.getBlockBody(header.getHash()).get(); final List<TransactionReceipt> receipts = blockchain.getTxReceipts(header.getHash()).get(); final Block block = new Block(header, body); shortChain.appendBlock(block, receipts); nextBlock++; } return shortChain; } }
final BlockHeader header = blockchain.getBlockHeader(blockNumber).get(); final List<TransactionReceipt> expectedReceipts = blockchain.getTxReceipts(header.getHash()).get(); final Hash blockHash = header.getHash(); final MessageData messageData =
private void assertBlockDataIsStored( final Blockchain blockchain, final Block block, final List<TransactionReceipt> receipts) { final Hash hash = block.getHash(); assertEquals(hash, blockchain.getBlockHashByNumber(block.getHeader().getNumber()).get()); assertEquals(block.getHeader(), blockchain.getBlockHeader(block.getHeader().getNumber()).get()); assertEquals(block.getHeader(), blockchain.getBlockHeader(hash).get()); assertEquals(block.getBody(), blockchain.getBlockBody(hash).get()); assertThat(blockchain.blockIsOnCanonicalChain(block.getHash())).isTrue(); final List<Transaction> txs = block.getBody().getTransactions(); for (int i = 0; i < txs.size(); i++) { final Transaction expected = txs.get(i); final Transaction actual = blockchain.getTransactionByHash(expected.hash()).get(); assertEquals(expected, actual); } final List<TransactionReceipt> actualReceipts = blockchain.getTxReceipts(hash).get(); assertEquals(receipts, actualReceipts); }