use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class AttesterSlashingTopicHandlerTest method handleMessage_invalidSSZ.
@Test
public void handleMessage_invalidSSZ() {
Bytes serialized = Bytes.fromHexString("0x1234");
final SafeFuture<ValidationResult> result = topicHandler.handleMessage(topicHandler.prepareMessage(serialized));
asyncRunner.executeQueuedActions();
assertThat(result).isCompletedWithValue(ValidationResult.Invalid);
}
use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class SingleAttestationTopicHandlerTest method handleMessage_valid.
@Test
public void handleMessage_valid() {
final AttestationGenerator attestationGenerator = new AttestationGenerator(spec, validatorKeys);
final StateAndBlockSummary blockAndState = getChainHead();
final ValidateableAttestation attestation = ValidateableAttestation.fromNetwork(spec, attestationGenerator.validAttestation(blockAndState), SUBNET_ID);
when(processor.process(attestation)).thenReturn(SafeFuture.completedFuture(InternalValidationResult.ACCEPT));
final Bytes serialized = gossipEncoding.encode(attestation.getAttestation());
final SafeFuture<ValidationResult> result = topicHandler.handleMessage(topicHandler.prepareMessage(serialized));
asyncRunner.executeQueuedActions();
assertThat(result).isCompletedWithValue(ValidationResult.Valid);
}
use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class SingleAttestationTopicHandlerTest method handleMessage_saveForFuture.
@Test
public void handleMessage_saveForFuture() {
final AttestationGenerator attestationGenerator = new AttestationGenerator(spec, validatorKeys);
final StateAndBlockSummary blockAndState = getChainHead();
final ValidateableAttestation attestation = ValidateableAttestation.fromNetwork(spec, attestationGenerator.validAttestation(blockAndState), SUBNET_ID);
when(processor.process(attestation)).thenReturn(SafeFuture.completedFuture(InternalValidationResult.SAVE_FOR_FUTURE));
final Bytes serialized = gossipEncoding.encode(attestation.getAttestation());
final SafeFuture<ValidationResult> result = topicHandler.handleMessage(topicHandler.prepareMessage(serialized));
asyncRunner.executeQueuedActions();
assertThat(result).isCompletedWithValue(ValidationResult.Ignore);
}
use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class SingleAttestationTopicHandlerTest method handleMessage_invalidAttestation_invalidSSZ.
@Test
public void handleMessage_invalidAttestation_invalidSSZ() {
final Bytes serialized = Bytes.fromHexString("0x3456");
final SafeFuture<ValidationResult> result = topicHandler.handleMessage(topicHandler.prepareMessage(serialized));
asyncRunner.executeQueuedActions();
assertThat(result).isCompletedWithValue(ValidationResult.Invalid);
}
use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class BlockTopicHandlerTest method handleMessage_validFutureBlock.
@Test
public void handleMessage_validFutureBlock() throws Exception {
final UInt64 nextSlot = recentChainData.getHeadSlot().plus(UInt64.ONE);
final SignedBeaconBlock block = beaconChainUtil.createBlockAtSlot(nextSlot);
Bytes serialized = gossipEncoding.encode(block);
when(processor.process(block)).thenReturn(SafeFuture.completedFuture(InternalValidationResult.SAVE_FOR_FUTURE));
final SafeFuture<ValidationResult> result = topicHandler.handleMessage(topicHandler.prepareMessage(serialized));
asyncRunner.executeQueuedActions();
assertThat(result).isCompletedWithValue(ValidationResult.Ignore);
}
Aggregations