mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
test: add inventory type constant MSG_CMPCT_BLOCK
This commit is contained in:
parent
eeaaa58d2c
commit
b35e1d2471
2 changed files with 5 additions and 4 deletions
|
@ -10,7 +10,7 @@ Version 2 compact blocks are post-segwit (wtxids)
|
|||
import random
|
||||
|
||||
from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment
|
||||
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
|
||||
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
|
||||
from test_framework.mininode import mininode_lock, P2PInterface
|
||||
from test_framework.script import CScript, OP_TRUE, OP_DROP
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
|
@ -307,7 +307,7 @@ class CompactBlocksTest(BitcoinTestFramework):
|
|||
# Now fetch the compact block using a normal non-announce getdata
|
||||
with mininode_lock:
|
||||
test_node.clear_block_announcement()
|
||||
inv = CInv(4, block_hash) # 4 == "CompactBlock"
|
||||
inv = CInv(MSG_CMPCT_BLOCK, block_hash)
|
||||
test_node.send_message(msg_getdata([inv]))
|
||||
|
||||
wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)
|
||||
|
@ -634,7 +634,7 @@ class CompactBlocksTest(BitcoinTestFramework):
|
|||
wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)
|
||||
|
||||
test_node.clear_block_announcement()
|
||||
test_node.send_message(msg_getdata([CInv(4, int(new_blocks[0], 16))]))
|
||||
test_node.send_message(msg_getdata([CInv(MSG_CMPCT_BLOCK, int(new_blocks[0], 16))]))
|
||||
wait_until(lambda: "cmpctblock" in test_node.last_message, timeout=30, lock=mininode_lock)
|
||||
|
||||
test_node.clear_block_announcement()
|
||||
|
@ -643,7 +643,7 @@ class CompactBlocksTest(BitcoinTestFramework):
|
|||
test_node.clear_block_announcement()
|
||||
with mininode_lock:
|
||||
test_node.last_message.pop("block", None)
|
||||
test_node.send_message(msg_getdata([CInv(4, int(new_blocks[0], 16))]))
|
||||
test_node.send_message(msg_getdata([CInv(MSG_CMPCT_BLOCK, int(new_blocks[0], 16))]))
|
||||
wait_until(lambda: "block" in test_node.last_message, timeout=30, lock=mininode_lock)
|
||||
with mininode_lock:
|
||||
test_node.last_message["block"].block.calc_sha256()
|
||||
|
|
|
@ -54,6 +54,7 @@ NODE_NETWORK_LIMITED = (1 << 10)
|
|||
MSG_TX = 1
|
||||
MSG_BLOCK = 2
|
||||
MSG_FILTERED_BLOCK = 3
|
||||
MSG_CMPCT_BLOCK = 4
|
||||
MSG_WITNESS_FLAG = 1 << 30
|
||||
MSG_TYPE_MASK = 0xffffffff >> 2
|
||||
|
||||
|
|
Loading…
Reference in a new issue