Search in sources :

Example 1 with SyncCommitteeMessage

use of tech.pegasys.teku.api.schema.altair.SyncCommitteeMessage in project teku by ConsenSys.

the class PostSyncCommitteesIntegrationTest method phase0SlotCausesBadRequest.

@Test
void phase0SlotCausesBadRequest() throws IOException {
    startRestAPIAtGenesis(SpecMilestone.PHASE0);
    spec = TestSpecFactory.createMinimalPhase0();
    DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);
    final List<SyncCommitteeMessage> requestBody = List.of(new SyncCommitteeMessage(UInt64.ONE, dataStructureUtil.randomBytes32(), dataStructureUtil.randomUInt64(), new BLSSignature(dataStructureUtil.randomSignature())));
    Response response = post(PostSyncCommittees.ROUTE, jsonProvider.objectToJSON(requestBody));
    assertThat(response.code()).isEqualTo(SC_BAD_REQUEST);
    assertThat(response.body().string()).contains("Could not create sync committee signature at phase0 slot 1");
}
Also used : PostDataFailureResponse(tech.pegasys.teku.api.response.v1.beacon.PostDataFailureResponse) Response(okhttp3.Response) SyncCommitteeMessage(tech.pegasys.teku.api.schema.altair.SyncCommitteeMessage) BLSSignature(tech.pegasys.teku.api.schema.BLSSignature) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil) Test(org.junit.jupiter.api.Test) AbstractDataBackedRestAPIIntegrationTest(tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest)

Example 2 with SyncCommitteeMessage

use of tech.pegasys.teku.api.schema.altair.SyncCommitteeMessage in project teku by ConsenSys.

the class PostSyncCommitteesIntegrationTest method shouldGet200OkWhenThereAreNoErrors.

@Test
void shouldGet200OkWhenThereAreNoErrors() throws Exception {
    spec = TestSpecFactory.createMinimalAltair();
    DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);
    startRestAPIAtGenesis(SpecMilestone.ALTAIR);
    final List<SyncCommitteeMessage> requestBody = List.of(new SyncCommitteeMessage(UInt64.ONE, dataStructureUtil.randomBytes32(), dataStructureUtil.randomUInt64(), new BLSSignature(dataStructureUtil.randomSignature())));
    final SafeFuture<List<SubmitDataError>> future = SafeFuture.completedFuture(Collections.emptyList());
    when(validatorApiChannel.sendSyncCommitteeMessages(any())).thenReturn(future);
    Response response = post(PostSyncCommittees.ROUTE, jsonProvider.objectToJSON(requestBody));
    assertThat(response.code()).isEqualTo(SC_OK);
    assertThat(response.body().string()).isEmpty();
}
Also used : PostDataFailureResponse(tech.pegasys.teku.api.response.v1.beacon.PostDataFailureResponse) Response(okhttp3.Response) List(java.util.List) SyncCommitteeMessage(tech.pegasys.teku.api.schema.altair.SyncCommitteeMessage) BLSSignature(tech.pegasys.teku.api.schema.BLSSignature) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil) Test(org.junit.jupiter.api.Test) AbstractDataBackedRestAPIIntegrationTest(tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest)

Example 3 with SyncCommitteeMessage

use of tech.pegasys.teku.api.schema.altair.SyncCommitteeMessage in project teku by ConsenSys.

the class PostSyncCommitteesIntegrationTest method shouldSubmitSyncCommitteesAndGetResponse.

@Test
void shouldSubmitSyncCommitteesAndGetResponse() throws IOException {
    spec = TestSpecFactory.createMinimalAltair();
    DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);
    startRestAPIAtGenesis(SpecMilestone.ALTAIR);
    final List<SyncCommitteeMessage> requestBody = List.of(new SyncCommitteeMessage(UInt64.ONE, dataStructureUtil.randomBytes32(), dataStructureUtil.randomUInt64(), new BLSSignature(dataStructureUtil.randomSignature())));
    final SafeFuture<List<SubmitDataError>> future = SafeFuture.completedFuture(List.of(new SubmitDataError(UInt64.ZERO, errorString)));
    when(validatorApiChannel.sendSyncCommitteeMessages(requestBody.get(0).asInternalCommitteeSignature(spec).stream().collect(Collectors.toList()))).thenReturn(future);
    Response response = post(PostSyncCommittees.ROUTE, jsonProvider.objectToJSON(requestBody));
    assertThat(response.code()).isEqualTo(SC_BAD_REQUEST);
    final PostDataFailureResponse responseBody = jsonProvider.jsonToObject(response.body().string(), PostDataFailureResponse.class);
    assertThat(responseBody.failures.get(0).message).isEqualTo(errorString);
}
Also used : PostDataFailureResponse(tech.pegasys.teku.api.response.v1.beacon.PostDataFailureResponse) Response(okhttp3.Response) PostDataFailureResponse(tech.pegasys.teku.api.response.v1.beacon.PostDataFailureResponse) List(java.util.List) SyncCommitteeMessage(tech.pegasys.teku.api.schema.altair.SyncCommitteeMessage) SubmitDataError(tech.pegasys.teku.validator.api.SubmitDataError) BLSSignature(tech.pegasys.teku.api.schema.BLSSignature) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil) Test(org.junit.jupiter.api.Test) AbstractDataBackedRestAPIIntegrationTest(tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest)

Aggregations

Response (okhttp3.Response)3 Test (org.junit.jupiter.api.Test)3 PostDataFailureResponse (tech.pegasys.teku.api.response.v1.beacon.PostDataFailureResponse)3 BLSSignature (tech.pegasys.teku.api.schema.BLSSignature)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 List (java.util.List)2 SubmitDataError (tech.pegasys.teku.validator.api.SubmitDataError)1