Skip to content

Commit b1f8a13

Browse files
committed
Merge bitcoin/bitcoin#33624: test: P2SH sig ops are only counted with SCRIPT_VERIFY_P2SH
3a10d70 test: P2SH sig ops are only counted with `SCRIPT_VERIFY_P2SH` flag (brunoerg) Pull request description: This PR adds a test case for `GetTransactionSigOpCost` to check that P2SH sig ops are only counted when `SCRIPT_VERIFY_P2SH` flag is set. Kills the following [mutant](https://corecheck.dev/mutation/src/consensus/tx_verify.cpp#L150): ```diff diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index 9d09872..cc7cdaaf8f 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -147,7 +147,7 @@ int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& i if (tx.IsCoinBase()) return nSigOps; - if (flags & SCRIPT_VERIFY_P2SH) { + if (1==1) { nSigOps += GetP2SHSigOpCount(tx, inputs) * WITNESS_SCALE_FACTOR; } ``` ACKs for top commit: l0rinc: Tested ACK 3a10d70 maflcko: re-lgtm ACK 3a10d70 instagibbs: ACK 3a10d70 janb84: tested ACK 3a10d70 Tree-SHA512: f560b4f9f2ce5c5fdd0a86e7e1f8ea27a8c6fda0327a6186a0c21e2c06ef13beeb017686db1688cace68812a01701abe46e8e1a095afefc6f2aed6ed96ba8288
2 parents 2f7a50f + 3a10d70 commit b1f8a13

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/test/sigopcount_tests.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ BOOST_AUTO_TEST_CASE(GetTxSigOpCost)
151151
BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, CScriptWitness());
152152
assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 2 * WITNESS_SCALE_FACTOR);
153153
assert(VerifyWithFlag(CTransaction(creationTx), spendingTx, flags) == SCRIPT_ERR_CHECKMULTISIGVERIFY);
154+
155+
// P2SH sigops are not counted if we don't set the SCRIPT_VERIFY_P2SH flag
156+
assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, /*flags=*/0) == 0);
154157
}
155158

156159
// P2WPKH witness program

0 commit comments

Comments
 (0)