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