use of tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage in project teku by ConsenSys.
the class ValidatorApiHandlerTest method sendSyncCommitteeMessages_shouldRaiseErrors.
@Test
void sendSyncCommitteeMessages_shouldRaiseErrors() {
final SyncCommitteeMessage message = dataStructureUtil.randomSyncCommitteeMessage();
final List<SyncCommitteeMessage> messages = List.of(message);
when(syncCommitteeMessagePool.add(any())).thenReturn(SafeFuture.completedFuture(InternalValidationResult.create(ValidationResultCode.REJECT, "Rejected")));
final SafeFuture<List<SubmitDataError>> result = validatorApiHandler.sendSyncCommitteeMessages(messages);
assertThat(result).isCompletedWithValue(List.of(new SubmitDataError(UInt64.ZERO, "Rejected")));
verify(performanceTracker, never()).saveProducedSyncCommitteeMessage(message);
}
use of tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage in project teku by ConsenSys.
the class SyncCommitteeMessageValidatorTest method shouldRejectWhenValidatorIsUnknown.
@Test
void shouldRejectWhenValidatorIsUnknown() {
final SyncCommitteeMessage template = chainBuilder.createValidSyncCommitteeMessage();
final SyncCommitteeMessage message = template.getSchema().create(template.getSlot(), template.getBeaconBlockRoot(), // There's only 16 validators
UInt64.valueOf(25), template.getSignature());
assertThat(validator.validate(ValidateableSyncCommitteeMessage.fromValidator(message))).isCompletedWithValueMatching(InternalValidationResult::isReject);
}
use of tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage in project teku by ConsenSys.
the class SyncCommitteeMessageValidatorTest method shouldAllowDuplicateMessagesForDistinctSubnets.
@Test
void shouldAllowDuplicateMessagesForDistinctSubnets() {
final SyncCommitteeMessage message = chainBuilder.createValidSyncCommitteeMessage();
assertThat(validator.validate(fromNetworkSpy(message, 1, IntSet.of(1, 2)))).isCompletedWithValue(ACCEPT);
assertThat(validator.validate(fromNetworkSpy(message, 2, IntSet.of(1, 2)))).isCompletedWithValue(ACCEPT);
}
use of tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage in project teku by ConsenSys.
the class SyncCommitteeMessageValidatorTest method shouldAcceptWhenValidButBeaconBlockIsUnknown.
@Test
void shouldAcceptWhenValidButBeaconBlockIsUnknown() {
final SyncCommitteeMessage message = chainBuilder.createSyncCommitteeMessage(chainBuilder.getLatestSlot(), dataStructureUtil.randomBytes32());
assertThat(validator.validate(ValidateableSyncCommitteeMessage.fromValidator(message))).isCompletedWithValue(ACCEPT);
}
use of tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage in project teku by ConsenSys.
the class SyncCommitteeMessageValidatorTest method shouldRejectWhenReceivedOnIncorrectSubnet.
@Test
void shouldRejectWhenReceivedOnIncorrectSubnet() {
final SyncCommitteeMessage message = chainBuilder.createValidSyncCommitteeMessage();
// 9 is never a valid subnet
assertThat(validator.validate(ValidateableSyncCommitteeMessage.fromNetwork(message, 9))).isCompletedWithValueMatching(InternalValidationResult::isReject);
}
Aggregations