Search in sources :

Example 1 with ForkChoiceUpdatedResult

use of tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceUpdatedResult in project teku by ConsenSys.

the class Web3JExecutionEngineClientTest method shouldDeserializeForkChoiceUpdatedResultWithNulls.

@TestTemplate
void shouldDeserializeForkChoiceUpdatedResultWithNulls() throws IOException {
    ForkChoiceUpdatedResult forkChoiceUpdatedResultExpected = createExternalForkChoiceUpdatedResult(ExecutionPayloadStatus.SYNCING, null, null);
    tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult internalForkChoiceUpdatedResultExpected = createInternalForkChoiceUpdatedResult(ExecutionPayloadStatus.SYNCING, Optional.empty(), Optional.empty());
    String json = "{\"payloadStatus\": {\"status\": \"SYNCING\"}, \"payloadId\": null }";
    ForkChoiceUpdatedResult executeForkChoiceUpdatedResultDeserialized = objectMapper.readValue(json, ForkChoiceUpdatedResult.class);
    tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult internalForkChoiceUpdatedResult = executeForkChoiceUpdatedResultDeserialized.asInternalExecutionPayload();
    assertThat(executeForkChoiceUpdatedResultDeserialized).isEqualTo(forkChoiceUpdatedResultExpected);
    assertThat(internalForkChoiceUpdatedResult).isEqualTo(internalForkChoiceUpdatedResultExpected);
}
Also used : ForkChoiceUpdatedResult(tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceUpdatedResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 2 with ForkChoiceUpdatedResult

use of tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceUpdatedResult in project teku by ConsenSys.

the class Web3JExecutionEngineClientTest method shouldDeserializeForkChoiceUpdatedResult.

@TestTemplate
void shouldDeserializeForkChoiceUpdatedResult() throws IOException {
    Bytes8 payloadId = dataStructureUtil.randomBytes8();
    Bytes32 latestValidHash = dataStructureUtil.randomBytes32();
    ForkChoiceUpdatedResult forkChoiceUpdatedResultExpected = createExternalForkChoiceUpdatedResult(ExecutionPayloadStatus.VALID, latestValidHash, payloadId);
    tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult internalForkChoiceUpdatedResultExpected = createInternalForkChoiceUpdatedResult(ExecutionPayloadStatus.VALID, Optional.of(latestValidHash), Optional.of(payloadId));
    String json = "{\"payloadStatus\": {\"status\": \"VALID\", \"latestValidHash\": \"" + latestValidHash.toHexString() + "\"}, \"payloadId\": \"" + payloadId.toHexString() + "\" }";
    ForkChoiceUpdatedResult executeForkChoiceUpdatedResultDeserialized = objectMapper.readValue(json, ForkChoiceUpdatedResult.class);
    tech.pegasys.teku.spec.executionengine.ForkChoiceUpdatedResult internalForkChoiceUpdatedResult = executeForkChoiceUpdatedResultDeserialized.asInternalExecutionPayload();
    assertThat(executeForkChoiceUpdatedResultDeserialized).isEqualTo(forkChoiceUpdatedResultExpected);
    assertThat(internalForkChoiceUpdatedResult).isEqualTo(internalForkChoiceUpdatedResultExpected);
}
Also used : Bytes8(tech.pegasys.teku.infrastructure.bytes.Bytes8) ForkChoiceUpdatedResult(tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceUpdatedResult) Bytes32(org.apache.tuweni.bytes.Bytes32) TestTemplate(org.junit.jupiter.api.TestTemplate)

Aggregations

TestTemplate (org.junit.jupiter.api.TestTemplate)2 ForkChoiceUpdatedResult (tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceUpdatedResult)2 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 Bytes8 (tech.pegasys.teku.infrastructure.bytes.Bytes8)1