Skip to content

Commit c3daa32

Browse files
author
MacroFake
committed
Merge bitcoin#25312: test: Fix port collisions caused by p2p_getaddr_caching.py
ea54ba2 [test] Fix port collisions caused by p2p_getaddr_caching.py (dergoegge) f9682e7 [test_framework] Set PortSeed.n directly after initialising params (dergoegge) Pull request description: This PR fixes the issue mentioned [here](bitcoin#25096 (comment)), to avoid port collisions between nodes spun up by the test framework. Top commit has no ACKs. Tree-SHA512: ec9159f0af90db636f7889d664c24e1430cf2bcb3c02a9ab2dcfe531b2a4d18f6e3a0f8ba73071bdf2f7db518df9d5d86a9cd06695e67644d20fe4515fac32b7
2 parents e3c08eb + ea54ba2 commit c3daa32

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

test/functional/p2p_getaddr_caching.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
from test_framework.test_framework import BitcoinTestFramework
1515
from test_framework.util import (
1616
assert_equal,
17-
PORT_MIN,
18-
PORT_RANGE,
17+
p2p_port,
1918
)
2019

2120
# As defined in net_processing.
@@ -44,10 +43,9 @@ def addr_received(self):
4443
class AddrTest(BitcoinTestFramework):
4544
def set_test_params(self):
4645
self.num_nodes = 1
47-
# Start onion ports after p2p and rpc ports.
48-
port = PORT_MIN + 2 * PORT_RANGE
49-
self.onion_port1 = port
50-
self.onion_port2 = port + 1
46+
# Use some of the remaining p2p ports for the onion binds.
47+
self.onion_port1 = p2p_port(1)
48+
self.onion_port2 = p2p_port(2)
5149
self.extra_args = [
5250
[f"-bind=127.0.0.1:{self.onion_port1}=onion", f"-bind=127.0.0.1:{self.onion_port2}=onion"],
5351
]

test/functional/test_framework/test_framework.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ def parse_args(self):
223223
# It still needs to exist and be None in order for tests to work however.
224224
self.options.descriptors = None
225225

226+
PortSeed.n = self.options.port_seed
227+
226228
def setup(self):
227229
"""Call this method to start up the test framework object with options set."""
228230

229-
PortSeed.n = self.options.port_seed
230-
231231
check_json_precision()
232232

233233
self.options.cachedir = os.path.abspath(self.options.cachedir)

0 commit comments

Comments
 (0)