Skip to content

Commit

Permalink
Improving coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Peinlich <[email protected]>
  • Loading branch information
gezero committed Mar 18, 2022
1 parent bbe59bf commit ec18c73
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,22 @@ public void shouldDropBlocksThatWeTrust() {
.isEqualTo(getBlockByNumber(LOCAL_HEIGHT + 2).getHeader());
}

@Test
public void shouldMergeEvenLongerChains() {
final BackwardChain backwardChain = createBackwardChain(LOCAL_HEIGHT - 5, LOCAL_HEIGHT+7);
backwardChain.appendExpectedBlock(getBlockByNumber(LOCAL_HEIGHT + 1));
final BackwardChain finalChain = createBackwardChain(LOCAL_HEIGHT + 2, LOCAL_HEIGHT + 5);
finalChain.prependChain(backwardChain);

ForwardSyncPhase step = new ForwardSyncPhase(context, finalChain);

assertThat(finalChain.getFirstAncestorHeader().orElseThrow())
.isEqualTo(getBlockByNumber(LOCAL_HEIGHT - 5).getHeader());
step.processKnownAncestors(null);
assertThat(finalChain.getFirstAncestorHeader().orElseThrow())
.isEqualTo(getBlockByNumber(LOCAL_HEIGHT + 2).getHeader());
}

@Test
public void shouldFindBlockWhenRequested() throws Exception {
ForwardSyncPhase step =
Expand Down

0 comments on commit ec18c73

Please sign in to comment.