Search in sources :

Example 6 with DisconnectMessage

use of org.ethereum.net.p2p.DisconnectMessage in project rskj by rsksmart.

the class DisconnectMessageTest method test_1.

/* DISCONNECT_MESSAGE */
@Test
public /* DisconnectMessage 1 - Requested */
void test_1() {
    byte[] payload = Hex.decode("C100");
    DisconnectMessage disconnectMessage = new DisconnectMessage(payload);
    logger.trace("{}" + disconnectMessage);
    assertEquals(disconnectMessage.getReason(), ReasonCode.REQUESTED);
}
Also used : DisconnectMessage(org.ethereum.net.p2p.DisconnectMessage) Test(org.junit.Test)

Example 7 with DisconnectMessage

use of org.ethereum.net.p2p.DisconnectMessage in project rskj by rsksmart.

the class DisconnectMessageTest method test_6.

// handling boundary-low minus 1 (error)
@Test
public void test_6() {
    String disconnectMessageRaw = "C19999";
    byte[] payload = Hex.decode(disconnectMessageRaw);
    try {
        DisconnectMessage disconnectMessage = new DisconnectMessage(payload);
        // throws exception
        disconnectMessage.toString();
        assertTrue("Valid raw encoding for disconnectMessage", false);
    } catch (RuntimeException e) {
        assertTrue("Invalid raw encoding for disconnectMessage", true);
    }
}
Also used : DisconnectMessage(org.ethereum.net.p2p.DisconnectMessage) Test(org.junit.Test)

Aggregations

DisconnectMessage (org.ethereum.net.p2p.DisconnectMessage)7 Test (org.junit.Test)6 ByteBuf (io.netty.buffer.ByteBuf)1 Message (org.ethereum.net.message.Message)1 HelloMessage (org.ethereum.net.p2p.HelloMessage)1 P2pMessageFactory (org.ethereum.net.p2p.P2pMessageFactory)1 Frame (org.ethereum.net.rlpx.FrameCodec.Frame)1 InvalidCipherTextException (org.spongycastle.crypto.InvalidCipherTextException)1 ECPoint (org.spongycastle.math.ec.ECPoint)1