aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/test_node.py
diff options
context:
space:
mode:
authorgzhao408 <gzhao408@berkeley.edu>2020-06-12 14:54:23 -0700
committergzhao408 <gzhao408@berkeley.edu>2020-06-16 08:26:13 -0700
commitaeb9fb414e2d000830287d9dd3fed7fc2eb570d2 (patch)
treea2e2f74069ea7b07565de9eb27fa83258142eada /test/functional/test_framework/test_node.py
parente81942d2e1288367e8da94adb2b2a88be99e4751 (diff)
downloadbitcoin-aeb9fb414e2d000830287d9dd3fed7fc2eb570d2.tar.xz
[test] wait for disconnect_p2ps to be reflected in getpeerinfo
-Waiting is important to avoid race conditions, especially if testing peer info through rpc later. -Wait for mininodes to be disconnected only, even though it's more complex, because we may still want to be connected to test nodes.
Diffstat (limited to 'test/functional/test_framework/test_node.py')
-rwxr-xr-xtest/functional/test_framework/test_node.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index ebc0501e11..66bb2c89b5 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -23,6 +23,7 @@ import sys
from .authproxy import JSONRPCException
from .descriptors import descsum_create
+from .messages import MY_SUBVERSION
from .util import (
MAX_NODES,
append_config,
@@ -549,11 +550,16 @@ class TestNode():
assert self.p2ps, self._node_msg("No p2p connection")
return self.p2ps[0]
+ def num_connected_mininodes(self):
+ """Return number of test framework p2p connections to the node."""
+ return len([peer for peer in self.getpeerinfo() if peer['subver'] == MY_SUBVERSION])
+
def disconnect_p2ps(self):
"""Close all p2p connections to the node."""
for p in self.p2ps:
p.peer_disconnect()
del self.p2ps[:]
+ wait_until(lambda: self.num_connected_mininodes() == 0)
class TestNodeCLIAttr: