Search in sources :

Example 1 with TransitionConfigurationV1

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

the class Web3JExecutionEngineClientTest method shouldSerializeTransitionConfigurationV1.

@TestTemplate
void shouldSerializeTransitionConfigurationV1() throws IOException {
    final TransitionConfigurationV1 externalTransitionConfiguration = new TransitionConfigurationV1(dataStructureUtil.randomUInt256(), dataStructureUtil.randomBytes32(), dataStructureUtil.randomUInt64());
    String serialized = objectMapper.writeValueAsString(externalTransitionConfiguration);
    assertThat(serialized).isNotEmpty();
}
Also used : TransitionConfigurationV1(tech.pegasys.teku.ethereum.executionlayer.client.schema.TransitionConfigurationV1) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 2 with TransitionConfigurationV1

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

the class Web3JExecutionEngineClientTest method shouldTransitionConfigurationRoundtrip.

@TestTemplate
void shouldTransitionConfigurationRoundtrip() {
    final TransitionConfigurationV1 externalTransitionConfiguration = new TransitionConfigurationV1(dataStructureUtil.randomUInt256(), dataStructureUtil.randomBytes32(), dataStructureUtil.randomUInt64());
    final TransitionConfiguration internalTransitionConfiguration = externalTransitionConfiguration.asInternalTransitionConfiguration();
    assertThat(internalTransitionConfiguration.getTerminalBlockHash()).isEqualTo(externalTransitionConfiguration.terminalBlockHash);
    assertThat(internalTransitionConfiguration.getTerminalBlockNumber()).isEqualTo(externalTransitionConfiguration.terminalBlockNumber);
    assertThat(internalTransitionConfiguration.getTerminalTotalDifficulty()).isEqualTo(externalTransitionConfiguration.terminalTotalDifficulty);
    final TransitionConfigurationV1 externalTransitionConfiguration2 = TransitionConfigurationV1.fromInternalTransitionConfiguration(internalTransitionConfiguration);
    assertThat(externalTransitionConfiguration2).isEqualTo(externalTransitionConfiguration);
}
Also used : TransitionConfiguration(tech.pegasys.teku.spec.executionengine.TransitionConfiguration) TransitionConfigurationV1(tech.pegasys.teku.ethereum.executionlayer.client.schema.TransitionConfigurationV1) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 3 with TransitionConfigurationV1

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

the class Web3JExecutionEngineClientTest method shouldSerializeDeserializeTransitionConfigurationV1.

@TestTemplate
void shouldSerializeDeserializeTransitionConfigurationV1() throws IOException {
    final TransitionConfigurationV1 externalTransitionConfiguration = new TransitionConfigurationV1(dataStructureUtil.randomUInt256(), dataStructureUtil.randomBytes32(), dataStructureUtil.randomUInt64());
    String serialized = objectMapper.writeValueAsString(externalTransitionConfiguration);
    assertThat(serialized).isNotEmpty();
    TransitionConfigurationV1 externalTransitionConfiguration2 = objectMapper.readValue(serialized, TransitionConfigurationV1.class);
    assertThat(externalTransitionConfiguration).isEqualTo(externalTransitionConfiguration2);
}
Also used : TransitionConfigurationV1(tech.pegasys.teku.ethereum.executionlayer.client.schema.TransitionConfigurationV1) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 4 with TransitionConfigurationV1

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

the class Web3JExecutionEngineClientTest method shouldDeserializeTransitionConfigurationV1.

@TestTemplate
void shouldDeserializeTransitionConfigurationV1() throws IOException {
    final String json = "{\"terminalTotalDifficulty\": \"0xF123657934589000000000000000001\", " + "\"terminalBlockHash\": \"0x95b8e2ba063ab62f68ebe7db0a9669ab9e7906aa4e060e1cc0b67b294ce8c5e4\", " + "\"terminalBlockNumber\": \"0xa79345890\" }";
    final TransitionConfigurationV1 externalTransitionConfiguration = objectMapper.readValue(json, TransitionConfigurationV1.class);
    assertThat(externalTransitionConfiguration.terminalTotalDifficulty).isEqualTo(UInt256.fromHexString("0xF123657934589000000000000000001"));
    assertThat(externalTransitionConfiguration.terminalBlockHash).isEqualTo(Bytes32.fromHexString("0x95b8e2ba063ab62f68ebe7db0a9669ab9e7906aa4e060e1cc0b67b294ce8c5e4"));
    assertThat(externalTransitionConfiguration.terminalBlockNumber).isEqualTo(UInt64.valueOf(Bytes.fromHexStringLenient("0xa79345890").toUnsignedBigInteger()));
}
Also used : TransitionConfigurationV1(tech.pegasys.teku.ethereum.executionlayer.client.schema.TransitionConfigurationV1) TestTemplate(org.junit.jupiter.api.TestTemplate)

Aggregations

TestTemplate (org.junit.jupiter.api.TestTemplate)4 TransitionConfigurationV1 (tech.pegasys.teku.ethereum.executionlayer.client.schema.TransitionConfigurationV1)4 TransitionConfiguration (tech.pegasys.teku.spec.executionengine.TransitionConfiguration)1