| 26 | BOOST_FIXTURE_TEST_SUITE(sigopcount_tests, BasicTestingSetup) |
| 27 | |
| 28 | BOOST_AUTO_TEST_CASE(GetSigOpCount) |
| 29 | { |
| 30 | // Test CScript::GetSigOpCount() |
| 31 | CScript s1; |
| 32 | BOOST_CHECK_EQUAL(s1.GetSigOpCount(false), 0U); |
| 33 | BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 0U); |
| 34 | |
| 35 | uint160 dummy; |
| 36 | s1 << OP_1 << ToByteVector(dummy) << ToByteVector(dummy) << OP_2 << OP_CHECKMULTISIG; |
| 37 | BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 2U); |
| 38 | s1 << OP_IF << OP_CHECKSIG << OP_ENDIF; |
| 39 | BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 3U); |
| 40 | BOOST_CHECK_EQUAL(s1.GetSigOpCount(false), 21U); |
| 41 | |
| 42 | CScript p2sh = GetScriptForDestination(ScriptHash(s1)); |
| 43 | CScript scriptSig; |
| 44 | scriptSig << OP_0 << Serialize(s1); |
| 45 | BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(scriptSig), 3U); |
| 46 | |
| 47 | std::vector<CPubKey> keys; |
| 48 | for (int i = 0; i < 3; i++) |
| 49 | { |
| 50 | CKey k; |
| 51 | k.MakeNewKey(true); |
| 52 | keys.push_back(k.GetPubKey()); |
| 53 | } |
| 54 | CScript s2 = GetScriptForMultisig(1, keys); |
| 55 | BOOST_CHECK_EQUAL(s2.GetSigOpCount(true), 3U); |
| 56 | BOOST_CHECK_EQUAL(s2.GetSigOpCount(false), 20U); |
| 57 | |
| 58 | p2sh = GetScriptForDestination(ScriptHash(s2)); |
| 59 | BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(true), 0U); |
| 60 | BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(false), 0U); |
| 61 | CScript scriptSig2; |
| 62 | scriptSig2 << OP_1 << ToByteVector(dummy) << ToByteVector(dummy) << Serialize(s2); |
| 63 | BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(scriptSig2), 3U); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Verifies script execution of the zeroth scriptPubKey of tx output and |
nothing calls this directly
no test coverage detected