Search in sources :

Example 11 with BLSSignature

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()));
}
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 12 with BLSSignature

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);
}
Also used : GetNewBlockResponseV2(tech.pegasys.teku.api.response.v2.validator.GetNewBlockResponseV2) MockResponse(okhttp3.mockwebserver.MockResponse) SignedBeaconBlock(tech.pegasys.teku.api.schema.SignedBeaconBlock) BeaconBlock(tech.pegasys.teku.api.schema.BeaconBlock) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Bytes32(org.apache.tuweni.bytes.Bytes32) BLSSignature(tech.pegasys.teku.api.schema.BLSSignature) Test(org.junit.jupiter.api.Test)

Aggregations

BLSSignature (tech.pegasys.teku.api.schema.BLSSignature)12 Test (org.junit.jupiter.api.Test)10 Bytes32 (org.apache.tuweni.bytes.Bytes32)6 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)6 MockResponse (okhttp3.mockwebserver.MockResponse)5 List (java.util.List)4 Response (okhttp3.Response)3 PostDataFailureResponse (tech.pegasys.teku.api.response.v1.beacon.PostDataFailureResponse)3 BeaconBlock (tech.pegasys.teku.api.schema.BeaconBlock)3 SyncCommitteeMessage (tech.pegasys.teku.api.schema.altair.SyncCommitteeMessage)3 AbstractDataBackedRestAPIIntegrationTest (tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest)3 DataStructureUtil (tech.pegasys.teku.spec.util.DataStructureUtil)3 GetNewBlockResponseV2 (tech.pegasys.teku.api.response.v2.validator.GetNewBlockResponseV2)2 SignedBeaconBlock (tech.pegasys.teku.api.schema.SignedBeaconBlock)2 SingleQueryParameterUtils.getParameterValueAsBLSSignature (tech.pegasys.teku.beaconrestapi.SingleQueryParameterUtils.getParameterValueAsBLSSignature)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Throwables (com.google.common.base.Throwables)1 Context (io.javalin.http.Context)1 Handler (io.javalin.http.Handler)1 HttpMethod (io.javalin.plugin.openapi.annotations.HttpMethod)1