Changeset View
Changeset View
Standalone View
Standalone View
src/test/merkle_tests.cpp
Show First 20 Lines • Show All 266 Lines • ▼ Show 20 Lines | for (int i = 0; i < 32; i++) { | ||||
BOOST_CHECK(newRoot == unmutatedRoot); | BOOST_CHECK(newRoot == unmutatedRoot); | ||||
BOOST_CHECK((newRoot == uint256()) == (ntx == 0)); | BOOST_CHECK((newRoot == uint256()) == (ntx == 0)); | ||||
BOOST_CHECK(oldMutated == newMutated); | BOOST_CHECK(oldMutated == newMutated); | ||||
BOOST_CHECK(newMutated == !!mutate); | BOOST_CHECK(newMutated == !!mutate); | ||||
// If no mutation was done (once for every ntx value), try up to 16 | // If no mutation was done (once for every ntx value), try up to 16 | ||||
// branches. | // branches. | ||||
if (mutate == 0) { | if (mutate == 0) { | ||||
for (int loop = 0; loop < std::min(ntx, 16); loop++) { | for (int loop = 0; loop < std::min(ntx, 16); loop++) { | ||||
// If ntx <= 16, try all branches. Otherise, try 16 random | // If ntx <= 16, try all branches. Otherwise, try 16 random | ||||
// ones. | // ones. | ||||
int mtx = loop; | int mtx = loop; | ||||
if (ntx > 16) { | if (ntx > 16) { | ||||
mtx = InsecureRandRange(ntx); | mtx = InsecureRandRange(ntx); | ||||
} | } | ||||
std::vector<uint256> newBranch = | std::vector<uint256> newBranch = | ||||
BlockMerkleBranch(block, mtx); | BlockMerkleBranch(block, mtx); | ||||
std::vector<uint256> oldBranch = | std::vector<uint256> oldBranch = | ||||
Show All 12 Lines |