From 2ed161c5ce648cb66ec3d2941b02d68b6ca4c390 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 26 Nov 2024 15:14:41 +0100 Subject: [PATCH] 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. --- test/functional/p2p_dns_seeds.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/functional/p2p_dns_seeds.py b/test/functional/p2p_dns_seeds.py index a2d4ea110f..89a29c0ebd 100755 --- a/test/functional/p2p_dns_seeds.py +++ b/test/functional/p2p_dns_seeds.py @@ -6,6 +6,7 @@ import itertools +from test_framework.netutil import UNREACHABLE_PROXY_ARG from test_framework.p2p import P2PInterface from test_framework.test_framework import BitcoinTestFramework @@ -14,7 +15,7 @@ class P2PDNSSeeds(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 - self.extra_args = [["-dnsseed=1"]] + self.extra_args = [["-dnsseed=1", UNREACHABLE_PROXY_ARG]] def run_test(self): self.init_arg_tests() @@ -29,11 +30,11 @@ class P2PDNSSeeds(BitcoinTestFramework): self.log.info("Check that setting -connect disables -dnsseed by default") self.nodes[0].stop_node() with self.nodes[0].assert_debug_log(expected_msgs=["DNS seeding disabled"]): - self.start_node(0, [f"-connect={fakeaddr}"]) + self.start_node(0, extra_args=[f"-connect={fakeaddr}", UNREACHABLE_PROXY_ARG]) self.log.info("Check that running -connect and -dnsseed means DNS logic runs.") with self.nodes[0].assert_debug_log(expected_msgs=["Loading addresses from DNS seed"], timeout=12): - self.restart_node(0, [f"-connect={fakeaddr}", "-dnsseed=1"]) + self.restart_node(0, extra_args=[f"-connect={fakeaddr}", "-dnsseed=1", UNREACHABLE_PROXY_ARG]) self.log.info("Check that running -forcednsseed and -dnsseed=0 throws an error.") self.nodes[0].stop_node() @@ -88,7 +89,7 @@ class P2PDNSSeeds(BitcoinTestFramework): with self.nodes[0].assert_debug_log(expected_msgs=["Loading addresses from DNS seed"], timeout=12): # -dnsseed defaults to 1 in bitcoind, but 0 in the test framework, # so pass it explicitly here - self.restart_node(0, ["-forcednsseed", "-dnsseed=1"]) + self.restart_node(0, ["-forcednsseed", "-dnsseed=1", UNREACHABLE_PROXY_ARG]) # Restore default for subsequent tests self.restart_node(0)