diff options
author | Suhas Daftuar <sdaftuar@chaincode.com> | 2016-01-07 09:22:20 -0500 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-01-09 16:32:30 +0100 |
commit | d513405cb71425dd615e88aca4f6222e08d150a5 (patch) | |
tree | 317c440a94cdfc4169ff260152e419e5c0e8d4c2 /qa/rpc-tests/test_framework | |
parent | 4707797df2d41d46a40f59977738e58f87a949fe (diff) | |
download | bitcoin-d513405cb71425dd615e88aca4f6222e08d150a5.tar.xz |
[Tests] Eliminate intermittent failures in sendheaders.py
- Add race-condition debugging tool to mininode
- Eliminate race condition in sendheaders.py test
Clear the last block announcement before mining new blocks.
Github-Pull: #7308
Rebased-From: 82a0ce09b45ab9c09ce4f516be5b9b413dcec470 168915e6dec88b31793d4ee4b60b94d4149de36c
Diffstat (limited to 'qa/rpc-tests/test_framework')
-rwxr-xr-x | qa/rpc-tests/test_framework/mininode.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/qa/rpc-tests/test_framework/mininode.py b/qa/rpc-tests/test_framework/mininode.py index 8e49b56565..ca65fb6e79 100755 --- a/qa/rpc-tests/test_framework/mininode.py +++ b/qa/rpc-tests/test_framework/mininode.py @@ -1004,6 +1004,18 @@ class msg_reject(object): class NodeConnCB(object): def __init__(self): self.verack_received = False + # deliver_sleep_time is helpful for debugging race conditions in p2p + # tests; it causes message delivery to sleep for the specified time + # before acquiring the global lock and delivering the next message. + self.deliver_sleep_time = None + + def set_deliver_sleep_time(self, value): + with mininode_lock: + self.deliver_sleep_time = value + + def get_deliver_sleep_time(self): + with mininode_lock: + return self.deliver_sleep_time # Spin until verack message is received from the node. # Tests may want to use this as a signal that the test can begin. @@ -1017,6 +1029,9 @@ class NodeConnCB(object): time.sleep(0.05) def deliver(self, conn, message): + deliver_sleep = self.get_deliver_sleep_time() + if deliver_sleep is not None: + time.sleep(deliver_sleep) with mininode_lock: try: getattr(self, 'on_' + message.command)(conn, message) |