@@ -224,11 +224,43 @@ def test_seed_peers(self):
224
224
]):
225
225
self .nodes [0 ].setmocktime (start + 65 )
226
226
227
+ def test_connect_with_seednode (self ):
228
+ self .log .info ('Test -connect with -seednode' )
229
+ seednode_ignored = ['-seednode is ignored when -connect is used\n ' ]
230
+ dnsseed_ignored = ['-dnsseed is ignored when -connect is used and -proxy is specified\n ' ]
231
+ addcon_thread_started = ['addcon thread start\n ' ]
232
+ self .stop_node (0 )
233
+
234
+ # When -connect is supplied, expanding addrman via getaddr calls to ADDR_FETCH(-seednode)
235
+ # nodes is irrelevant and -seednode is ignored.
236
+ with self .nodes [0 ].assert_debug_log (expected_msgs = seednode_ignored ):
237
+ self .start_node (0 , extra_args = ['-connect=fakeaddress1' , '-seednode=fakeaddress2' ])
238
+
239
+ # With -proxy, an ADDR_FETCH connection is made to a peer that the dns seed resolves to.
240
+ # ADDR_FETCH connections are not used when -connect is used.
241
+ with self .nodes [0 ].assert_debug_log (expected_msgs = dnsseed_ignored ):
242
+ self .restart_node (0 , extra_args = ['-connect=fakeaddress1' , '-dnsseed=1' , '-proxy=1.2.3.4' ])
243
+
244
+ # If the user did not disable -dnsseed, but it was soft-disabled because they provided -connect,
245
+ # they shouldn't see a warning about -dnsseed being ignored.
246
+ with self .nodes [0 ].assert_debug_log (expected_msgs = addcon_thread_started ,
247
+ unexpected_msgs = dnsseed_ignored ):
248
+ self .restart_node (0 , extra_args = ['-connect=fakeaddress1' , '-proxy=1.2.3.4' ])
249
+
250
+ # We have to supply expected_msgs as it's a required argument
251
+ # The expected_msg must be something we are confident will be logged after the unexpected_msg
252
+ # These cases test for -connect being supplied but only to disable it
253
+ for connect_arg in ['-connect=0' , '-noconnect' ]:
254
+ with self .nodes [0 ].assert_debug_log (expected_msgs = addcon_thread_started ,
255
+ unexpected_msgs = seednode_ignored ):
256
+ self .restart_node (0 , extra_args = [connect_arg , '-seednode=fakeaddress2' ])
257
+
227
258
def run_test (self ):
228
259
self .test_log_buffer ()
229
260
self .test_args_log ()
230
261
self .test_seed_peers ()
231
262
self .test_networkactive ()
263
+ self .test_connect_with_seednode ()
232
264
233
265
self .test_config_file_parser ()
234
266
self .test_invalid_command_line_options ()
0 commit comments