aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p-leaktests.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/p2p-leaktests.py')
-rwxr-xr-xtest/functional/p2p-leaktests.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/test/functional/p2p-leaktests.py b/test/functional/p2p-leaktests.py
index 5611c876ae..1dc8f72cd6 100755
--- a/test/functional/p2p-leaktests.py
+++ b/test/functional/p2p-leaktests.py
@@ -92,8 +92,7 @@ class CNodeNoVerackIdle(CLazyNode):
conn.send_message(msg_getaddr())
class P2PLeakTest(BitcoinTestFramework):
- def __init__(self):
- super().__init__()
+ def set_test_params(self):
self.num_nodes = 1
self.extra_args = [['-banscore='+str(banscore)]]
@@ -119,11 +118,11 @@ class P2PLeakTest(BitcoinTestFramework):
NetworkThread().start() # Start up network handling in another thread
- assert wait_until(lambda: no_version_bannode.ever_connected, timeout=10)
- assert wait_until(lambda: no_version_idlenode.ever_connected, timeout=10)
- assert wait_until(lambda: no_verack_idlenode.version_received, timeout=10)
- assert wait_until(lambda: unsupported_service_bit5_node.ever_connected, timeout=10)
- assert wait_until(lambda: unsupported_service_bit7_node.ever_connected, timeout=10)
+ wait_until(lambda: no_version_bannode.ever_connected, timeout=10, lock=mininode_lock)
+ wait_until(lambda: no_version_idlenode.ever_connected, timeout=10, lock=mininode_lock)
+ wait_until(lambda: no_verack_idlenode.version_received, timeout=10, lock=mininode_lock)
+ wait_until(lambda: unsupported_service_bit5_node.ever_connected, timeout=10, lock=mininode_lock)
+ wait_until(lambda: unsupported_service_bit7_node.ever_connected, timeout=10, lock=mininode_lock)
# Mine a block and make sure that it's not sent to the connected nodes
self.nodes[0].generate(1)
@@ -140,6 +139,9 @@ class P2PLeakTest(BitcoinTestFramework):
[conn.disconnect_node() for conn in connections]
+ # Wait until all connections are closed
+ wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 0)
+
# Make sure no unexpected messages came in
assert(no_version_bannode.unexpected_msg == False)
assert(no_version_idlenode.unexpected_msg == False)
@@ -158,8 +160,10 @@ class P2PLeakTest(BitcoinTestFramework):
allowed_service_bit5_node.add_connection(connections[5])
allowed_service_bit7_node.add_connection(connections[6])
- assert wait_until(lambda: allowed_service_bit5_node.message_count["verack"], timeout=10)
- assert wait_until(lambda: allowed_service_bit7_node.message_count["verack"], timeout=10)
+ NetworkThread().start() # Network thread stopped when all previous NodeConnCBs disconnected. Restart it
+
+ wait_until(lambda: allowed_service_bit5_node.message_count["verack"], lock=mininode_lock)
+ wait_until(lambda: allowed_service_bit7_node.message_count["verack"], lock=mininode_lock)
if __name__ == '__main__':
P2PLeakTest().main()