File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
test/functional/test_framework Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -381,7 +381,21 @@ def set_node_times(nodes, t):
381
381
node .setmocktime (t )
382
382
383
383
def disconnect_nodes (from_connection , node_num ):
384
- for peer_id in [peer ['id' ] for peer in from_connection .getpeerinfo () if "testnode%d" % node_num in peer ['subver' ]]:
384
+ def get_peer_ids ():
385
+ result = []
386
+ for peer in from_connection .getpeerinfo ():
387
+ if "testnode{}" .format (node_num ) in peer ['subver' ]:
388
+ result .append (peer ['id' ])
389
+ return result
390
+
391
+ peer_ids = get_peer_ids ()
392
+ if not peer_ids :
393
+ logger .warning ("disconnect_nodes: {} and {} were not connected" .format (
394
+ from_connection .index ,
395
+ node_num
396
+ ))
397
+ return
398
+ for peer_id in peer_ids :
385
399
try :
386
400
from_connection .disconnectnode (nodeid = peer_id )
387
401
except JSONRPCException as e :
@@ -392,7 +406,7 @@ def disconnect_nodes(from_connection, node_num):
392
406
raise
393
407
394
408
# wait to disconnect
395
- wait_until (lambda : [ peer [ 'id' ] for peer in from_connection . getpeerinfo () if "testnode%d" % node_num in peer [ 'subver' ]] == [] , timeout = 5 )
409
+ wait_until (lambda : not get_peer_ids () , timeout = 5 )
396
410
397
411
def connect_nodes (from_connection , node_num ):
398
412
ip_port = "127.0.0.1:" + str (p2p_port (node_num ))
You can’t perform that action at this time.
0 commit comments