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 <justin+github@florentine.us>
  • Loading branch information
jflo committed Sep 27, 2023
1 parent 8b7cfe3 commit f324297
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 f324297

Please sign in to comment.