Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-get-invalid-block.py
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# are not on the currently active chain. This is the only logged | # are not on the currently active chain. This is the only logged | ||||
# indication of such. | # indication of such. | ||||
with node.assert_debug_log(expected_msgs=["getblocks -1 to"]): | with node.assert_debug_log(expected_msgs=["getblocks -1 to"]): | ||||
msg = msg_getblocks() | msg = msg_getblocks() | ||||
msg.locator.vHave = [block_hash] | msg.locator.vHave = [block_hash] | ||||
peer.send_message(msg) | peer.send_message(msg) | ||||
peer.sync_with_ping() | peer.sync_with_ping() | ||||
with node.assert_debug_log(expected_msgs=["ignoring request from peer=0 for old block that isn't in the main chain"]): | with node.assert_debug_log( | ||||
expected_msgs=[ | |||||
"ignoring request from peer=0 for old block that isn't in the main" | |||||
" chain" | |||||
] | |||||
): | |||||
msg = msg_getdata() | msg = msg_getdata() | ||||
msg.inv.append(CInv(MSG_BLOCK, block_hash)) | msg.inv.append(CInv(MSG_BLOCK, block_hash)) | ||||
peer.send_message(msg) | peer.send_message(msg) | ||||
peer.sync_with_ping() | peer.sync_with_ping() | ||||
with node.assert_debug_log(expected_msgs=["ignoring request from peer=0 for old block that isn't in the main chain"]): | with node.assert_debug_log( | ||||
expected_msgs=[ | |||||
"ignoring request from peer=0 for old block that isn't in the main" | |||||
" chain" | |||||
] | |||||
): | |||||
msg = msg_getdata() | msg = msg_getdata() | ||||
msg.inv.append(CInv(MSG_CMPCT_BLOCK, block_hash)) | msg.inv.append(CInv(MSG_CMPCT_BLOCK, block_hash)) | ||||
peer.send_message(msg) | peer.send_message(msg) | ||||
peer.sync_with_ping() | peer.sync_with_ping() | ||||
with node.assert_debug_log(expected_msgs=["ignoring request from peer=0 for old block header that isn't in the main chain"]): | with node.assert_debug_log( | ||||
expected_msgs=[ | |||||
"ignoring request from peer=0 for old block header that isn't in" | |||||
" the main chain" | |||||
] | |||||
): | |||||
msg = msg_getheaders() | msg = msg_getheaders() | ||||
msg.hashstop = block_hash | msg.hashstop = block_hash | ||||
peer.send_message(msg) | peer.send_message(msg) | ||||
peer.sync_with_ping() | peer.sync_with_ping() | ||||
if __name__ == '__main__': | if __name__ == "__main__": | ||||
GetInvalidBlockTest().main() | GetInvalidBlockTest().main() |