aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2012-01-25 05:21:20 -0800
committerGavin Andresen <gavinandresen@gmail.com>2012-01-25 05:21:20 -0800
commitb6a35d2d5235585b728c4373d6c0e69e563caec6 (patch)
treea410ffb729166366824922db8b030488177b37f2 /src/test
parent341519523f2144349a920efee32ebf0dab74e7ac (diff)
parent137d0685a45d4a02f5773652130704ad135e63f7 (diff)
Merge pull request #773 from gavinandresen/p2shSigOpCount
Simplify counting of P2SH sigops to match BIP 16
Diffstat (limited to 'src/test')
-rw-r--r--src/test/script_P2SH_tests.cpp17
-rw-r--r--src/test/transaction_tests.cpp2
2 files changed, 14 insertions, 5 deletions
diff --git a/src/test/script_P2SH_tests.cpp b/src/test/script_P2SH_tests.cpp
index aed3e23319..c782e0c6c1 100644
--- a/src/test/script_P2SH_tests.cpp
+++ b/src/test/script_P2SH_tests.cpp
@@ -255,7 +255,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
}
CTransaction txFrom;
- txFrom.vout.resize(5);
+ txFrom.vout.resize(6);
// First three are standard:
CScript pay1; pay1.SetBitcoinAddress(key[0].GetPubKey());
@@ -267,12 +267,18 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
txFrom.vout[1].scriptPubKey = pay1;
txFrom.vout[2].scriptPubKey = pay1of3;
- // Last two non-standard:
+ // Last three non-standard:
CScript empty;
keystore.AddCScript(empty);
txFrom.vout[3].scriptPubKey = empty;
// Can't use SetPayToScriptHash, it checks for the empty Script. So:
txFrom.vout[4].scriptPubKey << OP_HASH160 << Hash160(empty) << OP_EQUAL;
+ CScript oneOfEleven;
+ oneOfEleven << OP_1;
+ for (int i = 0; i < 11; i++)
+ oneOfEleven << key[0].GetPubKey();
+ oneOfEleven << OP_11 << OP_CHECKMULTISIG;
+ txFrom.vout[5].scriptPubKey.SetPayToScriptHash(oneOfEleven);
mapInputs[txFrom.GetHash()] = make_pair(CTxIndex(), txFrom);
@@ -292,16 +298,21 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
BOOST_CHECK(SignSignature(keystore, txFrom, txTo, 2));
BOOST_CHECK(txTo.AreInputsStandard(mapInputs));
+ BOOST_CHECK_EQUAL(txTo.GetP2SHSigOpCount(mapInputs), 1);
CTransaction txToNonStd;
txToNonStd.vout.resize(1);
txToNonStd.vout[0].scriptPubKey.SetBitcoinAddress(key[1].GetPubKey());
- txToNonStd.vin.resize(1);
+ txToNonStd.vin.resize(2);
txToNonStd.vin[0].prevout.n = 4;
txToNonStd.vin[0].prevout.hash = txFrom.GetHash();
txToNonStd.vin[0].scriptSig << Serialize(empty);
+ txToNonStd.vin[1].prevout.n = 5;
+ txToNonStd.vin[1].prevout.hash = txFrom.GetHash();
+ txToNonStd.vin[1].scriptSig << OP_0 << Serialize(oneOfEleven);
BOOST_CHECK(!txToNonStd.AreInputsStandard(mapInputs));
+ BOOST_CHECK_EQUAL(txToNonStd.GetP2SHSigOpCount(mapInputs), 11);
txToNonStd.vin[0].scriptSig.clear();
BOOST_CHECK(!txToNonStd.AreInputsStandard(mapInputs));
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
index 33765ca966..592fe3f81a 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -78,7 +78,6 @@ BOOST_AUTO_TEST_CASE(test_Get)
t1.vout[0].scriptPubKey << OP_1;
BOOST_CHECK(t1.AreInputsStandard(dummyInputs));
- BOOST_CHECK_EQUAL(t1.GetSigOpCount(dummyInputs), 3);
BOOST_CHECK_EQUAL(t1.GetValueIn(dummyInputs), (50+21+22)*CENT);
}
@@ -103,7 +102,6 @@ BOOST_AUTO_TEST_CASE(test_GetThrow)
t1.vout[0].scriptPubKey << OP_1;
BOOST_CHECK_THROW(t1.AreInputsStandard(missingInputs), runtime_error);
- BOOST_CHECK_THROW(t1.GetSigOpCount(missingInputs), runtime_error);
BOOST_CHECK_THROW(t1.GetValueIn(missingInputs), runtime_error);
}