test(miniscript): Make tested script valid
What changed, and why it matters
This is a Bitcoin Core test-only change. It fixes a unit test so that the miniscript it builds is actually valid, and renames the test to better reflect that it stresses stack usage during node construction/destruction/cloning. No production code is changed, and there is no security fix or vulnerability being patched.
No security action required. Treat as ordinary test maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies src/test/miniscript_tests.cpp only. It renames node_deep_destruct to node_stress_stack, switches the test context from P2WSH to TAPSCRIPT, changes the wrapping fragment from WRAP_S to WRAP_N, and adds a BOOST_CHECK(root.IsValid()) assertion. The prior test constructed a 200,000-deep WRAP_S tree under P2WSH, which produced an invalid miniscript (likely due to script size or resource limits), while the new version produces a valid 200,001-byte script and still exercises deep recursive operations. This is a test correctness and naming cleanup, not a security patch.
Changed components
src/test/miniscript_tests.cppInspect captured patch +4 / −4
diff --git a/src/test/miniscript_tests.cpp b/src/test/miniscript_tests.cpp
index 757f89b6..2bb96144 100644
--- a/src/test/miniscript_tests.cpp
+++ b/src/test/miniscript_tests.cpp
@@ -728,18 +728,18 @@ BOOST_AUTO_TEST_CASE(fixed_tests)
}
// Confirm that ~Node(), Node::Clone() and operator=(Node&&) are stack-safe.
-BOOST_AUTO_TEST_CASE(node_deep_destruct)
+BOOST_AUTO_TEST_CASE(node_stress_stack)
{
using miniscript::internal::NoDupCheck;
using miniscript::Fragment;
using NodeU32 = miniscript::Node<uint32_t>;
- constexpr auto ctx{miniscript::MiniscriptContext::P2WSH};
-
+ constexpr auto ctx{miniscript::MiniscriptContext::TAPSCRIPT};
NodeU32 root{NoDupCheck{}, ctx, Fragment::JUST_1};
for (uint32_t i{0}; i < 200'000; ++i) {
- root = NodeU32{NoDupCheck{}, ctx, Fragment::WRAP_S, Vector(std::move(root))};
+ root = NodeU32{NoDupCheck{}, ctx, Fragment::WRAP_N, Vector(std::move(root))};
}
+ BOOST_CHECK(root.IsValid());
BOOST_CHECK_EQUAL(root.ScriptSize(), 200'001);
auto clone{root.Clone()};
Why this scored 15/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.