Skip to content

Commit c1fa5a0

Browse files
MacroFakePastaPastaPasta
authored andcommitted
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
1 parent aaa83ae commit c1fa5a0

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

test/functional/p2p_getaddr_caching.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
from test_framework.test_framework import BitcoinTestFramework
1313
from test_framework.util import (
1414
assert_equal,
15-
PORT_MIN,
16-
PORT_RANGE,
15+
p2p_port,
1716
)
1817

1918
# As defined in net_processing.
@@ -42,10 +41,9 @@ def addr_received(self):
4241
class AddrTest(BitcoinTestFramework):
4342
def set_test_params(self):
4443
self.num_nodes = 1
45-
# Start onion ports after p2p and rpc ports.
46-
port = PORT_MIN + 2 * PORT_RANGE
47-
self.onion_port1 = port
48-
self.onion_port2 = port + 1
44+
# Use some of the remaining p2p ports for the onion binds.
45+
self.onion_port1 = p2p_port(1)
46+
self.onion_port2 = p2p_port(2)
4947
self.extra_args = [
5048
[f"-bind=127.0.0.1:{self.onion_port1}=onion", f"-bind=127.0.0.1:{self.onion_port2}=onion"],
5149
]

test/functional/test_framework/test_framework.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ def parse_args(self):
236236
# source: https://stackoverflow.com/questions/48796169/how-to-fix-ipykernel-launcher-py-error-unrecognized-arguments-in-jupyter/56349168#56349168
237237
parser.add_argument("-f", "--fff", help="a dummy argument to fool ipython", default="1")
238238

239+
PortSeed.n = self.options.port_seed
240+
239241
def setup(self):
240242
"""Call this method to start up the test framework object with options set."""
241243

242-
PortSeed.n = self.options.port_seed
243-
244244
check_json_precision()
245245

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

0 commit comments

Comments
 (0)