From f670836112c01feb3cb71618192e9c0c2e55767f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Fri, 25 Apr 2025 15:57:49 +0200 Subject: [PATCH] test: remove old recursive `FindChallenges_recursive` implementation The performance of the test is the same as before, with the recursive method. --- src/test/miniscript_tests.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/src/test/miniscript_tests.cpp b/src/test/miniscript_tests.cpp index c2b0d43dccf..4d08fdfca6f 100644 --- a/src/test/miniscript_tests.cpp +++ b/src/test/miniscript_tests.cpp @@ -296,33 +296,6 @@ using NodeRef = miniscript::NodeRef; using miniscript::operator""_mst; using Node = miniscript::Node; -/** Compute all challenges (pubkeys, hashes, timelocks) that occur in a given Miniscript. */ -// NOLINTNEXTLINE(misc-no-recursion) -std::set FindChallenges_recursive(const NodeRef& ref) { - std::set chal; - for (const auto& key : ref->keys) { - chal.emplace(ChallengeType::PK, ChallengeNumber(key)); - } - if (ref->fragment == miniscript::Fragment::OLDER) { - chal.emplace(ChallengeType::OLDER, ref->k); - } else if (ref->fragment == miniscript::Fragment::AFTER) { - chal.emplace(ChallengeType::AFTER, ref->k); - } else if (ref->fragment == miniscript::Fragment::SHA256) { - chal.emplace(ChallengeType::SHA256, ChallengeNumber(ref->data)); - } else if (ref->fragment == miniscript::Fragment::RIPEMD160) { - chal.emplace(ChallengeType::RIPEMD160, ChallengeNumber(ref->data)); - } else if (ref->fragment == miniscript::Fragment::HASH256) { - chal.emplace(ChallengeType::HASH256, ChallengeNumber(ref->data)); - } else if (ref->fragment == miniscript::Fragment::HASH160) { - chal.emplace(ChallengeType::HASH160, ChallengeNumber(ref->data)); - } - for (const auto& sub : ref->subs) { - auto sub_chal = FindChallenges_recursive(sub); - chal.insert(sub_chal.begin(), sub_chal.end()); - } - return chal; -} - /** Compute all challenges (pubkeys, hashes, timelocks) that occur in a given Miniscript. */ std::set FindChallenges(const NodeRef& root) { @@ -379,9 +352,7 @@ struct MiniScriptTest : BasicTestingSetup { /** Run random satisfaction tests. */ void TestSatisfy(const KeyConverter& converter, const std::string& testcase, const NodeRef& node) { auto script = node->ToScript(converter); - const auto challenges_recursive{FindChallenges_recursive(node)}; const auto challenges{FindChallenges(node)}; // Find all challenges in the generated miniscript. - BOOST_CHECK(challenges_recursive == challenges); std::vector challist(challenges.begin(), challenges.end()); for (int iter = 0; iter < 3; ++iter) { std::shuffle(challist.begin(), challist.end(), m_rng);