Skip to content

Commit 2c6a02e

Browse files
committed
Clean message_count and last_message
This commit clarifies the intended usage of message_count and last_message. Additionally it changes the only usage of message_count to using last_message instead, bringing the code further along the intended usage.
1 parent 31d2b40 commit 2c6a02e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/functional/test_framework/mininode.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,13 @@ class P2PInterface(P2PConnection):
283283
def __init__(self):
284284
super().__init__()
285285

286-
# Track number of messages of each type received and the most recent
287-
# message of each type
286+
# Track number of messages of each type received.
287+
# Should be read-only in a test.
288288
self.message_count = defaultdict(int)
289+
290+
# Track the most recent message of each type.
291+
# To wait for a message to be received, pop that message from
292+
# this and use wait_until.
289293
self.last_message = {}
290294

291295
# A count of the number of ping messages we've sent to the node
@@ -472,7 +476,7 @@ def test_function():
472476

473477
def wait_for_verack(self, timeout=60):
474478
def test_function():
475-
return self.message_count["verack"]
479+
return "verack" in self.last_message
476480

477481
self.wait_until(test_function, timeout=timeout)
478482

0 commit comments

Comments
 (0)