Search in sources :

Example 1 with InternalValidationResult

use of tech.pegasys.teku.statetransition.validation.InternalValidationResult in project teku by ConsenSys.

the class SignedContributionAndProofValidatorTest method shouldRejectAggregateSignatureIsInvalid.

@Test
void shouldRejectAggregateSignatureIsInvalid() {
    final SignedContributionAndProof message = chainBuilder.createValidSignedContributionAndProofBuilder().addParticipantSignature(dataStructureUtil.randomSignature()).build();
    assertThat(validator.validate(message)).isCompletedWithValueMatching(InternalValidationResult::isReject);
}
Also used : SignedContributionAndProof(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof) InternalValidationResult(tech.pegasys.teku.statetransition.validation.InternalValidationResult) Test(org.junit.jupiter.api.Test)

Example 2 with InternalValidationResult

use of tech.pegasys.teku.statetransition.validation.InternalValidationResult in project teku by ConsenSys.

the class SignedContributionAndProofValidatorTest method shouldIgnoreWhenContributionIsNotFromTheCurrentSlot.

@Test
void shouldIgnoreWhenContributionIsNotFromTheCurrentSlot() {
    final SignedContributionAndProof message = chainBuilder.createValidSignedContributionAndProofBuilder().build();
    final UInt64 slot = message.getMessage().getContribution().getSlot().plus(1);
    // disparity is 500 millis, so 1 second into next slot will be time
    final UInt64 slotSeconds = slot.times(spec.getSecondsPerSlot(slot)).plus(1);
    timeProvider.advanceTimeBy(Duration.ofSeconds(slotSeconds.longValue()));
    storageSystem.chainUpdater().setCurrentSlot(message.getMessage().getContribution().getSlot().plus(1));
    final SafeFuture<InternalValidationResult> result = validator.validate(message);
    assertThat(result).isCompletedWithValue(IGNORE);
}
Also used : SignedContributionAndProof(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof) InternalValidationResult(tech.pegasys.teku.statetransition.validation.InternalValidationResult) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Test(org.junit.jupiter.api.Test)

Example 3 with InternalValidationResult

use of tech.pegasys.teku.statetransition.validation.InternalValidationResult in project teku by ConsenSys.

the class SignedContributionAndProofValidatorTest method shouldRejectWhenAggregatorIsNotInSyncCommittee.

@Test
void shouldRejectWhenAggregatorIsNotInSyncCommittee() {
    final SignedContributionAndProof message = chainBuilder.createValidSignedContributionAndProofBuilder().aggregatorNotInSyncSubcommittee().build();
    assertThat(validator.validate(message)).isCompletedWithValueMatching(InternalValidationResult::isReject);
}
Also used : SignedContributionAndProof(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof) InternalValidationResult(tech.pegasys.teku.statetransition.validation.InternalValidationResult) Test(org.junit.jupiter.api.Test)

Example 4 with InternalValidationResult

use of tech.pegasys.teku.statetransition.validation.InternalValidationResult in project teku by ConsenSys.

the class SignedContributionAndProofValidatorTest method shouldAcceptWhenValidButBeaconBlockRootIsUnknown.

@Test
void shouldAcceptWhenValidButBeaconBlockRootIsUnknown() {
    final SignedContributionAndProof message = chainBuilder.createValidSignedContributionAndProofBuilder(UInt64.ZERO, dataStructureUtil.randomBytes32()).build();
    final SafeFuture<InternalValidationResult> result = validator.validate(message);
    assertThat(result).isCompletedWithValue(ACCEPT);
}
Also used : SignedContributionAndProof(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof) InternalValidationResult(tech.pegasys.teku.statetransition.validation.InternalValidationResult) Test(org.junit.jupiter.api.Test)

Example 5 with InternalValidationResult

use of tech.pegasys.teku.statetransition.validation.InternalValidationResult in project teku by ConsenSys.

the class SignedContributionAndProofValidatorTest method shouldRejectWhenAggregatorIndexIsUnknown.

@Test
void shouldRejectWhenAggregatorIndexIsUnknown() {
    final SignedContributionAndProof message = chainBuilder.createValidSignedContributionAndProofBuilder().aggregatorIndex(UInt64.valueOf(10_000)).build();
    assertThat(validator.validate(message)).isCompletedWithValueMatching(InternalValidationResult::isReject);
}
Also used : SignedContributionAndProof(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof) InternalValidationResult(tech.pegasys.teku.statetransition.validation.InternalValidationResult) Test(org.junit.jupiter.api.Test)

Aggregations

InternalValidationResult (tech.pegasys.teku.statetransition.validation.InternalValidationResult)26 Test (org.junit.jupiter.api.Test)23 SignedContributionAndProof (tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof)13 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)8 SignedBlockAndState (tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState)8 ValidateableAttestation (tech.pegasys.teku.spec.datastructures.attestation.ValidateableAttestation)5 SyncCommitteeMessage (tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage)5 ValidateableSyncCommitteeMessage (tech.pegasys.teku.spec.datastructures.operations.versions.altair.ValidateableSyncCommitteeMessage)5 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)2 OpenApi (io.javalin.plugin.openapi.annotations.OpenApi)2 BLSPublicKey (tech.pegasys.teku.bls.BLSPublicKey)2 Spec (tech.pegasys.teku.spec.Spec)2 BeaconStateAltair (tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.altair.BeaconStateAltair)2 SyncCommitteeUtil (tech.pegasys.teku.spec.logic.common.util.SyncCommitteeUtil)2 FormatMethod (com.google.errorprone.annotations.FormatMethod)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1