use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class GossipHandlerTest method apply_duplicate.
@Test
@SuppressWarnings("FutureReturnValueIgnored")
public void apply_duplicate() {
final Bytes data = Bytes.fromHexString("0x01");
final MockMessageApi message = new MockMessageApi(data, topic);
gossipHandler.apply(message);
final SafeFuture<ValidationResult> result = gossipHandler.apply(message);
assertThat(result).isCompletedWithValue(ValidationResult.Ignore);
verify(topicHandler).handleMessage(any());
}
use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class GossipHandlerTest method apply_afterDuplicateGossip.
@Test
@SuppressWarnings("FutureReturnValueIgnored")
public void apply_afterDuplicateGossip() {
final Bytes data = Bytes.fromHexString("0x01");
final MockMessageApi message = new MockMessageApi(data, topic);
gossipHandler.gossip(data);
gossipHandler.apply(message);
final SafeFuture<ValidationResult> result = gossipHandler.apply(message);
assertThat(result).isCompletedWithValue(ValidationResult.Ignore);
verify(topicHandler, never()).handleMessage(any());
}
use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class GossipHandlerTest method apply_exceedsMaxSize.
@Test
public void apply_exceedsMaxSize() {
final Bytes data = Bytes.wrap(new byte[GOSSIP_MAX_SIZE + 1]);
final MockMessageApi message = new MockMessageApi(data, topic);
final SafeFuture<ValidationResult> result = gossipHandler.apply(message);
assertThat(result).isCompletedWithValue(ValidationResult.Invalid);
verify(topicHandler, never()).handleMessage(any());
}
use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class GossipHandlerTest method apply_invalid.
@Test
public void apply_invalid() {
final Bytes data = Bytes.fromHexString("0x01");
final MockMessageApi message = new MockMessageApi(data, topic);
when(topicHandler.handleMessage(any())).thenReturn(SafeFuture.completedFuture(ValidationResult.Invalid));
final SafeFuture<ValidationResult> result = gossipHandler.apply(message);
assertThat(result).isCompletedWithValue(ValidationResult.Invalid);
}
use of io.libp2p.core.pubsub.ValidationResult in project teku by ConsenSys.
the class GossipHandlerTest method apply_valid.
@Test
public void apply_valid() {
final Bytes data = Bytes.fromHexString("0x01");
final MockMessageApi message = new MockMessageApi(data, topic);
final SafeFuture<ValidationResult> result = gossipHandler.apply(message);
assertThat(result).isCompletedWithValue(ValidationResult.Valid);
}
Aggregations