Skip to content

Commit b35e1d2

Browse files
committed
test: add inventory type constant MSG_CMPCT_BLOCK
1 parent eeaaa58 commit b35e1d2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

test/functional/p2p_compactblocks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import random
1111

1212
from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment
13-
from test_framework.messages import BlockTransactions, BlockTransactionsRequest, calculate_shortid, CBlock, CBlockHeader, CInv, COutPoint, CTransaction, CTxIn, CTxInWitness, CTxOut, FromHex, HeaderAndShortIDs, msg_no_witness_block, msg_no_witness_blocktxn, msg_cmpctblock, msg_getblocktxn, msg_getdata, msg_getheaders, msg_headers, msg_inv, msg_sendcmpct, msg_sendheaders, msg_tx, msg_block, msg_blocktxn, MSG_BLOCK, MSG_WITNESS_FLAG, NODE_NETWORK, P2PHeaderAndShortIDs, PrefilledTransaction, ser_uint256, ToHex
13+
from test_framework.messages import BlockTransactions, BlockTransactionsRequest, calculate_shortid, CBlock, CBlockHeader, CInv, COutPoint, CTransaction, CTxIn, CTxInWitness, CTxOut, FromHex, HeaderAndShortIDs, msg_no_witness_block, msg_no_witness_blocktxn, msg_cmpctblock, msg_getblocktxn, msg_getdata, msg_getheaders, msg_headers, msg_inv, msg_sendcmpct, msg_sendheaders, msg_tx, msg_block, msg_blocktxn, MSG_BLOCK, MSG_CMPCT_BLOCK, MSG_WITNESS_FLAG, NODE_NETWORK, P2PHeaderAndShortIDs, PrefilledTransaction, ser_uint256, ToHex
1414
from test_framework.mininode import mininode_lock, P2PInterface
1515
from test_framework.script import CScript, OP_TRUE, OP_DROP
1616
from test_framework.test_framework import BitcoinTestFramework
@@ -307,7 +307,7 @@ def test_compactblock_construction(self, test_node, use_witness_address=True):
307307
# Now fetch the compact block using a normal non-announce getdata
308308
with mininode_lock:
309309
test_node.clear_block_announcement()
310-
inv = CInv(4, block_hash) # 4 == "CompactBlock"
310+
inv = CInv(MSG_CMPCT_BLOCK, block_hash)
311311
test_node.send_message(msg_getdata([inv]))
312312

313313
wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)
@@ -634,7 +634,7 @@ def test_compactblocks_not_at_tip(self, test_node):
634634
wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)
635635

636636
test_node.clear_block_announcement()
637-
test_node.send_message(msg_getdata([CInv(4, int(new_blocks[0], 16))]))
637+
test_node.send_message(msg_getdata([CInv(MSG_CMPCT_BLOCK, int(new_blocks[0], 16))]))
638638
wait_until(lambda: "cmpctblock" in test_node.last_message, timeout=30, lock=mininode_lock)
639639

640640
test_node.clear_block_announcement()
@@ -643,7 +643,7 @@ def test_compactblocks_not_at_tip(self, test_node):
643643
test_node.clear_block_announcement()
644644
with mininode_lock:
645645
test_node.last_message.pop("block", None)
646-
test_node.send_message(msg_getdata([CInv(4, int(new_blocks[0], 16))]))
646+
test_node.send_message(msg_getdata([CInv(MSG_CMPCT_BLOCK, int(new_blocks[0], 16))]))
647647
wait_until(lambda: "block" in test_node.last_message, timeout=30, lock=mininode_lock)
648648
with mininode_lock:
649649
test_node.last_message["block"].block.calc_sha256()

test/functional/test_framework/messages.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
MSG_TX = 1
5555
MSG_BLOCK = 2
5656
MSG_FILTERED_BLOCK = 3
57+
MSG_CMPCT_BLOCK = 4
5758
MSG_WITNESS_FLAG = 1 << 30
5859
MSG_TYPE_MASK = 0xffffffff >> 2
5960

0 commit comments

Comments
 (0)