test: Use unassigned p2p_port instead of hardcoded 60000 in p2p_i2p_ports.py
What changed, and why it matters
This is a minor test-only change in Bitcoin Core. It replaces a hardcoded port number (60000) used in a test with a dynamically chosen unassigned port. There is no effect on the actual Bitcoin software users run, and no security issue is being fixed or introduced.
No action needed. This is a benign test maintenance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies test/functional/p2p_i2p_ports.py to use the framework helper p2p_port(self.num_nodes) instead of the hardcoded string ‘127.0.0.1:60000’ as the fake I2P SAM proxy address. The test verifies that Bitcoin Core produces an error when attempting to connect to an I2P address via a non-existent proxy. The change only affects the functional test suite and avoids potential port collisions during testing.
Changed components
test/functional/p2p_i2p_ports.pyInspect captured patch +6 / −5
diff --git a/test/functional/p2p_i2p_ports.py b/test/functional/p2p_i2p_ports.py
index b1a3c61c..83a95123 100755
--- a/test/functional/p2p_i2p_ports.py
+++ b/test/functional/p2p_i2p_ports.py
@@ -1,21 +1,22 @@
#!/usr/bin/env python3
-# Copyright (c) 2021-2021 The Bitcoin Core developers
+# Copyright (c) 2021-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""
Test ports handling for I2P hosts
"""
-
from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import p2p_port
-PROXY = "127.0.0.1:60000"
class I2PPorts(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
+ # Use the p2p port of the non-existing next node as the proxy port
+ self.proxy = f"127.0.0.1:{p2p_port(self.num_nodes)}"
# The test assumes that an I2P SAM proxy is not listening here.
- self.extra_args = [[f"-i2psam={PROXY}"]]
+ self.extra_args = [[f"-i2psam={self.proxy}"]]
def run_test(self):
node = self.nodes[0]
@@ -27,7 +28,7 @@ class I2PPorts(BitcoinTestFramework):
self.log.info("Ensure we try to connect if port=0 and get an error due to missing I2P proxy")
addr = "h3r6bkn46qxftwja53pxiykntegfyfjqtnzbm6iv6r5mungmqgmq.b32.i2p:0"
- with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}: Cannot connect to {PROXY}"]):
+ with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}: Cannot connect to {self.proxy}"]):
node.addnode(node=addr, command="onetry")
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.