use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class AggregateTopicHandlerTest method handleMessage_ignoredAggregate.
@Test
public void handleMessage_ignoredAggregate() {
final ValidateableAttestation aggregate = ValidateableAttestation.aggregateFromValidator(spec, dataStructureUtil.randomSignedAggregateAndProof());
when(processor.process(aggregate)).thenReturn(SafeFuture.completedFuture(InternalValidationResult.IGNORE));
final SafeFuture<ValidationResult> result = topicHandler.handleMessage(topicHandler.prepareMessage(gossipEncoding.encode(aggregate.getSignedAggregateAndProof())));
asyncRunner.executeQueuedActions();
assertThat(result).isCompletedWithValue(ValidationResult.Ignore);
}
use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class BlockTopicHandlerTest method handleMessage_invalidBlock_invalidSSZ.
@Test
public void handleMessage_invalidBlock_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 BlockTopicHandlerTest method handleMessage_invalidBlock_wrongProposer.
@Test
public void handleMessage_invalidBlock_wrongProposer() throws Exception {
final UInt64 nextSlot = recentChainData.getHeadSlot().plus(UInt64.ONE);
final SignedBeaconBlock block = beaconChainUtil.createBlockAtSlotFromInvalidProposer(nextSlot);
Bytes serialized = gossipEncoding.encode(block);
beaconChainUtil.setSlot(nextSlot);
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_invalidBlock_unknownPreState.
@Test
public void handleMessage_invalidBlock_unknownPreState() {
SignedBeaconBlock block = dataStructureUtil.randomSignedBeaconBlock(1);
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);
}
use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class BlockTopicHandlerTest method handleMessage_validBlock.
@Test
public void handleMessage_validBlock() 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.ACCEPT));
final SafeFuture<ValidationResult> result = topicHandler.handleMessage(topicHandler.prepareMessage(serialized));
asyncRunner.executeQueuedActions();
assertThat(result).isCompletedWithValue(ValidationResult.Valid);
}
Aggregations