test: P2SH sig ops are only counted with `SCRIPT_VERIFY_P2SH` flag
What changed, and why it matters
This commit only adds a new test case to Bitcoin Core's own test suite. It checks that P2SH signature-operation counting is disabled when the relevant verification flag is not set. There is no change to production code, no bug fix, and no security patch.
No action required; treat as routine test coverage improvement.
Security signals we found
No production code modified
Test-only change
Behavior being tested is already present in the codebase
Evidence from the diff
The diff adds a single assertion in src/test/sigopcount_tests.cpp: after verifying that a P2SH-style transaction costs 2*WITNESS_SCALE_FACTOR sigops when SCRIPT_VERIFY_P2SH is enabled, it asserts that the same transaction reports 0 sigops when flags is 0. This documents/verifies existing behavior of GetTransactionSigOpCost; it does not alter consensus or mempool logic.
Changed components
src/test/sigopcount_tests.cppInspect captured patch +3 / −0
diff --git a/src/test/sigopcount_tests.cpp b/src/test/sigopcount_tests.cpp
index e3360312..41a4304f 100644
--- a/src/test/sigopcount_tests.cpp
+++ b/src/test/sigopcount_tests.cpp
@@ -151,6 +151,9 @@ BOOST_AUTO_TEST_CASE(GetTxSigOpCost)
BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, CScriptWitness());
assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 2 * WITNESS_SCALE_FACTOR);
assert(VerifyWithFlag(CTransaction(creationTx), spendingTx, flags) == SCRIPT_ERR_CHECKMULTISIGVERIFY);
+
+ // P2SH sigops are not counted if we don't set the SCRIPT_VERIFY_P2SH flag
+ assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, /*flags=*/0) == 0);
}
// P2WPKH witness program
Why this scored 16/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.