use of tech.pegasys.teku.api.response.v1.validator.GetProposerDutiesResponse in project teku by ConsenSys.
the class GetProposerDutiesTest method shouldGetProposerDuties.
@Test
public void shouldGetProposerDuties() throws Exception {
when(validatorDataProvider.isStoreAvailable()).thenReturn(true);
when(syncService.getCurrentSyncState()).thenReturn(SyncState.IN_SYNC);
when(context.pathParamMap()).thenReturn(Map.of("epoch", "100"));
GetProposerDutiesResponse duties = new GetProposerDutiesResponse(Bytes32.fromHexString("0x1234"), List.of(getProposerDuty(2, spec.computeStartSlotAtEpoch(UInt64.valueOf(100)))));
when(validatorDataProvider.getProposerDuties(eq(UInt64.valueOf(100)))).thenReturn(SafeFuture.completedFuture(Optional.of(duties)));
handler.handle(context);
GetProposerDutiesResponse response = getResponseFromFuture(GetProposerDutiesResponse.class);
assertThat(response).isEqualTo(duties);
}
use of tech.pegasys.teku.api.response.v1.validator.GetProposerDutiesResponse in project teku by ConsenSys.
the class RemoteValidatorApiHandlerTest method getProposerDuties_WhenFound_ReturnsDuties.
@Test
public void getProposerDuties_WhenFound_ReturnsDuties() {
final BLSPublicKey blsPublicKey = dataStructureUtil.randomPublicKey();
final int validatorIndex = 472;
final tech.pegasys.teku.api.response.v1.validator.ProposerDuty schemaValidatorDuties = new tech.pegasys.teku.api.response.v1.validator.ProposerDuty(new BLSPubKey(blsPublicKey), validatorIndex, UInt64.ZERO);
final ProposerDuty expectedValidatorDuties = new ProposerDuty(blsPublicKey, validatorIndex, UInt64.ZERO);
final GetProposerDutiesResponse response = new GetProposerDutiesResponse(Bytes32.fromHexString("0x1234"), List.of(schemaValidatorDuties));
when(apiClient.getProposerDuties(UInt64.ONE)).thenReturn(Optional.of(response));
SafeFuture<Optional<ProposerDuties>> future = apiHandler.getProposerDuties(UInt64.ONE);
ProposerDuties validatorDuties = unwrapToValue(future);
assertThat(validatorDuties.getDuties().get(0)).isEqualTo(expectedValidatorDuties);
assertThat(validatorDuties.getDependentRoot()).isEqualTo(response.dependentRoot);
}
Aggregations