Skip to content

Commit aeb9fb4

Browse files
committed
[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.
1 parent e81942d commit aeb9fb4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/functional/test_framework/test_node.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
from .authproxy import JSONRPCException
2525
from .descriptors import descsum_create
26+
from .messages import MY_SUBVERSION
2627
from .util import (
2728
MAX_NODES,
2829
append_config,
@@ -549,11 +550,16 @@ def p2p(self):
549550
assert self.p2ps, self._node_msg("No p2p connection")
550551
return self.p2ps[0]
551552

553+
def num_connected_mininodes(self):
554+
"""Return number of test framework p2p connections to the node."""
555+
return len([peer for peer in self.getpeerinfo() if peer['subver'] == MY_SUBVERSION])
556+
552557
def disconnect_p2ps(self):
553558
"""Close all p2p connections to the node."""
554559
for p in self.p2ps:
555560
p.peer_disconnect()
556561
del self.p2ps[:]
562+
wait_until(lambda: self.num_connected_mininodes() == 0)
557563

558564

559565
class TestNodeCLIAttr:

0 commit comments

Comments
 (0)