diff options
author | Elliott Jin <elliott.jin@gmail.com> | 2020-09-17 00:24:03 -0700 |
---|---|---|
committer | Elliott Jin <elliott.jin@gmail.com> | 2020-10-20 00:43:00 -0700 |
commit | 3c7d9ab8c8ec5284cdad1a53ee310b79b931f12f (patch) | |
tree | ba97cec0a4775ec3910bbe9847a01b7e8c0acd76 /test/functional/test_framework/util.py | |
parent | 4b16c614616c1ff09e5b1dcd58516bcb9a88e5e8 (diff) | |
download | bitcoin-3c7d9ab8c8ec5284cdad1a53ee310b79b931f12f.tar.xz |
test: Move (dis)?connect_nodes globals into TestFramework as helpers
Diffstat (limited to 'test/functional/test_framework/util.py')
-rw-r--r-- | test/functional/test_framework/util.py | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 7688febae7..3356f1ab10 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -411,47 +411,6 @@ def set_node_times(nodes, t): node.setmocktime(t) -def disconnect_nodes(from_connection, node_num): - def get_peer_ids(): - result = [] - for peer in from_connection.getpeerinfo(): - if "testnode{}".format(node_num) in peer['subver']: - result.append(peer['id']) - return result - - peer_ids = get_peer_ids() - if not peer_ids: - logger.warning("disconnect_nodes: {} and {} were not connected".format( - from_connection.index, - node_num, - )) - return - for peer_id in peer_ids: - try: - from_connection.disconnectnode(nodeid=peer_id) - except JSONRPCException as e: - # If this node is disconnected between calculating the peer id - # and issuing the disconnect, don't worry about it. - # This avoids a race condition if we're mass-disconnecting peers. - if e.error['code'] != -29: # RPC_CLIENT_NODE_NOT_CONNECTED - raise - - # wait to disconnect - wait_until_helper(lambda: not get_peer_ids(), timeout=5) - - -def connect_nodes(from_connection, node_num): - ip_port = "127.0.0.1:" + str(p2p_port(node_num)) - from_connection.addnode(ip_port, "onetry") - # poll until version handshake complete to avoid race conditions - # with transaction relaying - # See comments in net_processing: - # * Must have a version message before anything else - # * Must have a verack message before anything else - wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo())) - wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo())) - - # Transaction/Block functions ############################# |