@@ -441,20 +441,22 @@ def networks_dict(d):
441441 self .start_node (1 , extra_args = ["-onlynet=onion" , "-listenonion=1" ])
442442 self .stop_node (1 )
443443
444- self .log .info ("Test passing unknown network to -onlynet raises expected init error" )
445- self .nodes [1 ].extra_args = ["-onlynet=abc" ]
446- msg = "Error: Unknown network specified in -onlynet: 'abc'"
447- self .nodes [1 ].assert_start_raises_init_error (expected_msg = msg )
444+ self .log .info ("Test unknown and removed network names are rejected by -onlynet" )
445+ for network in ["abc" , "tor" ]:
446+ self .nodes [1 ].extra_args = [f"-onlynet={ network } " ]
447+ msg = f"Error: Unknown network specified in -onlynet: '{ network } '"
448+ self .nodes [1 ].assert_start_raises_init_error (expected_msg = msg )
448449
449450 self .log .info ("Test passing trailing '=' raises expected init error" )
450451 self .nodes [1 ].extra_args = ["-proxy=127.0.0.1:9050=" ]
451452 msg = "Error: Invalid -proxy address or hostname, ends with '=': '127.0.0.1:9050='"
452453 self .nodes [1 ].assert_start_raises_init_error (expected_msg = msg )
453454
454- self .log .info ("Test passing unrecognized network raises expected init error" )
455- self .nodes [1 ].extra_args = ["-proxy=127.0.0.1:9050=foo" ]
456- msg = "Error: Unrecognized network in -proxy='127.0.0.1:9050=foo': 'foo'"
457- self .nodes [1 ].assert_start_raises_init_error (expected_msg = msg )
455+ self .log .info ("Test unknown, removed and non-SOCKS5 network names are rejected by -proxy" )
456+ for network in ["Foo" , "tor" , "i2p" ]:
457+ self .nodes [1 ].extra_args = [f"-proxy=127.0.0.1:9050={ network } " ]
458+ msg = f"Error: Unrecognized network in -proxy='127.0.0.1:9050={ network } ': '{ network .lower ()} '" # TODO: The error must identify the invalid input exactly
459+ self .nodes [1 ].assert_start_raises_init_error (expected_msg = msg )
458460
459461 self .log .info ("Test passing proxy only for IPv6" )
460462 self .start_node (1 , extra_args = ["-proxy=127.6.6.6:6666=ipv6" ])
@@ -470,8 +472,8 @@ def networks_dict(d):
470472 assert_equal (nets ["ipv6" ]["proxy" ], "127.6.6.6:6666" )
471473 self .stop_node (1 )
472474
473- self .log .info ("Test overriding the Onion proxy" )
474- self .start_node (1 , extra_args = ["-proxy=127.1.1.1:1111" , "-proxy=127.2.2.2:2222=onion " ])
475+ self .log .info ("Test overriding the Onion proxy with a mixed-case network suffix " )
476+ self .start_node (1 , extra_args = ["-proxy=127.1.1.1:1111" , "-proxy=127.2.2.2:2222=OnIoN " ])
475477 nets = networks_dict (self .nodes [1 ].getnetworkinfo ())
476478 assert_equal (nets ["ipv4" ]["proxy" ], "127.1.1.1:1111" )
477479 assert_equal (nets ["ipv6" ]["proxy" ], "127.1.1.1:1111" )
@@ -487,6 +489,15 @@ def networks_dict(d):
487489 assert_equal (nets ["cjdns" ]["proxy" ], "" )
488490 self .stop_node (1 )
489491
492+ self .log .info ("Test that clearing the IPv4 proxy also clears the name proxy" )
493+ self .start_node (1 , extra_args = [f"-proxy={ self .conf1 .addr [0 ]} :{ self .conf1 .addr [1 ]} " , "-proxy=0=ipv4" , "-dns=0" ])
494+ with self .nodes [1 ].assert_debug_log (
495+ expected_msgs = ["trying v1 connection (manual) to example.invalid:8333" ],
496+ unexpected_msgs = ["SOCKS5 connecting example.invalid" ],
497+ ):
498+ self .nodes [1 ].addnode ("example.invalid:8333" , "onetry" , v2transport = False )
499+ self .stop_node (1 )
500+
490501 self .log .info ("Test passing too-long unix path to -proxy raises init error" )
491502 self .nodes [1 ].extra_args = [f"-proxy=unix:{ 'x' * 1000 } " ]
492503 if self .have_unix_sockets :
0 commit comments