use of tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader in project teku by ConsenSys.
the class GenesisInitializationTestExecutor method runTest.
@Override
public void runTest(final TestDefinition testDefinition) throws Exception {
final Spec spec = testDefinition.getSpec();
final BeaconState expectedGenesisState = loadStateFromSsz(testDefinition, "state.ssz_snappy");
final Eth1MetaData eth1MetaData = loadYaml(testDefinition, "eth1.yaml", Eth1MetaData.class);
final GenesisMetaData metaData = loadYaml(testDefinition, "meta.yaml", GenesisMetaData.class);
final List<Deposit> deposits = IntStream.range(0, metaData.getDepositsCount()).mapToObj(index -> loadSsz(testDefinition, "deposits_" + index + ".ssz_snappy", Deposit.SSZ_SCHEMA)).collect(Collectors.toList());
final Optional<ExecutionPayloadHeader> executionPayloadHeader;
if (metaData.hasExecutionPayloadHeader()) {
executionPayloadHeader = Optional.of(loadSsz(testDefinition, "execution_payload_header.ssz_snappy", SchemaDefinitionsBellatrix.required(spec.getGenesisSchemaDefinitions()).getExecutionPayloadHeaderSchema()));
} else {
executionPayloadHeader = Optional.empty();
}
final BeaconState result = spec.initializeBeaconStateFromEth1(eth1MetaData.getEth1BlockHash(), eth1MetaData.getEth1Timestamp(), deposits, executionPayloadHeader);
assertThat(result).isEqualTo(expectedGenesisState);
}
use of tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader in project teku by ConsenSys.
the class Web3JExecutionEngineClientTest method shouldSerializeDeserializeExecutionPayloadHeaderV1.
@TestTemplate
void shouldSerializeDeserializeExecutionPayloadHeaderV1() throws IOException {
ExecutionPayloadHeader internalExecutionPayloadHeader = dataStructureUtil.randomExecutionPayloadHeader();
ExecutionPayloadHeaderV1 executionPayloadHeaderV1Orig = ExecutionPayloadHeaderV1.fromInternalExecutionPayloadHeader(internalExecutionPayloadHeader);
String executionPayloadHeaderV1OrigSerialized = objectMapper.writeValueAsString(executionPayloadHeaderV1Orig);
ExecutionPayloadHeaderV1 executionPayloadHeaderV1New = objectMapper.readValue(executionPayloadHeaderV1OrigSerialized, ExecutionPayloadHeaderV1.class);
assertThat(executionPayloadHeaderV1Orig).isEqualTo(executionPayloadHeaderV1New);
assertThat(executionPayloadHeaderV1Orig.asInternalExecutionPayloadHeader(internalExecutionPayloadHeader.getSchema())).isEqualTo(internalExecutionPayloadHeader);
}
use of tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader in project teku by ConsenSys.
the class GenesisGeneratorTest method shouldGenerateStateWithExecutionPayload.
@Test
public void shouldGenerateStateWithExecutionPayload() {
final Spec spec = TestSpecFactory.createMinimalBellatrix();
final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);
final GenesisGenerator genesisGenerator = new GenesisGenerator(spec.getGenesisSpec(), spec.fork(UInt64.ZERO));
genesisGenerator.updateCandidateState(dataStructureUtil.randomBytes32(), UInt64.valueOf(982928293223232L), initialDeposits.subList(0, 8));
final ExecutionPayloadHeader payloadHeader = dataStructureUtil.randomExecutionPayloadHeader();
genesisGenerator.updateExecutionPayloadHeader(payloadHeader);
final BeaconState actualState = genesisGenerator.getGenesisState();
assertThat(actualState).isInstanceOf(BeaconStateBellatrix.class);
assertThat(BeaconStateBellatrix.required(actualState).getLatestExecutionPayloadHeader()).isEqualTo(payloadHeader);
}
Aggregations