Skip to content

Commit

Permalink
Update EngineGetPayloadV6110Test
Browse files Browse the repository at this point in the history
Signed-off-by: Navie Chan <naviechan@gmail.com>
  • Loading branch information
ensi321 committed Sep 7, 2023
1 parent 8c24aee commit ae07547
Showing 1 changed file with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand All @@ -28,18 +29,16 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlobsBundleV1;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetPayloadResultV6110;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.BlockWithReceipts;
import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec;

import java.security.InvalidParameterException;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

import org.apache.tuweni.bytes.Bytes;
Expand All @@ -62,7 +61,12 @@ public EngineGetPayloadV6110Test() {
@BeforeEach
@Override
public void before() {
super.before();
lenient()
.when(mergeContext.retrieveBlockById(mockPid))
.thenReturn(Optional.of(mockBlockWithReceiptsAndDeposits));
when(protocolContext.safeConsensusContext(any())).thenReturn(Optional.of(mergeContext));
when(protocolSchedule.hardforkFor(any()))
.thenReturn(Optional.of(new ScheduledProtocolSpec.Hardfork("6110", EIP_6110_AT)));
this.method =
new EngineGetPayloadV6110(
vertx,
Expand Down Expand Up @@ -106,7 +110,7 @@ public void shouldReturnBlockForKnownPayloadId() {
Collections.emptyList(),
Collections.emptyList(),
Optional.of(Collections.emptyList()),
Optional.empty())),
Optional.of(Collections.emptyList()))),
Collections.emptyList());

when(mergeContext.retrieveBlockById(postEip6110Pid)).thenReturn(Optional.of(postEip6110Block));
Expand Down Expand Up @@ -135,17 +139,6 @@ public void shouldReturnBlockForKnownPayloadId() {
verify(engineCallListener, times(1)).executionEngineCalled();
}

@Test
public void blobsBundleV1MustHaveSameNumberOfElements() {
String actualMessage =
assertThrows(
InvalidParameterException.class,
() -> new BlobsBundleV1(List.of(""), List.of(""), List.of()))
.getMessage();
final String expectedMessage = "There must be an equal number of blobs, commitments and proofs";
assertThat(actualMessage).isEqualTo(expectedMessage);
}

@Test
public void shouldReturnUnsupportedFork() {
final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V6110.getMethodName(), mockPid);
Expand Down

0 comments on commit ae07547

Please sign in to comment.