Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Karim TAAM <[email protected]>
  • Loading branch information
matkt committed Jun 28, 2021
1 parent a0d8584 commit 325308b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ private void handleNewBlockHashesFromNetwork(final EthMessage message) {

@SuppressWarnings("unused")
private CompletableFuture<Block> retrieveMissingAnnouncedBlock(final long blockNumber) {
LOG.info("retrieveMissingAnnouncedBlock " + blockNumber);
final List<EthPeer> peers =
ethContext.getEthPeers().streamBestPeers().collect(Collectors.toList());
final GetBlockFromPeersTask getBlockTask =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,18 @@ public void shouldReplaceLowestPriorityBlockWhenCacheIsFull() {
}
assertThat(pendingBlocksManager.contains(reorgBlock.getHash())).isTrue();
}

@Test
public void shouldReturnLowestBlockByNumber() {
final BlockDataGenerator gen = new BlockDataGenerator();
final Block parentBlock = gen.block();
final Block childBlock = gen.nextBlock(parentBlock);
final Block childBlock2 = gen.nextBlock(parentBlock);

pendingBlocksManager.registerPendingBlock(parentBlock, NODE_ID_1);
pendingBlocksManager.registerPendingBlock(childBlock, NODE_ID_1);
pendingBlocksManager.registerPendingBlock(childBlock2, NODE_ID_1);

assertThat(pendingBlocksManager.lowestAnnouncedBlock()).contains(parentBlock.getHeader());
}
}

0 comments on commit 325308b

Please sign in to comment.