From 16fb4b746c0826040f12ee9fa2e3a834b095326e Mon Sep 17 00:00:00 2001 From: vaidikcode Date: Wed, 27 Nov 2024 01:33:28 +0530 Subject: [PATCH 01/12] fix Signed-off-by: vaidikcode --- .../besu/ethereum/p2p/discovery/Endpoint.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java index 41cec4ac5f3..1490238a8cb 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java @@ -29,12 +29,15 @@ import com.google.common.net.InetAddresses; import org.apache.tuweni.bytes.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Encapsulates the network coordinates of a {@link DiscoveryPeer} as well as serialization logic * used in various Discovery messages. */ public class Endpoint { + private static final Logger log = LoggerFactory.getLogger(Endpoint.class); private final Optional host; private final int udpPort; private final Optional tcpPort; @@ -49,15 +52,15 @@ public Endpoint(final String host, final int udpPort, final Optional tc } public static Endpoint fromEnode(final EnodeURL enode) { - final int discoveryPort = - enode - .getDiscoveryPort() - .orElseThrow( - () -> - new IllegalArgumentException( - "Attempt to create a discovery endpoint for an enode with discovery disabled.")); + Optional discoveryPort = enode.getDiscoveryPort(); + + if (discoveryPort.isEmpty()) { + log.warn("Attempted to create a discovery endpoint for a node with discovery disabled: {}", enode); + return new Endpoint("defaultHost", 0, Optional.empty()); + } + final Optional listeningPort = enode.getListeningPort(); - return new Endpoint(enode.getIp().getHostAddress(), discoveryPort, listeningPort); + return new Endpoint(enode.getIp().getHostAddress(), discoveryPort.get(), listeningPort); } public EnodeURL toEnode(final Bytes nodeId) { From 864831a0378fb35121c48cb1a6404d1b0309831c Mon Sep 17 00:00:00 2001 From: vaidikcode Date: Wed, 27 Nov 2024 17:11:10 +0530 Subject: [PATCH 02/12] fix Signed-off-by: vaidikcode --- .../besu/ethereum/p2p/discovery/Endpoint.java | 5 +++-- .../p2p/discovery/PeerDiscoveryAgentTest.java | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java index 1490238a8cb..8f097363242 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java @@ -55,8 +55,9 @@ public static Endpoint fromEnode(final EnodeURL enode) { Optional discoveryPort = enode.getDiscoveryPort(); if (discoveryPort.isEmpty()) { - log.warn("Attempted to create a discovery endpoint for a node with discovery disabled: {}", enode); - return new Endpoint("defaultHost", 0, Optional.empty()); + int defaultPort = 30303; + log.debug("Discovery disabled for enode {}. Using default port {}.", enode, defaultPort); + return new Endpoint(enode.getIp().getHostAddress(), defaultPort, Optional.empty()); } final Optional listeningPort = enode.getListeningPort(); diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java index 57eb6f518b9..3cef43ab74f 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java @@ -18,6 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -45,6 +46,8 @@ import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsDenylist; import org.hyperledger.besu.plugin.data.EnodeURL; +import java.net.InetAddress; +import java.net.UnknownHostException; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -898,6 +901,23 @@ public void assertHostCorrectlyRevertsOnIgnoredPacketFrom() { assertThat(PeerDiscoveryAgent.deriveHost(source, mockWellFormed)).isEqualTo(routableHost); } + @Test + void testFromEnodeWithDiscoveryDisabled() throws UnknownHostException { + EnodeURL enodeWithNoDiscovery = mock(EnodeURL.class); + when(enodeWithNoDiscovery.getDiscoveryPort()).thenReturn(Optional.empty()); + when(enodeWithNoDiscovery.getListeningPort()).thenReturn(Optional.of(8545)); + when(enodeWithNoDiscovery.getIp()).thenReturn(InetAddress.getByName("127.0.0.1")); + + Endpoint result = Endpoint.fromEnode(enodeWithNoDiscovery); + + assertEquals("127.0.0.1", result.getHost()); + + assertEquals(30303, result.getUdpPort()); + + assertEquals(Optional.empty(), result.getTcpPort()); + } + + protected void bondViaIncomingPing( final MockPeerDiscoveryAgent agent, final MockPeerDiscoveryAgent otherNode) { final Packet pingPacket = helper.createPingPacket(otherNode, agent); From c45da9bbfcea9fe1711f82d4b60b73920df683f0 Mon Sep 17 00:00:00 2001 From: vaidikcode Date: Thu, 28 Nov 2024 10:31:47 +0530 Subject: [PATCH 03/12] fix Signed-off-by: vaidikcode --- .../org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java index 8f097363242..e0531537634 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java @@ -55,7 +55,7 @@ public static Endpoint fromEnode(final EnodeURL enode) { Optional discoveryPort = enode.getDiscoveryPort(); if (discoveryPort.isEmpty()) { - int defaultPort = 30303; + int defaultPort = EnodeURLImpl.DEFAULT_LISTENING_PORT; log.debug("Discovery disabled for enode {}. Using default port {}.", enode, defaultPort); return new Endpoint(enode.getIp().getHostAddress(), defaultPort, Optional.empty()); } From 3e1bbaa5ba19e2e7c4206e9ee87d5465ecaee8a9 Mon Sep 17 00:00:00 2001 From: vaidikcode Date: Thu, 28 Nov 2024 14:26:32 +0530 Subject: [PATCH 04/12] fix Signed-off-by: vaidikcode --- .../p2p/discovery/PeerDiscoveryAgentTest.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java index 3cef43ab74f..26eb7682278 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java @@ -19,6 +19,7 @@ import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -902,19 +903,24 @@ public void assertHostCorrectlyRevertsOnIgnoredPacketFrom() { } @Test - void testFromEnodeWithDiscoveryDisabled() throws UnknownHostException { - EnodeURL enodeWithNoDiscovery = mock(EnodeURL.class); - when(enodeWithNoDiscovery.getDiscoveryPort()).thenReturn(Optional.empty()); - when(enodeWithNoDiscovery.getListeningPort()).thenReturn(Optional.of(8545)); - when(enodeWithNoDiscovery.getIp()).thenReturn(InetAddress.getByName("127.0.0.1")); + void testFromEnodeWithDiscoveryDisabled() { + try { + EnodeURL enodeWithNoDiscovery = mock(EnodeURL.class); + when(enodeWithNoDiscovery.getDiscoveryPort()).thenReturn(Optional.empty()); + when(enodeWithNoDiscovery.getListeningPort()).thenReturn(Optional.of(8545)); + when(enodeWithNoDiscovery.getIp()).thenReturn(InetAddress.getByName("127.0.0.1")); - Endpoint result = Endpoint.fromEnode(enodeWithNoDiscovery); + Endpoint result = Endpoint.fromEnode(enodeWithNoDiscovery); - assertEquals("127.0.0.1", result.getHost()); + assertEquals("127.0.0.1", result.getHost()); - assertEquals(30303, result.getUdpPort()); + assertEquals(30303, result.getUdpPort()); - assertEquals(Optional.empty(), result.getTcpPort()); + assertEquals(Optional.empty(), result.getTcpPort()); + } + catch (UnknownHostException e) { + fail("Failed to resolve the Host Address "); + } } From ce0cd8f5d5674258cb70a2dc4d11040e5c644603 Mon Sep 17 00:00:00 2001 From: vaidikcode Date: Thu, 28 Nov 2024 23:53:45 +0530 Subject: [PATCH 05/12] fix Signed-off-by: vaidikcode --- .../p2p/discovery/PeerDiscoveryAgentTest.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java index 26eb7682278..0eb73f2ae74 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java @@ -61,12 +61,15 @@ import org.apache.tuweni.units.bigints.UInt64; import org.ethereum.beacon.discovery.schema.NodeRecord; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PeerDiscoveryAgentTest { private static final int BROADCAST_TCP_PORT = 30303; private static final Supplier SIGNATURE_ALGORITHM = Suppliers.memoize(SignatureAlgorithmFactory::getInstance); + private static final Logger log = LoggerFactory.getLogger(PeerDiscoveryAgentTest.class); private final PeerDiscoveryTestHelper helper = new PeerDiscoveryTestHelper(); @Test @@ -904,12 +907,15 @@ public void assertHostCorrectlyRevertsOnIgnoredPacketFrom() { @Test void testFromEnodeWithDiscoveryDisabled() { - try { EnodeURL enodeWithNoDiscovery = mock(EnodeURL.class); when(enodeWithNoDiscovery.getDiscoveryPort()).thenReturn(Optional.empty()); when(enodeWithNoDiscovery.getListeningPort()).thenReturn(Optional.of(8545)); - when(enodeWithNoDiscovery.getIp()).thenReturn(InetAddress.getByName("127.0.0.1")); - + try { + when(enodeWithNoDiscovery.getIp()).thenReturn(InetAddress.getByName("127.0.0.1")); + } + catch (UnknownHostException e) { + log.debug("failed to resolve the Host Address "); + } Endpoint result = Endpoint.fromEnode(enodeWithNoDiscovery); assertEquals("127.0.0.1", result.getHost()); @@ -917,10 +923,6 @@ void testFromEnodeWithDiscoveryDisabled() { assertEquals(30303, result.getUdpPort()); assertEquals(Optional.empty(), result.getTcpPort()); - } - catch (UnknownHostException e) { - fail("Failed to resolve the Host Address "); - } } From e9b91d441a6523149dbe6564ac9dfee6d0d64765 Mon Sep 17 00:00:00 2001 From: vaidikcode Date: Thu, 28 Nov 2024 23:55:30 +0530 Subject: [PATCH 06/12] fix Signed-off-by: vaidikcode --- .../besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java index 0eb73f2ae74..bd23a924849 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java @@ -914,7 +914,7 @@ void testFromEnodeWithDiscoveryDisabled() { when(enodeWithNoDiscovery.getIp()).thenReturn(InetAddress.getByName("127.0.0.1")); } catch (UnknownHostException e) { - log.debug("failed to resolve the Host Address "); + log.debug("Failed to resolve the Host Address "); } Endpoint result = Endpoint.fromEnode(enodeWithNoDiscovery); From d7b52315dd71eebc341c4bef0e04c2b383676b85 Mon Sep 17 00:00:00 2001 From: vaidikcode Date: Fri, 29 Nov 2024 04:11:55 +0530 Subject: [PATCH 07/12] fix Signed-off-by: vaidikcode --- .../p2p/discovery/PeerDiscoveryAgentTest.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java index bd23a924849..27b7df98abc 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java @@ -19,7 +19,6 @@ import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -61,15 +60,12 @@ import org.apache.tuweni.units.bigints.UInt64; import org.ethereum.beacon.discovery.schema.NodeRecord; import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class PeerDiscoveryAgentTest { private static final int BROADCAST_TCP_PORT = 30303; private static final Supplier SIGNATURE_ALGORITHM = Suppliers.memoize(SignatureAlgorithmFactory::getInstance); - private static final Logger log = LoggerFactory.getLogger(PeerDiscoveryAgentTest.class); private final PeerDiscoveryTestHelper helper = new PeerDiscoveryTestHelper(); @Test @@ -906,16 +902,13 @@ public void assertHostCorrectlyRevertsOnIgnoredPacketFrom() { } @Test - void testFromEnodeWithDiscoveryDisabled() { + void testFromEnodeWithDiscoveryDisabled() throws UnknownHostException { EnodeURL enodeWithNoDiscovery = mock(EnodeURL.class); when(enodeWithNoDiscovery.getDiscoveryPort()).thenReturn(Optional.empty()); when(enodeWithNoDiscovery.getListeningPort()).thenReturn(Optional.of(8545)); - try { - when(enodeWithNoDiscovery.getIp()).thenReturn(InetAddress.getByName("127.0.0.1")); - } - catch (UnknownHostException e) { - log.debug("Failed to resolve the Host Address "); - } + + when(enodeWithNoDiscovery.getIp()).thenReturn(InetAddress.getByName("127.0.0.1")); + Endpoint result = Endpoint.fromEnode(enodeWithNoDiscovery); assertEquals("127.0.0.1", result.getHost()); From 526c5182a5cd1e102f2be9d3a28ed68573eb9368 Mon Sep 17 00:00:00 2001 From: Vaidik Date: Thu, 5 Dec 2024 01:10:41 +0530 Subject: [PATCH 08/12] Update ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java Co-authored-by: Sally MacFarlane Signed-off-by: Vaidik --- .../org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java index e0531537634..c109f919600 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java @@ -37,7 +37,7 @@ * used in various Discovery messages. */ public class Endpoint { - private static final Logger log = LoggerFactory.getLogger(Endpoint.class); + private static final Logger LOG = LoggerFactory.getLogger(Endpoint.class); private final Optional host; private final int udpPort; private final Optional tcpPort; From 8fa1856d5a9a5a1aa2eeacfad0dfab51b016cc92 Mon Sep 17 00:00:00 2001 From: vaidikcode Date: Tue, 10 Dec 2024 14:42:33 +0530 Subject: [PATCH 09/12] Quickfix Signed-off-by: vaidikcode --- .../org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java index c109f919600..763ca4cc6a8 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java @@ -56,7 +56,7 @@ public static Endpoint fromEnode(final EnodeURL enode) { if (discoveryPort.isEmpty()) { int defaultPort = EnodeURLImpl.DEFAULT_LISTENING_PORT; - log.debug("Discovery disabled for enode {}. Using default port {}.", enode, defaultPort); + LOG.debug("Discovery disabled for enode {}. Using default port {}.", enode, defaultPort); return new Endpoint(enode.getIp().getHostAddress(), defaultPort, Optional.empty()); } From 7a67256a8f594db36d955df5237d604ac5c36e54 Mon Sep 17 00:00:00 2001 From: vaidikcode Date: Wed, 11 Dec 2024 13:16:52 +0530 Subject: [PATCH 10/12] spotless Signed-off-by: vaidikcode --- .../p2p/discovery/PeerDiscoveryAgentTest.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java index 27b7df98abc..6e1efbfd8ab 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java @@ -903,22 +903,21 @@ public void assertHostCorrectlyRevertsOnIgnoredPacketFrom() { @Test void testFromEnodeWithDiscoveryDisabled() throws UnknownHostException { - EnodeURL enodeWithNoDiscovery = mock(EnodeURL.class); - when(enodeWithNoDiscovery.getDiscoveryPort()).thenReturn(Optional.empty()); - when(enodeWithNoDiscovery.getListeningPort()).thenReturn(Optional.of(8545)); + EnodeURL enodeWithNoDiscovery = mock(EnodeURL.class); + when(enodeWithNoDiscovery.getDiscoveryPort()).thenReturn(Optional.empty()); + when(enodeWithNoDiscovery.getListeningPort()).thenReturn(Optional.of(8545)); - when(enodeWithNoDiscovery.getIp()).thenReturn(InetAddress.getByName("127.0.0.1")); + when(enodeWithNoDiscovery.getIp()).thenReturn(InetAddress.getByName("127.0.0.1")); - Endpoint result = Endpoint.fromEnode(enodeWithNoDiscovery); + Endpoint result = Endpoint.fromEnode(enodeWithNoDiscovery); - assertEquals("127.0.0.1", result.getHost()); + assertEquals("127.0.0.1", result.getHost()); - assertEquals(30303, result.getUdpPort()); + assertEquals(30303, result.getUdpPort()); - assertEquals(Optional.empty(), result.getTcpPort()); + assertEquals(Optional.empty(), result.getTcpPort()); } - protected void bondViaIncomingPing( final MockPeerDiscoveryAgent agent, final MockPeerDiscoveryAgent otherNode) { final Packet pingPacket = helper.createPingPacket(otherNode, agent); From 7fcf8fd6ab318105533e067846e1006a12f12a42 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 14 Jan 2025 12:50:02 +1000 Subject: [PATCH 11/12] loopback address Signed-off-by: Sally MacFarlane --- .../besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java index 6e1efbfd8ab..ac22632d206 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java @@ -907,7 +907,7 @@ void testFromEnodeWithDiscoveryDisabled() throws UnknownHostException { when(enodeWithNoDiscovery.getDiscoveryPort()).thenReturn(Optional.empty()); when(enodeWithNoDiscovery.getListeningPort()).thenReturn(Optional.of(8545)); - when(enodeWithNoDiscovery.getIp()).thenReturn(InetAddress.getByName("127.0.0.1")); + when(enodeWithNoDiscovery.getIp()).thenReturn(InetAddress.getLoopbackAddress()); Endpoint result = Endpoint.fromEnode(enodeWithNoDiscovery); From 0f4f4dc7a3185fa4b8ec7a6dbe79b444eed4d55c Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 15 Jan 2025 07:40:38 +1000 Subject: [PATCH 12/12] use constant Signed-off-by: Sally MacFarlane --- .../besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java index ac22632d206..8205bad5864 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java @@ -913,7 +913,7 @@ void testFromEnodeWithDiscoveryDisabled() throws UnknownHostException { assertEquals("127.0.0.1", result.getHost()); - assertEquals(30303, result.getUdpPort()); + assertEquals(EnodeURLImpl.DEFAULT_LISTENING_PORT, result.getUdpPort()); assertEquals(Optional.empty(), result.getTcpPort()); }