Add test case for GetTransactionSigOpCount without the P2SH flags passed in

https://reviews.bitcoinabc.org/D1596
This commit is contained in:
lateminer
2018-11-18 14:39:17 +03:00
parent 2cf0ca0789
commit c7346b5efd

View File

@@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE(GetTxSigOpCost)
key.MakeNewKey(true);
CPubKey pubkey = key.GetPubKey();
// Default flags
int flags = SCRIPT_VERIFY_P2SH;
unsigned int flags = SCRIPT_VERIFY_P2SH;
// Multisig script
{
@@ -140,6 +140,11 @@ BOOST_AUTO_TEST_CASE(GetTxSigOpCost)
assert(GetTransactionSigOpCount(CTransaction(creationTx), coins, flags) == MAX_PUBKEYS_PER_MULTISIG);
// Sanity check: script verification fails because of an invalid signature.
assert(VerifyWithFlag(creationTx, spendingTx, flags) == SCRIPT_ERR_CHECKMULTISIGVERIFY);
// Make sure non P2SH sigops are counted even if the flag for P2SH is
// not passed in.
assert(GetTransactionSigOpCount(CTransaction(spendingTx), coins, SCRIPT_VERIFY_NONE) == 0);
assert(GetTransactionSigOpCount(CTransaction(creationTx), coins, SCRIPT_VERIFY_NONE) == MAX_PUBKEYS_PER_MULTISIG);
}
// Multisig nested in P2SH
@@ -151,6 +156,10 @@ BOOST_AUTO_TEST_CASE(GetTxSigOpCost)
BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig);
assert(GetTransactionSigOpCount(CTransaction(spendingTx), coins, flags) == 2);
assert(VerifyWithFlag(creationTx, spendingTx, flags) == SCRIPT_ERR_CHECKMULTISIGVERIFY);
// Make sure P2SH sigops are not counted if the flag for P2SH is not
// passed in.
assert(GetTransactionSigOpCount(CTransaction(spendingTx), coins, SCRIPT_VERIFY_NONE) == 0);
}
}