Search in sources :

Example 1 with GetProposerDutiesResponse

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);
}
Also used : GetProposerDutiesResponse(tech.pegasys.teku.api.response.v1.validator.GetProposerDutiesResponse) Test(org.junit.jupiter.api.Test)

Example 2 with GetProposerDutiesResponse

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);
}
Also used : Optional(java.util.Optional) ProposerDuties(tech.pegasys.teku.validator.api.ProposerDuties) BLSPubKey(tech.pegasys.teku.api.schema.BLSPubKey) GetProposerDutiesResponse(tech.pegasys.teku.api.response.v1.validator.GetProposerDutiesResponse) ProposerDuty(tech.pegasys.teku.validator.api.ProposerDuty) BLSPublicKey(tech.pegasys.teku.bls.BLSPublicKey) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 GetProposerDutiesResponse (tech.pegasys.teku.api.response.v1.validator.GetProposerDutiesResponse)2 Optional (java.util.Optional)1 BLSPubKey (tech.pegasys.teku.api.schema.BLSPubKey)1 BLSPublicKey (tech.pegasys.teku.bls.BLSPublicKey)1 ProposerDuties (tech.pegasys.teku.validator.api.ProposerDuties)1 ProposerDuty (tech.pegasys.teku.validator.api.ProposerDuty)1