From 752ab9c3c65e47fc05545d9b9c919be945851d51 Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Sun, 28 Jul 2024 23:00:56 -0400 Subject: [PATCH] test: Add test to make sure -noconnect disables -dnsseed and -listen by default Make sure -noconnect has same effect as -connect for disabling DNS seeding and listening by default, and warning about -dnsseed being ignored with the -proxy setting. Initial implementation of https://github.com/bitcoin/bitcoin/pull/30529 accidentally broke this behavior, so having coverage may be useful to make sure it does not break again. Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com> --- test/functional/feature_config_args.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py index b2462be951a..e8fc1aca46c 100755 --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.py @@ -369,6 +369,8 @@ class ConfArgsTest(BitcoinTestFramework): seednode_ignored = ['-seednode is ignored when -connect is used\n'] dnsseed_ignored = ['-dnsseed is ignored when -connect is used and -proxy is specified\n'] addcon_thread_started = ['addcon thread start\n'] + dnsseed_disabled = "parameter interaction: -connect or -maxconnections=0 set -> setting -dnsseed=0" + listen_disabled = "parameter interaction: -connect or -maxconnections=0 set -> setting -listen=0" # When -connect is supplied, expanding addrman via getaddr calls to ADDR_FETCH(-seednode) # nodes is irrelevant and -seednode is ignored. @@ -393,6 +395,19 @@ class ConfArgsTest(BitcoinTestFramework): with self.nodes[0].assert_debug_log(expected_msgs=addcon_thread_started, unexpected_msgs=seednode_ignored): self.restart_node(0, extra_args=[connect_arg, '-seednode=fakeaddress2']) + + # Make sure -noconnect soft-disables -listen and -dnsseed. + # Need to temporarily remove these settings from the config file in + # order for the two log messages to appear + self.nodes[0].replace_in_config([("bind=", "#bind="), ("dnsseed=", "#dnsseed=")]) + with self.nodes[0].assert_debug_log(expected_msgs=[dnsseed_disabled, listen_disabled]): + self.restart_node(0, extra_args=[connect_arg]) + self.nodes[0].replace_in_config([("#bind=", "bind="), ("#dnsseed=", "dnsseed=")]) + + # Make sure -proxy and -noconnect warn about -dnsseed setting being + # ignored, just like -proxy and -connect do. + with self.nodes[0].assert_debug_log(expected_msgs=dnsseed_ignored): + self.restart_node(0, extra_args=[connect_arg, '-dnsseed', '-proxy=localhost:1080']) self.stop_node(0) def test_ignored_conf(self):