diff options
author | Niklas Gögge <n.goeggi@gmail.com> | 2021-08-09 21:17:57 +0200 |
---|---|---|
committer | Niklas Gögge <n.goeggi@gmail.com> | 2021-09-28 22:11:30 +0200 |
commit | a79ad65fc2c31a2b1132a6aab389d0197a95c395 (patch) | |
tree | 5ab7d33992413f52ba7075c2736d80a670cd5d8a /test/functional | |
parent | 5e231c116ba8165e9d8c795b85ca2833238aed54 (diff) |
[test] Test that getdata(CMPCT) is still sent on regular low bandwidth connections.
Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
Diffstat (limited to 'test/functional')
-rwxr-xr-x | test/functional/p2p_compactblocks_blocksonly.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/test/functional/p2p_compactblocks_blocksonly.py b/test/functional/p2p_compactblocks_blocksonly.py index f690fce0d6..93164d3034 100755 --- a/test/functional/p2p_compactblocks_blocksonly.py +++ b/test/functional/p2p_compactblocks_blocksonly.py @@ -23,8 +23,8 @@ from test_framework.util import assert_equal class P2PCompactBlocksBlocksOnly(BitcoinTestFramework): def set_test_params(self): - self.extra_args = [["-blocksonly"], [], []] - self.num_nodes = 3 + self.extra_args = [["-blocksonly"], [], [], []] + self.num_nodes = 4 def setup_network(self): self.setup_nodes() @@ -45,7 +45,8 @@ class P2PCompactBlocksBlocksOnly(BitcoinTestFramework): p2p_conn_blocksonly = self.nodes[0].add_p2p_connection(P2PInterface()) p2p_conn_high_bw = self.nodes[1].add_p2p_connection(P2PInterface()) - for conn in [p2p_conn_blocksonly, p2p_conn_high_bw]: + p2p_conn_low_bw = self.nodes[3].add_p2p_connection(P2PInterface()) + for conn in [p2p_conn_blocksonly, p2p_conn_high_bw, p2p_conn_low_bw]: assert_equal(conn.message_count['sendcmpct'], 2) conn.send_and_ping(msg_sendcmpct(announce=False, version=2)) @@ -53,10 +54,12 @@ class P2PCompactBlocksBlocksOnly(BitcoinTestFramework): # 0 -> blocksonly # 1 -> high bandwidth # 2 -> miner + # 3 -> low bandwidth # # Topology: # p2p_conn_blocksonly ---> node0 # p2p_conn_high_bw ---> node1 + # p2p_conn_low_bw ---> node3 # node2 (no connections) # # node2 produces blocks that are passed to the rest of the nodes @@ -80,6 +83,10 @@ class P2PCompactBlocksBlocksOnly(BitcoinTestFramework): p2p_conn_high_bw.wait_until(lambda: p2p_conn_high_bw.message_count['sendcmpct'] == 3) assert_equal(p2p_conn_high_bw.last_message['sendcmpct'].announce, True) + # Don't send a block from the p2p_conn_low_bw so the low bandwidth node + # doesn't select it for BIP152 high bandwidth relay. + self.nodes[3].submitblock(block0.serialize().hex()) + self.log.info("Test that -blocksonly nodes send getdata(BLOCK) instead" " of getdata(CMPCT) in BIP152 low bandwidth mode") @@ -93,5 +100,12 @@ class P2PCompactBlocksBlocksOnly(BitcoinTestFramework): p2p_conn_high_bw.sync_send_with_ping() assert_equal(p2p_conn_high_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)]) + self.log.info("Test that getdata(CMPCT) is still sent on BIP152 low bandwidth connections" + " when no -blocksonly nodes are involved") + + p2p_conn_low_bw.send_and_ping(msg_headers(headers=[CBlockHeader(block1)])) + p2p_conn_low_bw.sync_with_ping() + assert_equal(p2p_conn_low_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)]) + if __name__ == '__main__': P2PCompactBlocksBlocksOnly().main() |