Search in sources :

Example 1 with CommitteeSubscriptionRequest

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);
}
Also used : CommitteeSubscriptionRequest(tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Checkpoint(tech.pegasys.teku.spec.datastructures.state.Checkpoint) Test(org.junit.jupiter.api.Test)

Example 2 with CommitteeSubscriptionRequest

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);
}
Also used : CommitteeSubscriptionRequest(tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Checkpoint(tech.pegasys.teku.spec.datastructures.state.Checkpoint) Test(org.junit.jupiter.api.Test)

Example 3 with CommitteeSubscriptionRequest

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);
}
Also used : CommitteeSubscriptionRequest(tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Test(org.junit.jupiter.api.Test)

Example 4 with CommitteeSubscriptionRequest

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");
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) BeaconCommitteeSubscriptionRequest(tech.pegasys.teku.api.request.v1.validator.BeaconCommitteeSubscriptionRequest) CommitteeSubscriptionRequest(tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Test(org.junit.jupiter.api.Test)

Example 5 with CommitteeSubscriptionRequest

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);
}
Also used : CommitteeSubscriptionRequest(tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest) ArrayList(java.util.ArrayList)

Aggregations

CommitteeSubscriptionRequest (tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest)10 Test (org.junit.jupiter.api.Test)9 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)8 MockResponse (okhttp3.mockwebserver.MockResponse)3 BeaconCommitteeSubscriptionRequest (tech.pegasys.teku.api.request.v1.validator.BeaconCommitteeSubscriptionRequest)3 Optional (java.util.Optional)2 Checkpoint (tech.pegasys.teku.spec.datastructures.state.Checkpoint)2 AttesterDuties (tech.pegasys.teku.validator.api.AttesterDuties)2 AttesterDuty (tech.pegasys.teku.validator.api.AttesterDuty)2 ArrayList (java.util.ArrayList)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1