When new nodes are added to the feature_bind_extra.py
test, it succeeds if run individually, but fails if run via test_runner
with the error message:
0TestFramework (ERROR): Unexpected exception
1Traceback (most recent call last):
2 File "/home/node/test/functional/test_framework/test_framework.py", line 191, in main
3 self.setup()
4 File "/home/node/test/functional/test_framework/test_framework.py", line 349, in setup
5 self.setup_network()
6 File "/home/node/build/test/functional/feature_bind_extra.py", line 100, in setup_network
7 self.setup_nodes()
8 File "/home/node/test/functional/test_framework/test_framework.py", line 462, in setup_nodes
9 self.start_nodes()
10 File "/home/node/test/functional/test_framework/test_framework.py", line 603, in start_nodes
11 node.wait_for_rpc_connection()
12 File "/home/node/test/functional/test_framework/test_node.py", line 284, in wait_for_rpc_connection
13 raise FailedToStartError(self._node_msg(
14test_framework.test_node.FailedToStartError: [node 4] bitcoind exited with status 1 during initialization. Error: Unable to bind to 127.0.0.1:13388 on this computer. Bitcoin Core is probably already running.
15Error: Failed to listen on any port. Use -listen=0 if you want this.
I noticed this when creating more tests for #33231
It seems to be related to multiple nodes concurrently using the same port, but I’m not sure if it’s expected behavior or if it should happen.
Specifically for the feature_bind_extra.py
test, it can be resolved by reusing the same node. Multiple nodes were being created unnecessarily. I fixed this in the first commit of #33231 (https://github.com/bitcoin/bitcoin/pull/33231/commits/6b448e2eab007c9abd9f6be3c96a533641a73abc). This makes this test more efficient and prevents the error from occurring, but it does not address the underlying problem (if there is one).
To reproduce the error, that’s the patch:
0diff --git a/test/functional/feature_bind_extra.py b/test/functional/feature_bind_extra.py
1index 6b53de188f..9aac53f064 100755
2--- a/test/functional/feature_bind_extra.py
3+++ b/test/functional/feature_bind_extra.py
4@@ -27,7 +27,7 @@ class BindExtraTest(BitcoinTestFramework):
5 # Avoid any -bind= on the command line. Force the framework to avoid
6 # adding -bind=127.0.0.1.
7 self.bind_to_localhost_only = False
8- self.num_nodes = 3
9+ self.num_nodes = 6
10
11 def skip_test_if_missing_module(self):
12 # Due to OS-specific network stats queries, we only run on Linux.
13@@ -69,6 +69,33 @@ class BindExtraTest(BitcoinTestFramework):
14 )
15 port += 1
16
17+ # Node1, both -bind=... and -bind=...=onion.
18+ self.expected.append(
19+ [
20+ [f"-bind=127.0.0.1:{port}", f"-bind=127.0.0.1:{port + 1}=onion"],
21+ [(loopback_ipv4, port), (loopback_ipv4, port + 1)]
22+ ],
23+ )
24+ port += 2
25+
26+ # Node1, both -bind=... and -bind=...=onion.
27+ self.expected.append(
28+ [
29+ [f"-bind=127.0.0.1:{port}", f"-bind=127.0.0.1:{port + 1}=onion"],
30+ [(loopback_ipv4, port), (loopback_ipv4, port + 1)]
31+ ],
32+ )
33+ port += 2
34+
35+ # Node1, both -bind=... and -bind=...=onion.
36+ self.expected.append(
37+ [
38+ [f"-bind=127.0.0.1:{port}", f"-bind=127.0.0.1:{port + 1}=onion"],
39+ [(loopback_ipv4, port), (loopback_ipv4, port + 1)]
40+ ],
41+ )
42+ port += 2
43+
44 self.extra_args = list(map(lambda e: e[0], self.expected))
45 self.setup_nodes()