Search in sources :

Example 6 with HelloMessage

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

the class HelloMessageTest method test3.

// Fail test
@Test
public void test3() {
    // Init
    // invalid version
    byte version = -1;
    // null id
    String clientStr = "";
    List<Capability> capabilities = Arrays.asList(new Capability(null, (byte) 0), new Capability(null, (byte) 0), // null here causes NullPointerException when using toString
    null, // encoding null capabilities
    new Capability(null, (byte) 0));
    // invalid port
    int listenPort = 99999;
    // null id
    String peerId = "";
    HelloMessage helloMessage = new HelloMessage(version, clientStr, capabilities, listenPort, peerId);
    assertEquals(P2pMessageCodes.HELLO, helloMessage.getCommand());
    assertEquals(version, helloMessage.getP2PVersion());
    assertEquals(clientStr, helloMessage.getClientId());
    assertEquals(4, helloMessage.getCapabilities().size());
    assertEquals(listenPort, helloMessage.getListenPort());
    assertEquals(peerId, helloMessage.getPeerId());
}
Also used : Capability(org.ethereum.net.client.Capability) HelloMessage(org.ethereum.net.p2p.HelloMessage) Test(org.junit.Test)

Aggregations

HelloMessage (org.ethereum.net.p2p.HelloMessage)6 Test (org.junit.Test)4 Capability (org.ethereum.net.client.Capability)3 ByteBuf (io.netty.buffer.ByteBuf)2 Message (org.ethereum.net.message.Message)1 DisconnectMessage (org.ethereum.net.p2p.DisconnectMessage)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