test: additional test coverage for script_verify_flags
What changed, and why it matters
This commit only adds extra test cases and assertions for how Bitcoin Core handles script verification flags. It does not change any production code that processes real transactions, so it cannot introduce a security vulnerability or fix one in live software.
No security action required; treat as routine test-coverage improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds two assertions to the fuzz target for script flags and three new BOOST_CHECK_EQUAL cases in FormatScriptFlags unit tests. The assertions verify round-trip conversion between integer and typed flag representations, while the new test cases exercise multi-bit and high-bit flag formatting. No consensus, networking, wallet, or validation logic is modified.
Changed components
src/test/fuzz/script_flags.cppsrc/test/script_tests.cppInspect captured patch +5 / −0
diff --git a/src/test/fuzz/script_flags.cpp b/src/test/fuzz/script_flags.cpp
index 0920f7a4..ca38c6a6 100644
--- a/src/test/fuzz/script_flags.cpp
+++ b/src/test/fuzz/script_flags.cpp
@@ -20,6 +20,7 @@ static DataStream& operator>>(DataStream& ds, script_verify_flags& f)
script_verify_flags::value_type n{0};
ds >> n;
f = script_verify_flags::from_int(n);
+ assert(n == f.as_int());
return ds;
}
@@ -33,6 +34,8 @@ FUZZ_TARGET(script_flags)
script_verify_flags verify_flags;
ds >> verify_flags;
+ assert(verify_flags == script_verify_flags::from_int(verify_flags.as_int()));
+
if (!IsValidFlagCombination(verify_flags)) return;
script_verify_flags fuzzed_flags;
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index c1a99473..fc4550bb 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -1716,8 +1716,10 @@ BOOST_AUTO_TEST_CASE(formatscriptflags)
{
// quick check that FormatScriptFlags reports any unknown/unexpected bits
BOOST_CHECK_EQUAL(FormatScriptFlags(SCRIPT_VERIFY_P2SH), "P2SH");
+ BOOST_CHECK_EQUAL(FormatScriptFlags(SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_TAPROOT), "P2SH,TAPROOT");
BOOST_CHECK_EQUAL(FormatScriptFlags(SCRIPT_VERIFY_P2SH | script_verify_flags::from_int(1u<<31)), "P2SH,0x80000000");
BOOST_CHECK_EQUAL(FormatScriptFlags(SCRIPT_VERIFY_TAPROOT | script_verify_flags::from_int(1u<<27)), "TAPROOT,0x08000000");
+ BOOST_CHECK_EQUAL(FormatScriptFlags(SCRIPT_VERIFY_TAPROOT | script_verify_flags::from_int((1u<<28) | (1ull<<58))), "TAPROOT,0x400000010000000");
BOOST_CHECK_EQUAL(FormatScriptFlags(script_verify_flags::from_int(1u<<26)), "0x04000000");
}
Why this scored 14/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.