Skip to content

Commit

Permalink
new order requires more mocking
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Florentine <[email protected]>
  • Loading branch information
jflo committed Sep 28, 2023
1 parent c7b4d37 commit 11839d2
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,21 @@ public void shouldReturnSyncingIfMissingNewHead() {

@Test
public void shouldReturnInvalidWithLatestValidHashOnBadBlock() {
BlockHeader mockParent = blockHeaderBuilder.buildHeader();
blockHeaderBuilder.parentHash(mockParent.getHash());
BlockHeader mockHeader = blockHeaderBuilder.buildHeader();
Hash latestValidHash = Hash.hash(Bytes32.fromHexStringLenient("0xcafebabe"));
when(blockchain.getBlockHeader(mockHeader.getHash())).thenReturn(Optional.of(mockHeader));
when(blockchain.getBlockHeader(mockHeader.getParentHash())).thenReturn(Optional.of(mockHeader));
when(blockchain.getBlockHeader(mockHeader.getParentHash())).thenReturn(Optional.of(mockParent));
when(mergeCoordinator.getOrSyncHeadByHash(any(), any())).thenReturn(Optional.of(mockHeader));
when(mergeCoordinator.isBadBlock(mockHeader.getHash())).thenReturn(true);
when(mergeCoordinator.isDescendantOf(any(), any())).thenReturn(true);
when(mergeCoordinator.getLatestValidHashOfBadBlock(mockHeader.getHash()))
.thenReturn(Optional.of(latestValidHash));

assertSuccessWithPayloadForForkchoiceResult(
new EngineForkchoiceUpdatedParameter(
mockHeader.getHash(), Hash.ZERO, mockHeader.getParentHash()),
mockHeader.getHash(), mockHeader.getParentHash(), mockHeader.getParentHash()),
Optional.empty(),
mock(ForkchoiceResult.class),
INVALID,
Expand Down

0 comments on commit 11839d2

Please sign in to comment.