浏览代码

[qa] Handle disconnect_node race

Several tests call disconnect_nodes() on each node-pair in rapid
succession, resulting in a race condition if a node disconnects a peer
in-between the calculation of the nodeid's to disconnect and the
invocation of the disconnectnode rpc call.  Handle this.

GitHub-Pull: #13201
Rebased-From: 09c6699
tags/v0.16.1
Suhas Daftuar 3 年前
父节点
当前提交
b8aacd660e
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8
    1
      test/functional/test_framework/util.py

+ 8
- 1
test/functional/test_framework/util.py 查看文件

@@ -335,7 +335,14 @@ def set_node_times(nodes, t):

def disconnect_nodes(from_connection, node_num):
for peer_id in [peer['id'] for peer in from_connection.getpeerinfo() if "testnode%d" % node_num in peer['subver']]:
from_connection.disconnectnode(nodeid=peer_id)
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(lambda: [peer['id'] for peer in from_connection.getpeerinfo() if "testnode%d" % node_num in peer['subver']] == [], timeout=5)

正在加载...
取消
保存