@@ -586,7 +586,14 @@ def restart_node(self, i, extra_args=None):
586586 def wait_for_node_exit (self , i , timeout ):
587587 self .nodes [i ].process .wait (timeout )
588588
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+ """
590597 from_connection = self .nodes [a ]
591598 to_connection = self .nodes [b ]
592599 from_num_peers = 1 + len (from_connection .getpeerinfo ())
@@ -603,6 +610,9 @@ def connect_nodes(self, a, b, *, peer_advertises_v2=None):
603610 # compatibility with older clients
604611 from_connection .addnode (ip_port , "onetry" )
605612
613+ if not wait_for_connect :
614+ return
615+
606616 # poll until version handshake complete to avoid race conditions
607617 # with transaction relaying
608618 # See comments in net_processing:
0 commit comments