Search in sources :

Example 1 with PongPeerMessage

use of co.rsk.net.discovery.message.PongPeerMessage in project rskj by rsksmart.

the class PeerDiscoveryRequestTest method create.

@Test
public void create() {
    ECKey key = new ECKey();
    String check = UUID.randomUUID().toString();
    PingPeerMessage pingPeerMessage = PingPeerMessage.create("localhost", 80, check, key);
    PongPeerMessage pongPeerMessage = PongPeerMessage.create("localhost", 80, check, key);
    InetSocketAddress address = new InetSocketAddress("localhost", 8080);
    PeerDiscoveryRequest request = PeerDiscoveryRequestBuilder.builder().messageId(check).message(pingPeerMessage).address(address).expectedResponse(DiscoveryMessageType.PONG).expirationPeriod(1000).attemptNumber(1).build();
    Assert.assertNotNull(request);
    Assert.assertTrue(request.validateMessageResponse(pongPeerMessage));
    Assert.assertFalse(request.validateMessageResponse(pingPeerMessage));
}
Also used : PongPeerMessage(co.rsk.net.discovery.message.PongPeerMessage) InetSocketAddress(java.net.InetSocketAddress) PingPeerMessage(co.rsk.net.discovery.message.PingPeerMessage) ECKey(org.ethereum.crypto.ECKey) Test(org.junit.Test)

Aggregations

PingPeerMessage (co.rsk.net.discovery.message.PingPeerMessage)1 PongPeerMessage (co.rsk.net.discovery.message.PongPeerMessage)1 InetSocketAddress (java.net.InetSocketAddress)1 ECKey (org.ethereum.crypto.ECKey)1 Test (org.junit.Test)1