Skip to content

Commit 082779d

Browse files
committed
test: Add explicit onion bind to p2p_permissions
When the bind option is replaced in the bitcoin.conf, bitcoind will attempd to bind to the default tor listening port. If another bitcoind is running that is already bound to that port, the bind will fail which, since bitcoin#22729, causes the test to fail. This failure can be avoided by explicitly binding the tor port when the bind is removed.
1 parent d4b5553 commit 082779d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

test/functional/p2p_permissions.py

+5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
from test_framework.test_node import ErrorMatch
1515
from test_framework.test_framework import BitcoinTestFramework
1616
from test_framework.util import (
17+
append_config,
1718
assert_equal,
1819
p2p_port,
20+
tor_port,
1921
)
2022
from test_framework.wallet import MiniWallet
2123

@@ -57,11 +59,14 @@ def run_test(self):
5759
# by modifying the configuration file.
5860
ip_port = "127.0.0.1:{}".format(p2p_port(1))
5961
self.nodes[1].replace_in_config([("bind=127.0.0.1", "whitebind=bloomfilter,forcerelay@" + ip_port)])
62+
# Explicitly bind the tor port to prevent collisions with the default tor port
63+
append_config(self.nodes[1].datadir_path, [f"bind=127.0.0.1:{tor_port(self.nodes[1].index)}=onion"])
6064
self.checkpermission(
6165
6266
# Check parameter interaction forcerelay should activate relay
6367
["noban", "bloomfilter", "forcerelay", "relay", "download"])
6468
self.nodes[1].replace_in_config([("whitebind=bloomfilter,forcerelay@" + ip_port, "bind=127.0.0.1")])
69+
self.nodes[1].replace_in_config([(f"bind=127.0.0.1:{tor_port(self.nodes[1].index)}=onion", "")])
6570

6671
self.checkpermission(
6772
# legacy whitelistrelay should be ignored

0 commit comments

Comments
 (0)