mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
Merge bitcoin/bitcoin#33858: test: add unit test coverage for the empty leaves path in MerkleComputation
ffcae82a68test: exercise TransactionMerklePath with empty block; targets the MerkleComputation empty-leaves path that was only reached by fuzz tests (frankomosh) Pull request description: As noted in [#32243 (comment)](https://github.com/bitcoin/bitcoin/pull/32243#issuecomment-2988854482), the early return inside `MerkleComputation` when `leaves.size() == 0` was only exercised by fuzz tests. The existing `merkle_test_empty_block` calls `BlockMerkleRoot`, which uses `ComputeMerkleRoot`, but does not exercise the `TransactionMerklePath` → `ComputeMerklePath` → `MerkleComputation` code path. Coverage before adding test: <img width="2459" height="66" alt="before" src="https://github.com/user-attachments/assets/ca94015a-d7c2-4281-ac60-13b22f177b67" /> Coverage after adding test: <img width="2459" height="66" alt="after" src="https://github.com/user-attachments/assets/b1d4e1bb-af72-46ab-8898-f18db39dd2fb" /> ACKs for top commit: kevkevinpal: ACK [ffcae82](ffcae82a68) maflcko: lgtm ACKffcae82a68brunoerg: code review ACKffcae82a68sedited: ACKffcae82a68Tree-SHA512: d2499d91269c4f4f9a86011f7ad13f675834662a5bd37b0e7cbe887a7d9acf4170e53f0bdc528011fc82866b9c1dec34f4e7e9cd64cc3100591c1580a4df5d00
This commit is contained in:
@@ -154,6 +154,11 @@ BOOST_AUTO_TEST_CASE(merkle_test_empty_block)
|
||||
|
||||
BOOST_CHECK_EQUAL(root.IsNull(), true);
|
||||
BOOST_CHECK_EQUAL(mutated, false);
|
||||
|
||||
// Verify TransactionMerklePath handles empty block correctly
|
||||
// This tests the early-return path in MerkleComputation
|
||||
std::vector<uint256> merkle_path = TransactionMerklePath(block, 0);
|
||||
BOOST_CHECK(merkle_path.empty());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(merkle_test_oneTx_block)
|
||||
|
||||
Reference in New Issue
Block a user