Search in sources :

Example 1 with SyncCommitteeMessage

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);
}
Also used : Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) IntList(it.unimi.dsi.fastutil.ints.IntList) SszMutableList(tech.pegasys.teku.infrastructure.ssz.SszMutableList) SyncCommitteeMessage(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage) SubmitDataError(tech.pegasys.teku.validator.api.SubmitDataError) Test(org.junit.jupiter.api.Test)

Example 2 with SyncCommitteeMessage

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);
}
Also used : InternalValidationResult(tech.pegasys.teku.statetransition.validation.InternalValidationResult) ValidateableSyncCommitteeMessage(tech.pegasys.teku.spec.datastructures.operations.versions.altair.ValidateableSyncCommitteeMessage) SyncCommitteeMessage(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage) Test(org.junit.jupiter.api.Test)

Example 3 with SyncCommitteeMessage

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);
}
Also used : ValidateableSyncCommitteeMessage(tech.pegasys.teku.spec.datastructures.operations.versions.altair.ValidateableSyncCommitteeMessage) SyncCommitteeMessage(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage) Test(org.junit.jupiter.api.Test)

Example 4 with SyncCommitteeMessage

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);
}
Also used : ValidateableSyncCommitteeMessage(tech.pegasys.teku.spec.datastructures.operations.versions.altair.ValidateableSyncCommitteeMessage) SyncCommitteeMessage(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage) Test(org.junit.jupiter.api.Test)

Example 5 with SyncCommitteeMessage

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);
}
Also used : InternalValidationResult(tech.pegasys.teku.statetransition.validation.InternalValidationResult) ValidateableSyncCommitteeMessage(tech.pegasys.teku.spec.datastructures.operations.versions.altair.ValidateableSyncCommitteeMessage) SyncCommitteeMessage(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage) Test(org.junit.jupiter.api.Test)

Aggregations

SyncCommitteeMessage (tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage)18 Test (org.junit.jupiter.api.Test)16 ValidateableSyncCommitteeMessage (tech.pegasys.teku.spec.datastructures.operations.versions.altair.ValidateableSyncCommitteeMessage)15 InternalValidationResult (tech.pegasys.teku.statetransition.validation.InternalValidationResult)5 Collections.emptyList (java.util.Collections.emptyList)3 List (java.util.List)3 SignedBlockAndState (tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState)3 IntList (it.unimi.dsi.fastutil.ints.IntList)2 SszMutableList (tech.pegasys.teku.infrastructure.ssz.SszMutableList)2 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)2 BeaconStateAltair (tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.altair.BeaconStateAltair)2 SyncSubcommitteeAssignments (tech.pegasys.teku.spec.datastructures.util.SyncSubcommitteeAssignments)2 SyncCommitteeUtil (tech.pegasys.teku.spec.logic.common.util.SyncCommitteeUtil)2 SubmitDataError (tech.pegasys.teku.validator.api.SubmitDataError)2 Collections.emptySet (java.util.Collections.emptySet)1 Optional (java.util.Optional)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Stream (java.util.stream.Stream)1 Bytes32 (org.apache.tuweni.bytes.Bytes32)1