protocolSchedule, ethContext, blockchain.getBlockHashByNumber(startNumber).get(), startNumber, count,
private void assertTotalDifficultiesAreConsistent(final Blockchain blockchain, final Block head) { // Check that total difficulties are summed correctly long num = BlockHeader.GENESIS_BLOCK_NUMBER; UInt256 td = UInt256.of(0); while (num <= head.getHeader().getNumber()) { final Hash curHash = blockchain.getBlockHashByNumber(num).get(); final BlockHeader curHead = blockchain.getBlockHeader(curHash).get(); td = td.plus(curHead.getDifficulty()); assertEquals(td, blockchain.getTotalDifficultyByHash(curHash).get()); num += 1; } // Check reported chainhead td assertEquals(td, blockchain.getChainHead().getTotalDifficulty()); }
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); }