@@ -596,24 +596,24 @@ def connect_nodes(self, a, b):
596596 self .wait_until (lambda : sum (peer ['bytesrecv_per_msg' ].pop ('verack' , 0 ) == 24 for peer in to_connection .getpeerinfo ()) == to_num_peers )
597597
598598 def disconnect_nodes (self , a , b ):
599- def disconnect_nodes_helper (from_connection , node_num ):
600- def get_peer_ids ():
599+ def disconnect_nodes_helper (node_a , node_b ):
600+ def get_peer_ids (from_connection , node_num ):
601601 result = []
602602 for peer in from_connection .getpeerinfo ():
603603 if "testnode{}" .format (node_num ) in peer ['subver' ]:
604604 result .append (peer ['id' ])
605605 return result
606606
607- peer_ids = get_peer_ids ()
607+ peer_ids = get_peer_ids (node_a , node_b . index )
608608 if not peer_ids :
609609 self .log .warning ("disconnect_nodes: {} and {} were not connected" .format (
610- from_connection .index ,
611- node_num ,
610+ node_a .index ,
611+ node_b . index ,
612612 ))
613613 return
614614 for peer_id in peer_ids :
615615 try :
616- from_connection .disconnectnode (nodeid = peer_id )
616+ node_a .disconnectnode (nodeid = peer_id )
617617 except JSONRPCException as e :
618618 # If this node is disconnected between calculating the peer id
619619 # and issuing the disconnect, don't worry about it.
@@ -622,9 +622,10 @@ def get_peer_ids():
622622 raise
623623
624624 # wait to disconnect
625- self .wait_until (lambda : not get_peer_ids (), timeout = 5 )
625+ self .wait_until (lambda : not get_peer_ids (node_a , node_b .index ), timeout = 5 )
626+ self .wait_until (lambda : not get_peer_ids (node_b , node_a .index ), timeout = 5 )
626627
627- disconnect_nodes_helper (self .nodes [a ], b )
628+ disconnect_nodes_helper (self .nodes [a ], self . nodes [ b ] )
628629
629630 def split_network (self ):
630631 """
0 commit comments