test: exercise TransactionMerklePath with empty block; targets the MerkleComputation empty-leaves path that was only reached by fuzz tests
What changed, and why it matters
This commit only adds a new test case to Bitcoin Core's test suite. It checks that when a block has no transactions, a helper function called TransactionMerklePath returns an empty path. There is no change to production code, no bug fix, and no security-relevant behavior change.
No action needed; this is a test-only addition. Routine review/merge is sufficient.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds four lines to src/test/merkle_tests.cpp inside the merkle_test_empty_block test. It calls TransactionMerklePath(block, 0) on an empty block and asserts the returned vector is empty. The commit message says this exercises the MerkleComputation empty-leaves path that previously was only reached by fuzz tests. No implementation code is modified.
Changed components
src/test/merkle_tests.cppInspect captured patch +5 / −0
diff --git a/src/test/merkle_tests.cpp b/src/test/merkle_tests.cpp
index cad23321..649da07c 100644
--- a/src/test/merkle_tests.cpp
+++ b/src/test/merkle_tests.cpp
@@ -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)
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.