Skip to content

Commit

Permalink
squashme: makes safer test
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajpiar committed Apr 1, 2024
1 parent bec94de commit 0c67641
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions rskj-core/src/test/java/co/rsk/net/discovery/PeerExplorerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,15 @@ void handlePongMessage() throws Exception {
assertEquals(1, peerExplorer.getNodes().size());

// Verify that only IP is being sent, not hostname
for (Node discoveredNode : peerExplorer.getNodes()) {
assertNotEquals(HOST_1, discoveredNode.getHost());
}
Optional<Node> discoveredNode = peerExplorer.getNodes().stream().filter((Node aNode) -> {
String nodeIP = aNode.getAddress().getAddress().getHostAddress();
Node localhostNode = new Node(key1.getNodeId(), HOST_1, PORT_1);
String localhostIP = localhostNode.getAddress().getAddress().getHostAddress();

return Objects.equals(nodeIP, localhostIP);
}).findFirst();
assertTrue(discoveredNode.isPresent());
assertNotEquals(HOST_1, discoveredNode.get().getHost());

peerExplorer.dispose();
}
Expand Down Expand Up @@ -432,9 +438,15 @@ void handleFindNodeMessage() throws Exception {
assertEquals(1, neighborsPeerMessage.getNodes().size());

// Verify that only IP is being sent, not hostname
for (Node discoveredNode : neighborsPeerMessage.getNodes()) {
assertNotEquals(HOST_1, discoveredNode.getHost());
}
Optional<Node> discoveredNode = peerExplorer.getNodes().stream().filter((Node aNode) -> {
String nodeIP = aNode.getAddress().getAddress().getHostAddress();
Node localhostNode = new Node(key1.getNodeId(), HOST_1, PORT_1);
String localhostIP = localhostNode.getAddress().getAddress().getHostAddress();

return Objects.equals(nodeIP, localhostIP);
}).findFirst();
assertTrue(discoveredNode.isPresent());
assertNotEquals(HOST_1, discoveredNode.get().getHost());

peerExplorer.dispose();
}
Expand Down

0 comments on commit 0c67641

Please sign in to comment.