use of tech.pegasys.teku.infrastructure.logging.ValidatorLogger in project teku by ConsenSys.
the class AttestationProductionDutyTest method shouldReportFailureWhenAttestationIsInvalid.
@Test
void shouldReportFailureWhenAttestationIsInvalid() {
final int committeeIndex = 3;
final int committeePosition = 6;
final int committeeSize = 22;
final Validator validator = createValidator();
final AttestationData attestationData = expectCreateAttestationData(committeeIndex);
final Attestation expectedAttestation = expectSignAttestation(validator, committeePosition, committeeSize, attestationData);
when(validatorApiChannel.sendSignedAttestations(List.of(expectedAttestation))).thenReturn(SafeFuture.completedFuture(List.of(new SubmitDataError(UInt64.ZERO, "Naughty attestation"))));
final SafeFuture<Optional<AttestationData>> attestationResult = duty.addValidator(validator, committeeIndex, committeePosition, 10, committeeSize);
performAndReportDuty();
assertThat(attestationResult).isCompletedWithValue(Optional.of(attestationData));
verify(validatorApiChannel).sendSignedAttestations(List.of(expectedAttestation));
verify(validatorLogger).dutyFailed(eq(TYPE), eq(SLOT), eq(Set.of(validator.getPublicKey().toAbbreviatedString())), argThat(error -> error instanceof RestApiReportedException && error.getMessage().equals("Naughty attestation")));
verifyNoMoreInteractions(validatorLogger);
}
use of tech.pegasys.teku.infrastructure.logging.ValidatorLogger in project teku by ConsenSys.
the class SyncCommitteeProductionDutyTest method shouldReportPartialFailureWhenBeaconNodeRejectsSomeMessages.
@Test
void shouldReportPartialFailureWhenBeaconNodeRejectsSomeMessages() {
final UInt64 slot = UInt64.valueOf(48);
final int validatorIndex1 = 11;
final int validatorIndex2 = 22;
final Validator validator2 = createValidator();
final BLSSignature signature1 = dataStructureUtil.randomSignature();
final BLSSignature signature2 = dataStructureUtil.randomSignature();
final SyncCommitteeProductionDuty duties = createDuty(committeeAssignment(validator, validatorIndex1, 1, 2, 3), committeeAssignment(validator2, validatorIndex2, 1, 5));
when(validator.getSigner().signSyncCommitteeMessage(slot, blockRoot, forkInfo)).thenReturn(SafeFuture.completedFuture(signature1));
when(validator2.getSigner().signSyncCommitteeMessage(slot, blockRoot, forkInfo)).thenReturn(SafeFuture.completedFuture(signature2));
when(validatorApiChannel.sendSyncCommitteeMessages(any())).thenReturn(SafeFuture.completedFuture(List.of(new SubmitDataError(UInt64.ZERO, "API Rejected"))));
produceMessagesAndReport(duties, slot);
assertSentMessages(createMessage(slot, blockRoot, validatorIndex1, signature1), createMessage(slot, blockRoot, validatorIndex2, signature2));
verify(validatorLogger).dutyCompleted(MESSAGE_TYPE, slot, 1, Set.of(blockRoot));
verify(validatorLogger).dutyFailed(eq(MESSAGE_TYPE), eq(slot), eq(Set.of(validator.getPublicKey().toAbbreviatedString())), argThat(error -> error.getMessage().equals("API Rejected")));
}
use of tech.pegasys.teku.infrastructure.logging.ValidatorLogger in project teku by ConsenSys.
the class SlashingProtectionLoggerTest method beforeEach.
@BeforeEach
public void beforeEach() throws Exception {
when(slashingProtector.getSigningRecord(any())).thenReturn(Optional.empty());
this.asyncRunner = new StubAsyncRunner();
this.validatorLogger = mock(ValidatorLogger.class);
this.slashingProtectionLogger = new SlashingProtectionLogger(slashingProtector, spec, asyncRunner, validatorLogger);
this.slashingProtectionLogger.onSlot(UInt64.ONE);
}
Aggregations