Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/mininode.py
Show First 20 Lines • Show All 482 Lines • ▼ Show 20 Lines | def wait_for_merkleblock(self, blockhash, timeout=60): | ||||
assert self.is_connected | assert self.is_connected | ||||
last_filtered_block = self.last_message.get('merkleblock') | last_filtered_block = self.last_message.get('merkleblock') | ||||
if not last_filtered_block: | if not last_filtered_block: | ||||
return False | return False | ||||
return last_filtered_block.merkleblock.header.rehash() == int(blockhash, 16) | return last_filtered_block.merkleblock.header.rehash() == int(blockhash, 16) | ||||
wait_until(test_function, timeout=timeout, lock=mininode_lock) | 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. | """Waits for a getdata message. | ||||
Receiving any getdata message will satisfy the predicate. the last_message["getdata"] | The object hashes in the inventory vector must match the provided hash_list.""" | ||||
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.""" | |||||
def test_function(): | def test_function(): | ||||
assert self.is_connected | 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) | wait_until(test_function, timeout=timeout, lock=mininode_lock) | ||||
def wait_for_getheaders(self, timeout=60): | def wait_for_getheaders(self, timeout=60): | ||||
"""Waits for a getheaders message. | """Waits for a getheaders message. | ||||
Receiving any getheaders message will satisfy the predicate. the last_message["getheaders"] | Receiving any getheaders message will satisfy the predicate. the last_message["getheaders"] | ||||
value must be explicitly cleared before calling this method, or this will return | value must be explicitly cleared before calling this method, or this will return | ||||
▲ Show 20 Lines • Show All 229 Lines • Show Last 20 Lines |