use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class GossipHandlerTest method apply_bufferCapacityExceedsMaxSize.
@Test
public void apply_bufferCapacityExceedsMaxSize() {
ByteBuf data = Unpooled.buffer(GOSSIP_MAX_SIZE + 1).writeBytes(new byte[GOSSIP_MAX_SIZE]);
final MockMessageApi message = new MockMessageApi(data, topic);
final SafeFuture<ValidationResult> result = gossipHandler.apply(message);
assertThat(result).isCompletedWithValue(ValidationResult.Valid);
}
use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class AggregateTopicHandlerTest method handleMessage_savedForFuture.
@Test
public void handleMessage_savedForFuture() {
final ValidateableAttestation aggregate = ValidateableAttestation.aggregateFromValidator(spec, dataStructureUtil.randomSignedAggregateAndProof());
when(processor.process(aggregate)).thenReturn(SafeFuture.completedFuture(InternalValidationResult.SAVE_FOR_FUTURE));
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 AggregateTopicHandlerTest method handleMessage_invalidAggregate.
@Test
public void handleMessage_invalidAggregate() {
final ValidateableAttestation aggregate = ValidateableAttestation.aggregateFromValidator(spec, dataStructureUtil.randomSignedAggregateAndProof());
when(processor.process(aggregate)).thenReturn(SafeFuture.completedFuture(InternalValidationResult.reject("Nope")));
final SafeFuture<ValidationResult> result = topicHandler.handleMessage(topicHandler.prepareMessage(gossipEncoding.encode(aggregate.getSignedAggregateAndProof())));
asyncRunner.executeQueuedActions();
assertThat(result).isCompletedWithValue(ValidationResult.Invalid);
}
use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class AttesterSlashingTopicHandlerTest method handleMessage_rejectedSlashing.
@Test
public void handleMessage_rejectedSlashing() {
final AttesterSlashing slashing = dataStructureUtil.randomAttesterSlashing();
when(processor.process(slashing)).thenReturn(SafeFuture.completedFuture(InternalValidationResult.reject("Nope")));
Bytes serialized = gossipEncoding.encode(slashing);
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 AttesterSlashingTopicHandlerTest method handleMessage_ignoredSlashing.
@Test
public void handleMessage_ignoredSlashing() {
final AttesterSlashing slashing = dataStructureUtil.randomAttesterSlashing();
when(processor.process(slashing)).thenReturn(SafeFuture.completedFuture(InternalValidationResult.IGNORE));
Bytes serialized = gossipEncoding.encode(slashing);
final SafeFuture<ValidationResult> result = topicHandler.handleMessage(topicHandler.prepareMessage(serialized));
asyncRunner.executeQueuedActions();
assertThat(result).isCompletedWithValue(ValidationResult.Ignore);
}
Aggregations