99from test_framework .util import (
1010 assert_equal ,
1111 set_node_times ,
12+ wait_until ,
1213)
1314
1415
@@ -22,9 +23,9 @@ def setup_network(self):
2223 # don't connect nodes yet
2324 self .setup_nodes ()
2425
25- def connect_nodes_bi (self , a , b ):
26- self .connect_nodes (a , b )
27- self .connect_nodes (b , a )
26+ def connect_nodes_bi (self , a , b , wait_for_connect = True ):
27+ self .connect_nodes (a , b , wait_for_connect )
28+ self .connect_nodes (b , a , wait_for_connect )
2829
2930 def check_connected_nodes (self ):
3031 ni = [node .getnetworkinfo () for node in self .connected_nodes ]
@@ -96,9 +97,9 @@ def run_test(self):
9697
9798 # try to connect node 5 and check that it can't
9899 self .log .info ("Trying to connect with node-5 (+30 s)..." )
99- self . connect_nodes_bi ( 0 , 5 )
100- ni = self .nodes [ 0 ]. getnetworkinfo ( )
101- assert_equal ( ni [ 'connections' ], 10 )
100+ # Don't wait for a connection that will never be established.
101+ self .connect_nodes_bi ( 0 , 5 , False )
102+ wait_until ( lambda : self . nodes [ 0 ]. getnetworkinfo ()[ 'connections' ] == 10 )
102103 assert_equal (ni ['timeoffset' ], 15 )
103104 self .log .info ("Not connected." )
104105 self .log .info ("Node-0 nTimeOffset: +%d seconds" % ni ['timeoffset' ])
0 commit comments