@@ -586,7 +586,14 @@ def restart_node(self, i, extra_args=None):
586
586
def wait_for_node_exit (self , i , timeout ):
587
587
self .nodes [i ].process .wait (timeout )
588
588
589
- def connect_nodes (self , a , b , * , peer_advertises_v2 = None ):
589
+ def connect_nodes (self , a , b , * , peer_advertises_v2 = None , wait_for_connect : bool = True ):
590
+ """
591
+ Kwargs:
592
+ wait_for_connect: if True, block until the nodes are verified as connected. You might
593
+ want to disable this when using -stopatheight with one of the connected nodes,
594
+ since there will be a race between the actual connection and performing
595
+ the assertions before one node shuts down.
596
+ """
590
597
from_connection = self .nodes [a ]
591
598
to_connection = self .nodes [b ]
592
599
from_num_peers = 1 + len (from_connection .getpeerinfo ())
@@ -603,6 +610,9 @@ def connect_nodes(self, a, b, *, peer_advertises_v2=None):
603
610
# compatibility with older clients
604
611
from_connection .addnode (ip_port , "onetry" )
605
612
613
+ if not wait_for_connect :
614
+ return
615
+
606
616
# poll until version handshake complete to avoid race conditions
607
617
# with transaction relaying
608
618
# See comments in net_processing:
0 commit comments