Skip to content

Commit ae54485

Browse files
committed
[test] Test that -blocksonly nodes still serve compact blocks.
1 parent c652e18 commit ae54485

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/functional/p2p_compactblocks_blocksonly.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
CInv,
1414
from_hex,
1515
msg_block,
16+
msg_getdata,
1617
msg_headers,
1718
msg_sendcmpct,
1819
)
@@ -106,5 +107,23 @@ def run_test(self):
106107
p2p_conn_low_bw.sync_with_ping()
107108
assert_equal(p2p_conn_low_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)])
108109

110+
self.log.info("Test that -blocksonly nodes still serve compact blocks.")
111+
112+
def test_for_cmpctblock(block):
113+
if 'cmpctblock' not in p2p_conn_blocksonly.last_message:
114+
return False
115+
return p2p_conn_blocksonly.last_message['cmpctblock'].header_and_shortids.header.rehash() == block.sha256
116+
117+
p2p_conn_blocksonly.send_message(msg_getdata([CInv(MSG_CMPCT_BLOCK, block0.sha256)]))
118+
p2p_conn_blocksonly.wait_until(lambda: test_for_cmpctblock(block0))
119+
120+
# Request BIP152 high bandwidth mode from the -blocksonly node.
121+
p2p_conn_blocksonly.send_and_ping(msg_sendcmpct(announce=True, version=2))
122+
123+
block2 = self.build_block_on_tip()
124+
self.nodes[0].submitblock(block1.serialize().hex())
125+
self.nodes[0].submitblock(block2.serialize().hex())
126+
p2p_conn_blocksonly.wait_until(lambda: test_for_cmpctblock(block2))
127+
109128
if __name__ == '__main__':
110129
P2PCompactBlocksBlocksOnly().main()

0 commit comments

Comments
 (0)