Search in sources :

Example 1 with SchemaObjectProvider

use of tech.pegasys.teku.api.SchemaObjectProvider in project teku by ConsenSys.

the class GetNewBlockV2Test method shouldReturnBlockWithoutGraffiti.

@Test
void shouldReturnBlockWithoutGraffiti() throws Exception {
    final Map<String, String> pathParams = Map.of(SLOT, "1");
    final SchemaObjectProvider schemaProvider = new SchemaObjectProvider(spec);
    final Map<String, List<String>> queryParams = Map.of(RANDAO_REVEAL, List.of(signature.toHexString()));
    final tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock randomBeaconBlock = dataStructureUtil.randomBeaconBlock(ONE);
    final BeaconBlock altairBlock = schemaProvider.getBeaconBlock(randomBeaconBlock);
    when(context.queryParamMap()).thenReturn(queryParams);
    when(context.pathParamMap()).thenReturn(pathParams);
    when(provider.getMilestoneAtSlot(UInt64.ONE)).thenReturn(SpecMilestone.ALTAIR);
    when(provider.getUnsignedBeaconBlockAtSlot(ONE, signature, Optional.empty())).thenReturn(SafeFuture.completedFuture(Optional.of(altairBlock)));
    handler.handle(context);
    verify(context).future(args.capture());
    SafeFuture<String> result = args.getValue();
    assertThat(result).isCompletedWithValue(jsonProvider.objectToJSON(new GetNewBlockResponseV2(SpecMilestone.ALTAIR, altairBlock)));
}
Also used : GetNewBlockResponseV2(tech.pegasys.teku.api.response.v2.validator.GetNewBlockResponseV2) BeaconBlock(tech.pegasys.teku.api.schema.BeaconBlock) List(java.util.List) SchemaObjectProvider(tech.pegasys.teku.api.SchemaObjectProvider) Test(org.junit.jupiter.api.Test)

Example 2 with SchemaObjectProvider

use of tech.pegasys.teku.api.SchemaObjectProvider in project teku by ConsenSys.

the class SchemaObjectsTestFixture method beaconBlockAltair.

public BeaconBlock beaconBlockAltair() {
    final Spec altairSpec = TestSpecFactory.createMainnetAltair();
    final DataStructureUtil altairData = new DataStructureUtil(altairSpec);
    final SchemaObjectProvider schemaObjectProvider = new SchemaObjectProvider(altairSpec);
    return schemaObjectProvider.getBeaconBlock(altairData.randomBeaconBlock(UInt64.ONE));
}
Also used : Spec(tech.pegasys.teku.spec.Spec) SchemaObjectProvider(tech.pegasys.teku.api.SchemaObjectProvider) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil)

Aggregations

SchemaObjectProvider (tech.pegasys.teku.api.SchemaObjectProvider)2 List (java.util.List)1 Test (org.junit.jupiter.api.Test)1 GetNewBlockResponseV2 (tech.pegasys.teku.api.response.v2.validator.GetNewBlockResponseV2)1 BeaconBlock (tech.pegasys.teku.api.schema.BeaconBlock)1 Spec (tech.pegasys.teku.spec.Spec)1 DataStructureUtil (tech.pegasys.teku.spec.util.DataStructureUtil)1