test_invalid_tx_in_compactblock
tests that we don’t get disconnected if we relay a compact block with valid header, but invalid transactions.
In this test, after sending the block with invalid transactions, this test checks two things: the tip in the receiver node did not advance and the sender did not get disconnected. However, even if the block contains only valid transactions, the tip would not advance because the receiver does not have all transactions to reconstruct the valid and would request them back. This PR fixes it by sending all the transactions.
Also, comparing block hash (int) using is not
can lead to subtle bugs, this PR fixes it by replacing it to !=
.
Can be tested by applying:
0diff --git a/test/functional/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py
1index 274ef9532c..419153a32f 100755
2--- a/test/functional/p2p_compactblocks.py
3+++ b/test/functional/p2p_compactblocks.py
4@@ -723,11 +723,8 @@ class CompactBlocksTest(BitcoinTestFramework):
5 utxo = self.utxos[0]
6
7 block = self.build_block_with_transactions(node, utxo, 5)
8- del block.vtx[3]
9 block.hashMerkleRoot = block.calc_merkle_root()
10 # Drop the coinbase witness but include the witness commitment.
11- add_witness_commitment(block)
12- block.vtx[0].wit.vtxinwit = []
13 block.solve()
14
15 # Make sure node has the transactions to reconstruct the block