Search in sources :

Example 1 with DecodingException

use of tech.pegasys.teku.networking.eth2.gossip.encoding.DecodingException in project teku by ConsenSys.

the class Eth2TopicHandlerTest method handleMessage_errorWhileProcessing_wrappedDecodingException.

@Test
public void handleMessage_errorWhileProcessing_wrappedDecodingException() {
    MockEth2TopicHandler topicHandler = new MockEth2TopicHandler(recentChainData, spec, asyncRunner, (b) -> SafeFuture.completedFuture(InternalValidationResult.ACCEPT));
    topicHandler.setDeserializer((b) -> {
        throw new CompletionException(new DecodingException("oops"));
    });
    final SafeFuture<ValidationResult> result = topicHandler.handleMessage(topicHandler.prepareMessage(blockBytes));
    asyncRunner.executeQueuedActions();
    assertThatSafeFuture(result).isCompletedWithValue(ValidationResult.Invalid);
}
Also used : CompletionException(java.util.concurrent.CompletionException) DecodingException(tech.pegasys.teku.networking.eth2.gossip.encoding.DecodingException) ValidationResult(io.libp2p.core.pubsub.ValidationResult) InternalValidationResult(tech.pegasys.teku.statetransition.validation.InternalValidationResult) Test(org.junit.jupiter.api.Test)

Aggregations

ValidationResult (io.libp2p.core.pubsub.ValidationResult)1 CompletionException (java.util.concurrent.CompletionException)1 Test (org.junit.jupiter.api.Test)1 DecodingException (tech.pegasys.teku.networking.eth2.gossip.encoding.DecodingException)1 InternalValidationResult (tech.pegasys.teku.statetransition.validation.InternalValidationResult)1