diff --git a/src/test/fuzz/integer.cpp b/src/test/fuzz/integer.cpp index 89c29dbcb70..3effc1c19f0 100644 --- a/src/test/fuzz/integer.cpp +++ b/src/test/fuzz/integer.cpp @@ -80,8 +80,8 @@ FUZZ_TARGET(integer, .init = initialize_integer) } constexpr uint256 u256_min{"0000000000000000000000000000000000000000000000000000000000000000"}; constexpr uint256 u256_max{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"}; - const std::vector v256{u256, u256_min, u256_max}; - (void)ComputeMerkleRoot(v256); + std::vector v256{u256, u256_min, u256_max}; + (void)ComputeMerkleRoot(std::move(v256)); (void)DecompressAmount(u64); { if (std::optional parsed = ParseMoney(FormatMoney(i64))) { diff --git a/src/test/merkle_tests.cpp b/src/test/merkle_tests.cpp index 649da07cf7e..3a5720fedd5 100644 --- a/src/test/merkle_tests.cpp +++ b/src/test/merkle_tests.cpp @@ -232,8 +232,9 @@ BOOST_AUTO_TEST_CASE(merkle_test_BlockWitness) { CBlock block; - block.vtx.resize(2); - for (std::size_t pos = 0; pos < block.vtx.size(); pos++) { + constexpr size_t vtx_count{3}; + block.vtx.resize(vtx_count); + for (std::size_t pos = 0; pos < vtx_count; pos++) { CMutableTransaction mtx; mtx.nLockTime = pos; block.vtx[pos] = MakeTransactionRef(std::move(mtx)); @@ -242,12 +243,12 @@ BOOST_AUTO_TEST_CASE(merkle_test_BlockWitness) uint256 blockWitness = BlockWitnessMerkleRoot(block); std::vector hashes; - hashes.resize(block.vtx.size()); - hashes[0].SetNull(); - hashes[1] = block.vtx[1]->GetHash().ToUint256(); + hashes.resize(vtx_count); // Note: leaving odd count to exercise old behavior + for (size_t pos{1}; pos < vtx_count; ++pos) { + hashes[pos] = block.vtx[pos]->GetWitnessHash().ToUint256(); + } uint256 merkleRootofHashes = ComputeMerkleRoot(hashes); - BOOST_CHECK_EQUAL(merkleRootofHashes, blockWitness); } BOOST_AUTO_TEST_SUITE_END()