Search in sources :

Example 1 with GetBlockRootResponse

use of tech.pegasys.teku.api.response.v1.beacon.GetBlockRootResponse in project teku by ConsenSys.

the class TekuNode method fetchBeaconHead.

private Optional<Bytes32> fetchBeaconHead() throws IOException {
    final String result = httpClient.get(getRestApiUrl(), "/eth/v1/beacon/blocks/head/root");
    if (result.isEmpty()) {
        return Optional.empty();
    }
    final GetBlockRootResponse response = jsonProvider.jsonToObject(result, GetBlockRootResponse.class);
    return Optional.of(response.data.root);
}
Also used : GetBlockRootResponse(tech.pegasys.teku.api.response.v1.beacon.GetBlockRootResponse)

Example 2 with GetBlockRootResponse

use of tech.pegasys.teku.api.response.v1.beacon.GetBlockRootResponse in project teku by ConsenSys.

the class GetBlockRootIntegrationTest method shouldGetBlockRoot.

@Test
public void shouldGetBlockRoot() throws IOException {
    final List<SignedBlockAndState> created = createBlocksAtSlots(10);
    final Response response = get("head");
    final GetBlockRootResponse body = jsonProvider.jsonToObject(response.body().string(), GetBlockRootResponse.class);
    final Root data = body.data;
    final Bytes32 blockRoot = created.get(0).getRoot();
    assertThat(data).isEqualTo(new Root(blockRoot));
    // Bellatrix not enabled
    assertThat(body.execution_optimistic).isNull();
}
Also used : GetBlockRootResponse(tech.pegasys.teku.api.response.v1.beacon.GetBlockRootResponse) Response(okhttp3.Response) Root(tech.pegasys.teku.api.schema.Root) GetBlockRoot(tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetBlockRoot) GetBlockRootResponse(tech.pegasys.teku.api.response.v1.beacon.GetBlockRootResponse) SignedBlockAndState(tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState) Bytes32(org.apache.tuweni.bytes.Bytes32) Test(org.junit.jupiter.api.Test) AbstractDataBackedRestAPIIntegrationTest(tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest)

Aggregations

GetBlockRootResponse (tech.pegasys.teku.api.response.v1.beacon.GetBlockRootResponse)2 Response (okhttp3.Response)1 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 Test (org.junit.jupiter.api.Test)1 Root (tech.pegasys.teku.api.schema.Root)1 AbstractDataBackedRestAPIIntegrationTest (tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest)1 GetBlockRoot (tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetBlockRoot)1 SignedBlockAndState (tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState)1