Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_sendheaders.py
Show First 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | def send_header_for_blocks(self, new_blocks): | ||||
headers_message.headers = [CBlockHeader(b) for b in new_blocks] | headers_message.headers = [CBlockHeader(b) for b in new_blocks] | ||||
self.send_message(headers_message) | self.send_message(headers_message) | ||||
def send_getblocks(self, locator): | def send_getblocks(self, locator): | ||||
getblocks_message = msg_getblocks() | getblocks_message = msg_getblocks() | ||||
getblocks_message.locator.vHave = locator | getblocks_message.locator.vHave = locator | ||||
self.send_message(getblocks_message) | self.send_message(getblocks_message) | ||||
def wait_for_getdata(self, hash_list, timeout=60): | |||||
if hash_list == []: | |||||
return | |||||
def test_function(): return "getdata" in self.last_message and [ | |||||
x.hash for x in self.last_message["getdata"].inv] == hash_list | |||||
wait_until(test_function, timeout=timeout, lock=mininode_lock) | |||||
def wait_for_block_announcement(self, block_hash, timeout=60): | def wait_for_block_announcement(self, block_hash, timeout=60): | ||||
def test_function(): return self.last_blockhash_announced == block_hash | def test_function(): return self.last_blockhash_announced == block_hash | ||||
wait_until(test_function, timeout=timeout, lock=mininode_lock) | wait_until(test_function, timeout=timeout, lock=mininode_lock) | ||||
def on_inv(self, message): | def on_inv(self, message): | ||||
self.block_announced = True | self.block_announced = True | ||||
self.last_blockhash_announced = message.inv[-1].hash | self.last_blockhash_announced = message.inv[-1].hash | ||||
▲ Show 20 Lines • Show All 481 Lines • Show Last 20 Lines |