mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
test: check for matching object hashes in wait_for_getdata
This commit is contained in:
@@ -406,17 +406,17 @@ class P2PInterface(P2PConnection):
|
||||
|
||||
wait_until(test_function, timeout=timeout, lock=mininode_lock)
|
||||
|
||||
def wait_for_getdata(self, timeout=60):
|
||||
def wait_for_getdata(self, hash_list, timeout=60):
|
||||
"""Waits for a getdata message.
|
||||
|
||||
Receiving any getdata message will satisfy the predicate. the last_message["getdata"]
|
||||
value must be explicitly cleared before calling this method, or this will return
|
||||
immediately with success. TODO: change this method to take a hash value and only
|
||||
return true if the correct block/tx has been requested."""
|
||||
The object hashes in the inventory vector must match the provided hash_list."""
|
||||
|
||||
def test_function():
|
||||
assert self.is_connected
|
||||
return self.last_message.get("getdata")
|
||||
last_data = self.last_message.get("getdata")
|
||||
if not last_data:
|
||||
return False
|
||||
return [x.hash for x in last_data.inv] == hash_list
|
||||
|
||||
wait_until(test_function, timeout=timeout, lock=mininode_lock)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user