use of co.rsk.net.discovery.message.PingPeerMessage in project rskj by rsksmart.
the class UDPChannelTest method write.
@Test
public void write() {
String check = UUID.randomUUID().toString();
ECKey key = new ECKey();
PingPeerMessage nodeMessage = PingPeerMessage.create("localhost", 80, check, key);
Channel channel = Mockito.mock(Channel.class);
PeerExplorer peerExplorer = Mockito.mock(PeerExplorer.class);
UDPChannel udpChannel = new UDPChannel(channel, peerExplorer);
udpChannel.write(new DiscoveryEvent(nodeMessage, new InetSocketAddress("localhost", 8080)));
Mockito.verify(channel, Mockito.times(1)).write(Mockito.any());
Mockito.verify(channel, Mockito.times(1)).flush();
}
use of co.rsk.net.discovery.message.PingPeerMessage in project rskj by rsksmart.
the class NodeChallengeManager method startChallenge.
public NodeChallenge startChallenge(Node challengedNode, Node challenger, PeerExplorer explorer) {
PingPeerMessage pingMessage = explorer.sendPing(challengedNode.getAddress(), 1, challengedNode);
String messageId = pingMessage.getMessageId();
NodeChallenge challenge = new NodeChallenge(challengedNode, challenger, messageId);
activeChallenges.put(messageId, challenge);
return challenge;
}
use of co.rsk.net.discovery.message.PingPeerMessage 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));
}
Aggregations