Search in sources :

Example 1 with BlockHeader

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

the class GetBlockHeaderIntegrationTest method shouldGetBlockHeader.

@Test
public void shouldGetBlockHeader() throws IOException {
    final List<SignedBlockAndState> created = createBlocksAtSlots(10);
    final Response response = get("head");
    final GetBlockHeaderResponse body = jsonProvider.jsonToObject(response.body().string(), GetBlockHeaderResponse.class);
    final BlockHeader data = body.data;
    assertThat(data).isEqualTo(new BlockHeader(created.get(0).getBlock(), true));
}
Also used : Response(okhttp3.Response) GetBlockHeaderResponse(tech.pegasys.teku.api.response.v1.beacon.GetBlockHeaderResponse) GetBlockHeaderResponse(tech.pegasys.teku.api.response.v1.beacon.GetBlockHeaderResponse) SignedBlockAndState(tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState) GetBlockHeader(tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetBlockHeader) BlockHeader(tech.pegasys.teku.api.response.v1.beacon.BlockHeader) Test(org.junit.jupiter.api.Test) AbstractDataBackedRestAPIIntegrationTest(tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest)

Example 2 with BlockHeader

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

the class ChainDataProviderTest method getBlockHeaderByBlockId_shouldGetHeadBlock.

@Test
public void getBlockHeaderByBlockId_shouldGetHeadBlock() throws ExecutionException, InterruptedException {
    final ChainDataProvider provider = new ChainDataProvider(spec, recentChainData, combinedChainDataClient);
    final tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock block = storageSystem.getChainHead().getSignedBeaconBlock().orElseThrow();
    ObjectAndMetaData<BlockHeader> result = provider.getBlockHeader("head").get().orElseThrow();
    final BeaconBlockHeader beaconBlockHeader = new BeaconBlockHeader(block.getSlot(), block.getMessage().getProposerIndex(), block.getParentRoot(), block.getStateRoot(), block.getBodyRoot());
    final BlockHeader expected = new BlockHeader(block.getRoot(), true, new SignedBeaconBlockHeader(beaconBlockHeader, new BLSSignature(block.getSignature())));
    assertThat(result).isEqualTo(addMetaData(expected, block.getSlot()));
}
Also used : SignedBeaconBlockHeader(tech.pegasys.teku.api.schema.SignedBeaconBlockHeader) SignedBeaconBlockHeader(tech.pegasys.teku.api.schema.SignedBeaconBlockHeader) BlockHeader(tech.pegasys.teku.api.response.v1.beacon.BlockHeader) BeaconBlockHeader(tech.pegasys.teku.api.schema.BeaconBlockHeader) SignedBeaconBlockHeader(tech.pegasys.teku.api.schema.SignedBeaconBlockHeader) BeaconBlockHeader(tech.pegasys.teku.api.schema.BeaconBlockHeader) BLSSignature(tech.pegasys.teku.api.schema.BLSSignature) Test(org.junit.jupiter.api.Test)

Example 3 with BlockHeader

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

the class ChainDataProviderTest method shouldGetBlockHeadersOnEmptyChainHeadSlot.

@Test
public void shouldGetBlockHeadersOnEmptyChainHeadSlot() {
    final ChainDataProvider provider = new ChainDataProvider(spec, recentChainData, combinedChainDataClient);
    final UInt64 headSlot = recentChainData.getHeadSlot();
    storageSystem.chainUpdater().advanceChain(headSlot.plus(1));
    final SafeFuture<GetBlockHeadersResponse> future = provider.getBlockHeaders(Optional.empty(), Optional.empty());
    final BlockHeader header = safeJoin(future).data.get(0);
    assertThat(header.header.message.slot).isEqualTo(headSlot);
}
Also used : GetBlockHeadersResponse(tech.pegasys.teku.api.response.v1.beacon.GetBlockHeadersResponse) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) SignedBeaconBlockHeader(tech.pegasys.teku.api.schema.SignedBeaconBlockHeader) BlockHeader(tech.pegasys.teku.api.response.v1.beacon.BlockHeader) BeaconBlockHeader(tech.pegasys.teku.api.schema.BeaconBlockHeader) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 BlockHeader (tech.pegasys.teku.api.response.v1.beacon.BlockHeader)3 BeaconBlockHeader (tech.pegasys.teku.api.schema.BeaconBlockHeader)2 SignedBeaconBlockHeader (tech.pegasys.teku.api.schema.SignedBeaconBlockHeader)2 Response (okhttp3.Response)1 GetBlockHeaderResponse (tech.pegasys.teku.api.response.v1.beacon.GetBlockHeaderResponse)1 GetBlockHeadersResponse (tech.pegasys.teku.api.response.v1.beacon.GetBlockHeadersResponse)1 BLSSignature (tech.pegasys.teku.api.schema.BLSSignature)1 AbstractDataBackedRestAPIIntegrationTest (tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest)1 GetBlockHeader (tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetBlockHeader)1 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)1 SignedBlockAndState (tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState)1