Search in sources :

Example 11 with AttesterDuty

use of tech.pegasys.teku.validator.api.AttesterDuty in project teku by ConsenSys.

the class AttestationDutyLoaderTest method shouldSubscribeToSubnetWhenValidatorIsAggregator.

@Test
void shouldSubscribeToSubnetWhenValidatorIsAggregator() {
    final UInt64 slot = UInt64.ONE;
    final Integer validatorIndex = VALIDATOR_INDICES.get(0);
    final int committeeLength = 1;
    final int committeeIndex = 3;
    final int committeesAtSlot = 4;
    final AttesterDuty duty = new AttesterDuty(validatorKey, validatorIndex, committeeLength, committeeIndex, committeesAtSlot, 0, slot);
    when(validatorApiChannel.getAttestationDuties(UInt64.ONE, VALIDATOR_INDICES)).thenReturn(SafeFuture.completedFuture(Optional.of(new AttesterDuties(dataStructureUtil.randomBytes32(), List.of(duty)))));
    when(scheduledDuties.scheduleProduction(any(), any(), any())).thenReturn(new SafeFuture<>());
    when(signer.signAggregationSlot(slot, forkInfo)).thenReturn(SafeFuture.completedFuture(dataStructureUtil.randomSignature()));
    final SafeFuture<Optional<SlotBasedScheduledDuties<?, ?>>> result = dutyLoader.loadDutiesForEpoch(UInt64.ONE);
    assertThat(result).isCompleted();
    verify(beaconCommitteeSubscriptions).subscribeToBeaconCommittee(new CommitteeSubscriptionRequest(validatorIndex, committeeIndex, UInt64.valueOf(committeesAtSlot), slot, true));
    verify(beaconCommitteeSubscriptions).sendRequests();
}
Also used : AttesterDuties(tech.pegasys.teku.validator.api.AttesterDuties) Optional(java.util.Optional) AttesterDuty(tech.pegasys.teku.validator.api.AttesterDuty) CommitteeSubscriptionRequest(tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Test(org.junit.jupiter.api.Test)

Aggregations

AttesterDuties (tech.pegasys.teku.validator.api.AttesterDuties)11 AttesterDuty (tech.pegasys.teku.validator.api.AttesterDuty)11 Test (org.junit.jupiter.api.Test)10 Optional (java.util.Optional)7 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)7 AttestationProductionDuty (tech.pegasys.teku.validator.client.duties.attestations.AttestationProductionDuty)5 BLSPublicKey (tech.pegasys.teku.bls.BLSPublicKey)3 PostAttesterDutiesResponse (tech.pegasys.teku.api.response.v1.validator.PostAttesterDutiesResponse)2 BeaconState (tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)2 CommitteeSubscriptionRequest (tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest)2 TestTemplate (org.junit.jupiter.api.TestTemplate)1 BLSPubKey (tech.pegasys.teku.api.schema.BLSPubKey)1 BLSSignature (tech.pegasys.teku.bls.BLSSignature)1 SafeFuture (tech.pegasys.teku.infrastructure.async.SafeFuture)1 AggregationDuty (tech.pegasys.teku.validator.client.duties.attestations.AggregationDuty)1