Search in sources :

Example 1 with PostSyncDutiesResponse

use of tech.pegasys.teku.api.response.v1.validator.PostSyncDutiesResponse in project teku by ConsenSys.

the class PostSyncDutiesIntegrationTest method shouldGetSyncCommitteeDuties.

@Test
void shouldGetSyncCommitteeDuties() throws IOException {
    startRestAPIAtGenesis(SpecMilestone.ALTAIR);
    final SafeFuture<Optional<SyncCommitteeDuties>> out = SafeFuture.completedFuture(Optional.of(new SyncCommitteeDuties(List.of(new SyncCommitteeDuty(VALIDATOR_KEYS.get(1).getPublicKey(), 1, IntSet.of(11))))));
    when(syncService.getCurrentSyncState()).thenReturn(SyncState.IN_SYNC);
    when(validatorApiChannel.getSyncCommitteeDuties(ONE, validators)).thenReturn(out);
    Response response = post(PostSyncDuties.ROUTE.replace("{epoch}", "1"), jsonProvider.objectToJSON(validators));
    Assertions.assertThat(response.code()).isEqualTo(SC_OK);
    final PostSyncDutiesResponse dutiesResponse = jsonProvider.jsonToObject(response.body().string(), PostSyncDutiesResponse.class);
    assertThat(dutiesResponse.data.get(0)).isEqualTo(new tech.pegasys.teku.api.response.v1.validator.SyncCommitteeDuty(new BLSPubKey(VALIDATOR_KEYS.get(1).getPublicKey()), ONE, IntSet.of(11)));
}
Also used : PostSyncDutiesResponse(tech.pegasys.teku.api.response.v1.validator.PostSyncDutiesResponse) Response(okhttp3.Response) PostSyncDutiesResponse(tech.pegasys.teku.api.response.v1.validator.PostSyncDutiesResponse) Optional(java.util.Optional) SyncCommitteeDuty(tech.pegasys.teku.validator.api.SyncCommitteeDuty) SyncCommitteeDuties(tech.pegasys.teku.validator.api.SyncCommitteeDuties) BLSPubKey(tech.pegasys.teku.api.schema.BLSPubKey) Test(org.junit.jupiter.api.Test) AbstractDataBackedRestAPIIntegrationTest(tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest)

Aggregations

Optional (java.util.Optional)1 Response (okhttp3.Response)1 Test (org.junit.jupiter.api.Test)1 PostSyncDutiesResponse (tech.pegasys.teku.api.response.v1.validator.PostSyncDutiesResponse)1 BLSPubKey (tech.pegasys.teku.api.schema.BLSPubKey)1 AbstractDataBackedRestAPIIntegrationTest (tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest)1 SyncCommitteeDuties (tech.pegasys.teku.validator.api.SyncCommitteeDuties)1 SyncCommitteeDuty (tech.pegasys.teku.validator.api.SyncCommitteeDuty)1