aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/mininode.py
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2017-12-08 10:00:33 -0500
committerJohn Newbery <john@johnnewbery.com>2017-12-11 09:17:21 -0500
commit5c8ff26b2fc59d8bcfa2a8bfb7c9fe6d78cf6678 (patch)
treefe0bfdb8c657ba5cef79f0067e3781a89e4f8a8f /test/functional/test_framework/mininode.py
parent34e08b3510c64e35fc51327562d15d938f4b656e (diff)
downloadbitcoin-5c8ff26b2fc59d8bcfa2a8bfb7c9fe6d78cf6678.tar.xz
[tests] Add NetworkThread assertions
Check that P2PConnections aren't created after the NetworkThread has started and that at any time only one NetworkThread is running.
Diffstat (limited to 'test/functional/test_framework/mininode.py')
-rwxr-xr-xtest/functional/test_framework/mininode.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py
index a00fc3d43c..724d418099 100755
--- a/test/functional/test_framework/mininode.py
+++ b/test/functional/test_framework/mininode.py
@@ -69,6 +69,10 @@ class P2PConnection(asyncore.dispatcher):
sub-classed and the on_message() callback overridden."""
def __init__(self):
+ # All P2PConnections must be created before starting the NetworkThread.
+ # assert that the network thread is not running.
+ assert not network_thread_running()
+
super().__init__(map=mininode_socket_map)
def peer_connect(self, dstaddr, dstport, net="regtest"):
@@ -418,6 +422,9 @@ class NetworkThread(threading.Thread):
def network_thread_start():
"""Start the network thread."""
+ # Only one network thread may run at a time
+ assert not network_thread_running()
+
NetworkThread().start()
def network_thread_running():