Skip to content

Commit f670836

Browse files
committed
test: remove old recursive FindChallenges_recursive implementation
The performance of the test is the same as before, with the recursive method.
1 parent b80d0bd commit f670836

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

src/test/miniscript_tests.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -296,33 +296,6 @@ using NodeRef = miniscript::NodeRef<CPubKey>;
296296
using miniscript::operator""_mst;
297297
using Node = miniscript::Node<CPubKey>;
298298

299-
/** Compute all challenges (pubkeys, hashes, timelocks) that occur in a given Miniscript. */
300-
// NOLINTNEXTLINE(misc-no-recursion)
301-
std::set<Challenge> FindChallenges_recursive(const NodeRef& ref) {
302-
std::set<Challenge> chal;
303-
for (const auto& key : ref->keys) {
304-
chal.emplace(ChallengeType::PK, ChallengeNumber(key));
305-
}
306-
if (ref->fragment == miniscript::Fragment::OLDER) {
307-
chal.emplace(ChallengeType::OLDER, ref->k);
308-
} else if (ref->fragment == miniscript::Fragment::AFTER) {
309-
chal.emplace(ChallengeType::AFTER, ref->k);
310-
} else if (ref->fragment == miniscript::Fragment::SHA256) {
311-
chal.emplace(ChallengeType::SHA256, ChallengeNumber(ref->data));
312-
} else if (ref->fragment == miniscript::Fragment::RIPEMD160) {
313-
chal.emplace(ChallengeType::RIPEMD160, ChallengeNumber(ref->data));
314-
} else if (ref->fragment == miniscript::Fragment::HASH256) {
315-
chal.emplace(ChallengeType::HASH256, ChallengeNumber(ref->data));
316-
} else if (ref->fragment == miniscript::Fragment::HASH160) {
317-
chal.emplace(ChallengeType::HASH160, ChallengeNumber(ref->data));
318-
}
319-
for (const auto& sub : ref->subs) {
320-
auto sub_chal = FindChallenges_recursive(sub);
321-
chal.insert(sub_chal.begin(), sub_chal.end());
322-
}
323-
return chal;
324-
}
325-
326299
/** Compute all challenges (pubkeys, hashes, timelocks) that occur in a given Miniscript. */
327300
std::set<Challenge> FindChallenges(const NodeRef& root)
328301
{
@@ -379,9 +352,7 @@ struct MiniScriptTest : BasicTestingSetup {
379352
/** Run random satisfaction tests. */
380353
void TestSatisfy(const KeyConverter& converter, const std::string& testcase, const NodeRef& node) {
381354
auto script = node->ToScript(converter);
382-
const auto challenges_recursive{FindChallenges_recursive(node)};
383355
const auto challenges{FindChallenges(node)}; // Find all challenges in the generated miniscript.
384-
BOOST_CHECK(challenges_recursive == challenges);
385356
std::vector<Challenge> challist(challenges.begin(), challenges.end());
386357
for (int iter = 0; iter < 3; ++iter) {
387358
std::shuffle(challist.begin(), challist.end(), m_rng);

0 commit comments

Comments
 (0)