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));
}
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()));
}
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);
}
Aggregations