aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-07-30 09:15:46 +0200
committerMarcoFalke <falke.marco@gmail.com>2020-07-30 09:15:49 +0200
commit149eca433d8060d8ea5bf207322573c037750d92 (patch)
treefa24a4fdad3c03b4c9f8dcfd03e1477bafb0e1f0 /test
parent8db23349fe9b512e6801d59d17052c5a7a1c64df (diff)
parent2c6a02e0248825e205e6deea4c38409044feb4ab (diff)
downloadbitcoin-149eca433d8060d8ea5bf207322573c037750d92.tar.xz
Merge #19599: test: clean message_count and last_message
2c6a02e0248825e205e6deea4c38409044feb4ab Clean message_count and last_message (Troy Giorshev) Pull request description: From #19580 This PR changes comments to clarify the intended usage of `message_count` and `last_message`. Additionally it changes the only usage of `message_count` to use `last_message` instead, bringing the code into alignment with the intended usage. Note: Now `message_count` is completely unused. However, it is ready to be used (i.e. the supporting code works) and likely will be used in some test in the future. ACKs for top commit: jnewbery: utACK 2c6a02e0248825e205e6deea4c38409044feb4ab Tree-SHA512: 07c7684c9586de4f845e10d7aac36c1aab9fb56b409949c1c70d5ca705bc3971ca7d5943245a0472def4efd7b4e1c5dad2f713db5ead8fca08404daf4891e98b
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/test_framework/mininode.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py
index f68c1a9ddd..07811667a8 100755
--- a/test/functional/test_framework/mininode.py
+++ b/test/functional/test_framework/mininode.py
@@ -283,9 +283,13 @@ class P2PInterface(P2PConnection):
def __init__(self):
super().__init__()
- # Track number of messages of each type received and the most recent
- # message of each type
+ # Track number of messages of each type received.
+ # Should be read-only in a test.
self.message_count = defaultdict(int)
+
+ # Track the most recent message of each type.
+ # To wait for a message to be received, pop that message from
+ # this and use wait_until.
self.last_message = {}
# A count of the number of ping messages we've sent to the node
@@ -472,7 +476,7 @@ class P2PInterface(P2PConnection):
def wait_for_verack(self, timeout=60):
def test_function():
- return self.message_count["verack"]
+ return "verack" in self.last_message
self.wait_until(test_function, timeout=timeout)