Skip to content

Commit 2ed161c

Browse files
committed
test: avoid generating non-loopback traffic from p2p_dns_seeds.py
`p2p_dns_seeds.py` would try to connect to the DNS server configured on the machine and resolve `dummySeed.invalid`. To block that configure an unavailable proxy which will be used also to connect to the name server. The test needs 2 successful connections to other peers (two Python `P2PInterface`s) and they work in spite of the unavailable proxy because they are on `127.0.0.1` (`NET_UNROUTABLE`) and the proxy is not used for that.
1 parent a5746dc commit 2ed161c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/functional/p2p_dns_seeds.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import itertools
88

9+
from test_framework.netutil import UNREACHABLE_PROXY_ARG
910
from test_framework.p2p import P2PInterface
1011
from test_framework.test_framework import BitcoinTestFramework
1112

@@ -14,7 +15,7 @@ class P2PDNSSeeds(BitcoinTestFramework):
1415
def set_test_params(self):
1516
self.setup_clean_chain = True
1617
self.num_nodes = 1
17-
self.extra_args = [["-dnsseed=1"]]
18+
self.extra_args = [["-dnsseed=1", UNREACHABLE_PROXY_ARG]]
1819

1920
def run_test(self):
2021
self.init_arg_tests()
@@ -29,11 +30,11 @@ def init_arg_tests(self):
2930
self.log.info("Check that setting -connect disables -dnsseed by default")
3031
self.nodes[0].stop_node()
3132
with self.nodes[0].assert_debug_log(expected_msgs=["DNS seeding disabled"]):
32-
self.start_node(0, [f"-connect={fakeaddr}"])
33+
self.start_node(0, extra_args=[f"-connect={fakeaddr}", UNREACHABLE_PROXY_ARG])
3334

3435
self.log.info("Check that running -connect and -dnsseed means DNS logic runs.")
3536
with self.nodes[0].assert_debug_log(expected_msgs=["Loading addresses from DNS seed"], timeout=12):
36-
self.restart_node(0, [f"-connect={fakeaddr}", "-dnsseed=1"])
37+
self.restart_node(0, extra_args=[f"-connect={fakeaddr}", "-dnsseed=1", UNREACHABLE_PROXY_ARG])
3738

3839
self.log.info("Check that running -forcednsseed and -dnsseed=0 throws an error.")
3940
self.nodes[0].stop_node()
@@ -88,7 +89,7 @@ def force_dns_test(self):
8889
with self.nodes[0].assert_debug_log(expected_msgs=["Loading addresses from DNS seed"], timeout=12):
8990
# -dnsseed defaults to 1 in bitcoind, but 0 in the test framework,
9091
# so pass it explicitly here
91-
self.restart_node(0, ["-forcednsseed", "-dnsseed=1"])
92+
self.restart_node(0, ["-forcednsseed", "-dnsseed=1", UNREACHABLE_PROXY_ARG])
9293

9394
# Restore default for subsequent tests
9495
self.restart_node(0)

0 commit comments

Comments
 (0)