30
30
addnode connect to a CJDNS address
31
31
32
32
- Test getnetworkinfo for each node
33
+
34
+ - Test passing invalid -proxy
35
+ - Test passing invalid -onion
36
+ - Test passing -onlynet=onion without -proxy or -onion
37
+ - Test passing -onlynet=onion with -onion=0 and with -noonion
33
38
"""
34
39
35
40
import socket
@@ -263,12 +268,13 @@ def networks_dict(d):
263
268
264
269
n2 = networks_dict (self .nodes [2 ].getnetworkinfo ())
265
270
assert_equal (NETWORKS , n2 .keys ())
271
+ proxy = f'{ self .conf2 .addr [0 ]} :{ self .conf2 .addr [1 ]} '
266
272
for net in NETWORKS :
267
273
if net == NET_I2P :
268
274
expected_proxy = ''
269
275
expected_randomize = False
270
276
else :
271
- expected_proxy = f' { self . conf2 . addr [ 0 ] } : { self . conf2 . addr [ 1 ] } '
277
+ expected_proxy = proxy
272
278
expected_randomize = True
273
279
assert_equal (n2 [net ]['proxy' ], expected_proxy )
274
280
assert_equal (n2 [net ]['proxy_randomize_credentials' ], expected_randomize )
@@ -279,11 +285,9 @@ def networks_dict(d):
279
285
if self .have_ipv6 :
280
286
n3 = networks_dict (self .nodes [3 ].getnetworkinfo ())
281
287
assert_equal (NETWORKS , n3 .keys ())
288
+ proxy = f'[{ self .conf3 .addr [0 ]} ]:{ self .conf3 .addr [1 ]} '
282
289
for net in NETWORKS :
283
- if net == NET_I2P or net == NET_ONION :
284
- expected_proxy = ''
285
- else :
286
- expected_proxy = f'[{ self .conf3 .addr [0 ]} ]:{ self .conf3 .addr [1 ]} '
290
+ expected_proxy = '' if net == NET_I2P or net == NET_ONION else proxy
287
291
assert_equal (n3 [net ]['proxy' ], expected_proxy )
288
292
assert_equal (n3 [net ]['proxy_randomize_credentials' ], False )
289
293
assert_equal (n3 ['onion' ]['reachable' ], False )
@@ -305,6 +309,32 @@ def networks_dict(d):
305
309
assert_equal (n4 ['i2p' ]['reachable' ], False )
306
310
assert_equal (n4 ['cjdns' ]['reachable' ], True )
307
311
312
+ self .stop_node (1 )
313
+
314
+ self .log .info ("Test passing invalid -proxy raises expected init error" )
315
+ self .nodes [1 ].extra_args = ["-proxy=abc:def" ]
316
+ msg = "Error: Invalid -proxy address or hostname: 'abc:def'"
317
+ self .nodes [1 ].assert_start_raises_init_error (expected_msg = msg )
318
+
319
+ self .log .info ("Test passing invalid -onion raises expected init error" )
320
+ self .nodes [1 ].extra_args = ["-onion=xyz:abc" ]
321
+ msg = "Error: Invalid -onion address or hostname: 'xyz:abc'"
322
+ self .nodes [1 ].assert_start_raises_init_error (expected_msg = msg )
323
+
324
+ msg = (
325
+ "Error: Outbound connections restricted to Tor (-onlynet=onion) but "
326
+ "the proxy for reaching the Tor network is not provided (no -proxy= "
327
+ "and no -onion= given) or it is explicitly forbidden (-onion=0)"
328
+ )
329
+ self .log .info ("Test passing -onlynet=onion without -proxy or -onion raises expected init error" )
330
+ self .nodes [1 ].extra_args = ["-onlynet=onion" ]
331
+ self .nodes [1 ].assert_start_raises_init_error (expected_msg = msg )
332
+
333
+ self .log .info ("Test passing -onlynet=onion with -onion=0/-noonion raises expected init error" )
334
+ for arg in ["-onion=0" , "-noonion" ]:
335
+ self .nodes [1 ].extra_args = ["-onlynet=onion" , arg ]
336
+ self .nodes [1 ].assert_start_raises_init_error (expected_msg = msg )
337
+
308
338
309
339
if __name__ == '__main__' :
310
340
ProxyTest ().main ()
0 commit comments