use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EnginePayloadStatusResult in project besu by hyperledger.
the class EngineNewPayloadTest method shouldCheckBlockValidityBeforeCheckingByHashForExisting.
@Test
public void shouldCheckBlockValidityBeforeCheckingByHashForExisting() {
BlockHeader realHeader = new BlockHeaderTestFixture().baseFeePerGas(Wei.ONE).buildHeader();
BlockHeader paramHeader = spy(realHeader);
when(paramHeader.getHash()).thenReturn(Hash.fromHexStringLenient("0x1337"));
var resp = resp(mockPayload(paramHeader, Collections.emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getLatestValidHash()).isEmpty();
assertThat(res.getStatusAsString()).isEqualTo(INVALID_BLOCK_HASH.name());
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EnginePayloadStatusResult in project besu by hyperledger.
the class EngineNewPayloadTest method shouldReturnInvalidBlockHashOnBadHashParameter.
@Test
public void shouldReturnInvalidBlockHashOnBadHashParameter() {
BlockHeader mockHeader = new BlockHeaderTestFixture().buildHeader();
var resp = resp(mockPayload(mockHeader, Collections.emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getLatestValidHash()).isEmpty();
assertThat(res.getStatusAsString()).isEqualTo(INVALID_BLOCK_HASH.name());
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EnginePayloadStatusResult in project besu by hyperledger.
the class EngineNewPayloadTest method shouldRespondWithSyncingDuringForwardSync.
@Test
public void shouldRespondWithSyncingDuringForwardSync() {
BlockHeader mockHeader = new BlockHeaderTestFixture().baseFeePerGas(Wei.ONE).buildHeader();
when(blockchain.getBlockByHash(any())).thenReturn(Optional.empty());
when(mergeContext.isSyncing()).thenReturn(Boolean.TRUE);
var resp = resp(mockPayload(mockHeader, Collections.emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getError()).isNull();
assertThat(res.getStatusAsString()).isEqualTo(SYNCING.name());
assertThat(res.getLatestValidHash()).isEmpty();
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EnginePayloadStatusResult in project besu by hyperledger.
the class EngineNewPayloadTest method shouldReturnValid.
@Test
public void shouldReturnValid() {
BlockHeader mockHeader = new BlockHeaderTestFixture().baseFeePerGas(Wei.ONE).buildHeader();
when(blockchain.getBlockByHash(any())).thenReturn(Optional.empty());
when(mergeCoordinator.getLatestValidAncestor(any(BlockHeader.class))).thenReturn(Optional.of(mockHash));
when(mergeCoordinator.latestValidAncestorDescendsFromTerminal(any(BlockHeader.class))).thenReturn(true);
when(mergeCoordinator.getOrSyncHeaderByHash(any(Hash.class))).thenReturn(Optional.of(mockHeader));
when(mergeCoordinator.executeBlock(any())).thenReturn(new Result(new BlockProcessingOutputs(null, List.of())));
var resp = resp(mockPayload(mockHeader, Collections.emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getLatestValidHash().get()).isEqualTo(mockHeader.getHash());
assertThat(res.getStatusAsString()).isEqualTo(VALID.name());
assertThat(res.getError()).isNull();
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EnginePayloadStatusResult in project besu by hyperledger.
the class EngineNewPayloadTest method shouldRespondWithSyncingDuringBackwardsSync.
@Test
public void shouldRespondWithSyncingDuringBackwardsSync() {
when(mergeCoordinator.getOrSyncHeaderByHash(any(Hash.class))).thenReturn(Optional.empty());
BlockHeader mockHeader = new BlockHeaderTestFixture().baseFeePerGas(Wei.ONE).buildHeader();
var resp = resp(mockPayload(mockHeader, Collections.emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getLatestValidHash()).isEmpty();
assertThat(res.getStatusAsString()).isEqualTo(SYNCING.name());
assertThat(res.getError()).isNull();
}
Aggregations