[test] Test that -blocksonly nodes still serve compact blocks.

pull/22340/head
Niklas Gögge 3 years ago
parent a79ad65fc2
commit 18c5b23a0f

@ -13,6 +13,7 @@ from test_framework.messages import (
CInv, CInv,
from_hex, from_hex,
msg_block, msg_block,
msg_getdata,
msg_headers, msg_headers,
msg_sendcmpct, msg_sendcmpct,
) )
@ -107,5 +108,23 @@ class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
p2p_conn_low_bw.sync_with_ping() p2p_conn_low_bw.sync_with_ping()
assert_equal(p2p_conn_low_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)]) assert_equal(p2p_conn_low_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)])
self.log.info("Test that -blocksonly nodes still serve compact blocks")
def test_for_cmpctblock(block):
if 'cmpctblock' not in p2p_conn_blocksonly.last_message:
return False
return p2p_conn_blocksonly.last_message['cmpctblock'].header_and_shortids.header.rehash() == block.sha256
p2p_conn_blocksonly.send_message(msg_getdata([CInv(MSG_CMPCT_BLOCK, block0.sha256)]))
p2p_conn_blocksonly.wait_until(lambda: test_for_cmpctblock(block0))
# Request BIP152 high bandwidth mode from the -blocksonly node.
p2p_conn_blocksonly.send_and_ping(msg_sendcmpct(announce=True, version=2))
block2 = self.build_block_on_tip()
self.nodes[0].submitblock(block1.serialize().hex())
self.nodes[0].submitblock(block2.serialize().hex())
p2p_conn_blocksonly.wait_until(lambda: test_for_cmpctblock(block2))
if __name__ == '__main__': if __name__ == '__main__':
P2PCompactBlocksBlocksOnly().main() P2PCompactBlocksBlocksOnly().main()

Loading…
Cancel
Save