@Test public void getAttesterDuties_shouldReturnDutiesForKnownValidator() { AttesterDuties v1 = new AttesterDuties(BLSPublicKey.random(0), 1, 2, 3, 4, ONE); AttesterDuties v2 = new AttesterDuties(BLSPublicKey.random(1), 11, 12, 13, 14, ZERO); when(validatorApiChannel.getAttestationDuties(eq(ONE), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(List.of(v1, v2)))); final SafeFuture<Optional<List<AttesterDuty>>> future = provider.getAttesterDuties(ONE, List.of(1, 11)); assertThat(future).isCompleted(); final Optional<List<AttesterDuty>> maybeList = future.join(); final List<AttesterDuty> list = maybeList.get(); assertThat(list).containsExactlyInAnyOrder(asAttesterDuty(v1), asAttesterDuty(v2)); }
public SafeFuture<Optional<List<AttesterDuty>>> getAttesterDuties( final UInt64 epoch, final List<Integer> indexes) { if (indexes.isEmpty()) { return SafeFuture.completedFuture(Optional.of(emptyList())); } return SafeFuture.of(() -> validatorApiChannel.getAttestationDuties(epoch, indexes)) .thenApply( res -> res.map( duties -> duties.stream() .filter(duty -> duty.getPublicKey() != null) .map(this::mapToAttesterDuties) .collect(toList()))); }
ValidatorDataProvider { public SafeFuture<Optional<List<AttesterDuty>>> getAttesterDuties( final UInt64 epoch, final List<Integer> indexes) { if (indexes.isEmpty()) { return SafeFuture.completedFuture(Optional.of(emptyList())); } return SafeFuture.of(() -> validatorApiChannel.getAttestationDuties(epoch, indexes)) .thenApply( res -> res.map( duties -> duties.stream() .filter(duty -> duty.getPublicKey() != null) .map(this::mapToAttesterDuties) .collect(toList()))); } }
ValidatorDataProvider { public SafeFuture<Optional<List<AttesterDuty>>> getAttesterDuties( final UInt64 epoch, final List<Integer> indexes) { if (indexes.isEmpty()) { return SafeFuture.completedFuture(Optional.of(emptyList())); } return SafeFuture.of(() -> validatorApiChannel.getAttestationDuties(epoch, indexes)) .thenApply( res -> res.map( duties -> duties.stream() .filter(duty -> duty.getPublicKey() != null) .map(this::mapToAttesterDuties) .collect(toList()))); } ValidatorDataProvider(
      final ValidatorApiChannel validatorApiChannel,
      final BlockImporter blockImporter,
      final CombinedChainDataClient combinedChainDataClient); }
ValidatorDataProvider { public SafeFuture<Optional<List<AttesterDuty>>> getAttesterDuties( final UInt64 epoch, final List<Integer> indexes) { if (indexes.isEmpty()) { return SafeFuture.completedFuture(Optional.of(emptyList())); } return SafeFuture.of(() -> validatorApiChannel.getAttestationDuties(epoch, indexes)) .thenApply( res -> res.map( duties -> duties.stream() .filter(duty -> duty.getPublicKey() != null) .map(this::mapToAttesterDuties) .collect(toList()))); } ValidatorDataProvider(
      final ValidatorApiChannel validatorApiChannel,
      final BlockImporter blockImporter,
      final CombinedChainDataClient combinedChainDataClient); boolean isStoreAvailable(); boolean isEpochFinalized(final UInt64 epoch); SafeFuture<Optional<BeaconBlock>> getUnsignedBeaconBlockAtSlot(
      UInt64 slot, BLSSignature randao, Optional<Bytes32> graffiti); SafeFuture<Optional<Attestation>> createUnsignedAttestationAtSlot(
      UInt64 slot, int committeeIndex); SafeFuture<Optional<List<ValidatorDuties>>> getValidatorDutiesByRequest(
      final ValidatorDutiesRequest validatorDutiesRequest); void submitAttestation(Attestation attestation); SafeFuture<ValidatorBlockResult> submitSignedBlock(
      final SignedBeaconBlock signedBeaconBlock); SafeFuture<Optional<Attestation>> createAggregate(final Bytes32 attestationHashTreeRoot); void sendAggregateAndProof(SignedAggregateAndProof aggregateAndProof); void subscribeToBeaconCommitteeForAggregation(
      final SubscribeToBeaconCommitteeRequest request); void subscribeToPersistentSubnets(final List<SubnetSubscription> subnetSubscriptions); SafeFuture<Optional<List<AttesterDuty>>> getAttesterDuties(
      final UInt64 epoch, final List<Integer> indexes); SafeFuture<Optional<List<ProposerDuty>>> getProposerDuties(final UInt64 epoch); }
ValidatorDataProvider { public SafeFuture<Optional<List<AttesterDuty>>> getAttesterDuties( final UInt64 epoch, final List<Integer> indexes) { if (indexes.isEmpty()) { return SafeFuture.completedFuture(Optional.of(emptyList())); } return SafeFuture.of(() -> validatorApiChannel.getAttestationDuties(epoch, indexes)) .thenApply( res -> res.map( duties -> duties.stream() .filter(duty -> duty.getPublicKey() != null) .map(this::mapToAttesterDuties) .collect(toList()))); } ValidatorDataProvider(
      final ValidatorApiChannel validatorApiChannel,
      final BlockImporter blockImporter,
      final CombinedChainDataClient combinedChainDataClient); boolean isStoreAvailable(); boolean isEpochFinalized(final UInt64 epoch); SafeFuture<Optional<BeaconBlock>> getUnsignedBeaconBlockAtSlot(
      UInt64 slot, BLSSignature randao, Optional<Bytes32> graffiti); SafeFuture<Optional<Attestation>> createUnsignedAttestationAtSlot(
      UInt64 slot, int committeeIndex); SafeFuture<Optional<List<ValidatorDuties>>> getValidatorDutiesByRequest(
      final ValidatorDutiesRequest validatorDutiesRequest); void submitAttestation(Attestation attestation); SafeFuture<ValidatorBlockResult> submitSignedBlock(
      final SignedBeaconBlock signedBeaconBlock); SafeFuture<Optional<Attestation>> createAggregate(final Bytes32 attestationHashTreeRoot); void sendAggregateAndProof(SignedAggregateAndProof aggregateAndProof); void subscribeToBeaconCommitteeForAggregation(
      final SubscribeToBeaconCommitteeRequest request); void subscribeToPersistentSubnets(final List<SubnetSubscription> subnetSubscriptions); SafeFuture<Optional<List<AttesterDuty>>> getAttesterDuties(
      final UInt64 epoch, final List<Integer> indexes); SafeFuture<Optional<List<ProposerDuty>>> getProposerDuties(final UInt64 epoch); static final String CANNOT_PRODUCE_FAR_FUTURE_BLOCK; static final String CANNOT_PRODUCE_HISTORIC_BLOCK; static final String NO_SLOT_PROVIDED; static final String NO_RANDAO_PROVIDED; }