Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge bitcoin#31406: test: fix
test_invalid_tx_in_compactblock
in `…
…p2p_compactblocks` 7239ddb test: make sure node has all transactions (brunoerg) ee1b9be test: replace `is not` to `!=` when comparing block hash (brunoerg) Pull request description: `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: ```diff diff --git a/test/functional/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py index 274ef9532c..419153a32f 100755 --- a/test/functional/p2p_compactblocks.py +++ b/test/functional/p2p_compactblocks.py @@ -723,11 +723,8 @@ class CompactBlocksTest(BitcoinTestFramework): utxo = self.utxos[0] block = self.build_block_with_transactions(node, utxo, 5) - del block.vtx[3] block.hashMerkleRoot = block.calc_merkle_root() # Drop the coinbase witness but include the witness commitment. - add_witness_commitment(block) - block.vtx[0].wit.vtxinwit = [] block.solve() # Make sure node has the transactions to reconstruct the block ``` ACKs for top commit: instagibbs: ACK 7239ddb glozow: ACK 7239ddb lucasbalieiro: Tested ACK for commit [7239ddb](bitcoin@7239ddb) Tree-SHA512: 6d04fb7c50b5e635c83ede75c12130cbd8e1b229887a86a2e1bfe747e4208731faecc7265cae063c1ace187b20c5f37080d5116760766fa2948f38971e5f6fbf
- Loading branch information