use of tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest in project teku by ConsenSys.
the class ValidatorApiHandlerTest method subscribeToBeaconCommittee_shouldUpdateActiveValidatorTrackerWhenNotAggregating.
@Test
public void subscribeToBeaconCommittee_shouldUpdateActiveValidatorTrackerWhenNotAggregating() {
final int committeeIndex = 10;
final UInt64 aggregationSlot = UInt64.valueOf(13);
final UInt64 committeesAtSlot = UInt64.valueOf(10);
final int validatorIndex = 1;
validatorApiHandler.subscribeToBeaconCommittee(List.of(new CommitteeSubscriptionRequest(validatorIndex, committeeIndex, committeesAtSlot, aggregationSlot, false)));
verifyNoInteractions(attestationTopicSubscriptions);
verify(activeValidatorTracker).onCommitteeSubscriptionRequest(validatorIndex, aggregationSlot);
}
use of tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest in project teku by ConsenSys.
the class ValidatorApiHandlerTest method subscribeToBeaconCommittee_shouldSubscribeViaAttestationTopicSubscriptions.
@Test
public void subscribeToBeaconCommittee_shouldSubscribeViaAttestationTopicSubscriptions() {
final int committeeIndex = 10;
final UInt64 aggregationSlot = UInt64.valueOf(13);
final UInt64 committeesAtSlot = UInt64.valueOf(10);
final int validatorIndex = 1;
validatorApiHandler.subscribeToBeaconCommittee(List.of(new CommitteeSubscriptionRequest(validatorIndex, committeeIndex, committeesAtSlot, aggregationSlot, true)));
verify(attestationTopicSubscriptions).subscribeToCommitteeForAggregation(committeeIndex, committeesAtSlot, aggregationSlot);
verify(activeValidatorTracker).onCommitteeSubscriptionRequest(validatorIndex, aggregationSlot);
}
use of tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest in project teku by ConsenSys.
the class RemoteValidatorApiHandlerTest method subscribeToBeaconCommitteeForAggregation_InvokeApi.
@Test
public void subscribeToBeaconCommitteeForAggregation_InvokeApi() {
final int validatorIndex = 3;
final int committeeIndex = 1;
final UInt64 aggregationSlot = UInt64.ONE;
final boolean isAggregator = true;
final UInt64 committeesAtSlot = UInt64.valueOf(23);
final List<CommitteeSubscriptionRequest> requests = List.of(new CommitteeSubscriptionRequest(validatorIndex, committeeIndex, committeesAtSlot, aggregationSlot, isAggregator));
apiHandler.subscribeToBeaconCommittee(requests);
asyncRunner.executeQueuedActions();
verify(apiClient).subscribeToBeaconCommittee(requests);
}
use of tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest in project teku by ConsenSys.
the class OkHttpValidatorRestApiClientTest method subscribeToBeaconCommitteeForAggregation_WhenServerError_ThrowsRuntimeException.
@Test
public void subscribeToBeaconCommitteeForAggregation_WhenServerError_ThrowsRuntimeException() {
final int committeeIndex = 1;
final UInt64 aggregationSlot = UInt64.ONE;
mockWebServer.enqueue(new MockResponse().setResponseCode(SC_INTERNAL_SERVER_ERROR));
assertThatThrownBy(() -> apiClient.subscribeToBeaconCommittee(List.of(new CommitteeSubscriptionRequest(1, committeeIndex, UInt64.valueOf(10), aggregationSlot, true)))).isInstanceOf(RuntimeException.class).hasMessageContaining("Unexpected response from Beacon Node API");
}
use of tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest in project teku by ConsenSys.
the class BeaconCommitteeSubscriptions method sendRequests.
public void sendRequests() {
final List<CommitteeSubscriptionRequest> requestsToSend = new ArrayList<>();
for (CommitteeSubscriptionRequest request = pendingRequests.poll(); request != null; request = pendingRequests.poll()) {
requestsToSend.add(request);
}
if (requestsToSend.isEmpty()) {
return;
}
validatorApiChannel.subscribeToBeaconCommittee(requestsToSend);
}
Aggregations