|
10 | 10 | import random
|
11 | 11 |
|
12 | 12 | 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_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_WITNESS_FLAG, NODE_NETWORK, P2PHeaderAndShortIDs, PrefilledTransaction, ser_uint256, ToHex |
14 | 14 | from test_framework.mininode import mininode_lock, P2PInterface
|
15 | 15 | from test_framework.script import CScript, OP_TRUE, OP_DROP
|
16 | 16 | from test_framework.test_framework import BitcoinTestFramework
|
@@ -44,7 +44,7 @@ def on_headers(self, message):
|
44 | 44 |
|
45 | 45 | def on_inv(self, message):
|
46 | 46 | for x in self.last_message["inv"].inv:
|
47 |
| - if x.type == 2: |
| 47 | + if x.type == MSG_BLOCK: |
48 | 48 | self.block_announced = True
|
49 | 49 | self.announced_blockhashes.add(x.hash)
|
50 | 50 |
|
@@ -380,7 +380,7 @@ def test_compactblock_requests(self, test_node, segwit=True):
|
380 | 380 | block = self.build_block_on_tip(node, segwit=segwit)
|
381 | 381 |
|
382 | 382 | if announce == "inv":
|
383 |
| - test_node.send_message(msg_inv([CInv(2, block.sha256)])) |
| 383 | + test_node.send_message(msg_inv([CInv(MSG_BLOCK, block.sha256)])) |
384 | 384 | wait_until(lambda: "getheaders" in test_node.last_message, timeout=30, lock=mininode_lock)
|
385 | 385 | test_node.send_header_for_blocks([block])
|
386 | 386 | else:
|
@@ -564,7 +564,8 @@ def test_incorrect_blocktxn_response(self, test_node):
|
564 | 564 |
|
565 | 565 | # We should receive a getdata request
|
566 | 566 | test_node.wait_for_getdata([block.sha256], timeout=10)
|
567 |
| - assert test_node.last_message["getdata"].inv[0].type == 2 or test_node.last_message["getdata"].inv[0].type == 2 | MSG_WITNESS_FLAG |
| 567 | + assert test_node.last_message["getdata"].inv[0].type == MSG_BLOCK or \ |
| 568 | + test_node.last_message["getdata"].inv[0].type == MSG_BLOCK | MSG_WITNESS_FLAG |
568 | 569 |
|
569 | 570 | # Deliver the block
|
570 | 571 | if version == 2:
|
|
0 commit comments