use of tech.pegasys.teku.api.schema.BLSSignature 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.schema.BLSSignature in project teku by ConsenSys.
the class OkHttpValidatorRestApiClientTest method createUnsignedBlock_Altair_ReturnsBeaconBlock.
@Test
public void createUnsignedBlock_Altair_ReturnsBeaconBlock() {
final UInt64 slot = UInt64.ONE;
final BLSSignature blsSignature = schemaObjects.blsSignature();
final Optional<Bytes32> graffiti = Optional.of(Bytes32.random());
final BeaconBlock expectedBeaconBlock = schemaObjects.beaconBlockAltair();
mockWebServer.enqueue(new MockResponse().setResponseCode(SC_OK).setBody(asJson(new GetNewBlockResponseV2(SpecMilestone.ALTAIR, expectedBeaconBlock))));
Optional<BeaconBlock> beaconBlock = apiClient.createUnsignedBlock(slot, blsSignature, graffiti);
assertThat(beaconBlock).isPresent();
assertThat(beaconBlock.get()).usingRecursiveComparison().isEqualTo(expectedBeaconBlock);
}
Aggregations