From 18c5b23a0f7adf9a08bcaa967ed800badf62d90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20G=C3=B6gge?= Date: Mon, 9 Aug 2021 21:54:02 +0200 Subject: [PATCH] [test] Test that -blocksonly nodes still serve compact blocks. --- .../p2p_compactblocks_blocksonly.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/functional/p2p_compactblocks_blocksonly.py b/test/functional/p2p_compactblocks_blocksonly.py index 93164d30344..4073ec03a69 100755 --- a/test/functional/p2p_compactblocks_blocksonly.py +++ b/test/functional/p2p_compactblocks_blocksonly.py @@ -13,6 +13,7 @@ from test_framework.messages import ( CInv, from_hex, msg_block, + msg_getdata, msg_headers, msg_sendcmpct, ) @@ -107,5 +108,23 @@ class P2PCompactBlocksBlocksOnly(BitcoinTestFramework): p2p_conn_low_bw.sync_with_ping() 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__': P2PCompactBlocksBlocksOnly().main()