mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-03 12:11:52 +02:00
qa: Check specific reject reasons in feature_block
This commit is contained in:
@ -511,14 +511,14 @@ class P2PDataStore(P2PInterface):
|
||||
if response is not None:
|
||||
self.send_message(response)
|
||||
|
||||
def send_blocks_and_test(self, blocks, node, *, success=True, request_block=True, reject_reason=None, expect_disconnect=False, timeout=60):
|
||||
def send_blocks_and_test(self, blocks, node, *, success=True, force_send=False, reject_reason=None, expect_disconnect=False, timeout=60):
|
||||
"""Send blocks to test node and test whether the tip advances.
|
||||
|
||||
- add all blocks to our block_store
|
||||
- send a headers message for the final block
|
||||
- the on_getheaders handler will ensure that any getheaders are responded to
|
||||
- if request_block is True: wait for getdata for each of the blocks. The on_getdata handler will
|
||||
ensure that any getdata messages are responded to
|
||||
- if force_send is False: wait for getdata for each of the blocks. The on_getdata handler will
|
||||
ensure that any getdata messages are responded to. Otherwise send the full block unsolicited.
|
||||
- if success is True: assert that the node's tip advances to the most recent block
|
||||
- if success is False: assert that the node's tip doesn't advance
|
||||
- if reject_reason is set: assert that the correct reject message is logged"""
|
||||
@ -530,9 +530,11 @@ class P2PDataStore(P2PInterface):
|
||||
|
||||
reject_reason = [reject_reason] if reject_reason else []
|
||||
with node.assert_debug_log(expected_msgs=reject_reason):
|
||||
self.send_message(msg_headers([CBlockHeader(blocks[-1])]))
|
||||
|
||||
if request_block:
|
||||
if force_send:
|
||||
for b in blocks:
|
||||
self.send_message(msg_block(block=b))
|
||||
else:
|
||||
self.send_message(msg_headers([CBlockHeader(blocks[-1])]))
|
||||
wait_until(lambda: blocks[-1].sha256 in self.getdata_requests, timeout=timeout, lock=mininode_lock)
|
||||
|
||||
if expect_disconnect:
|
||||
|
Reference in New Issue
Block a user