|
|
@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(script_valid) |
|
|
|
unsigned int scriptflags = ParseScriptFlags(test[2].get_str()); |
|
|
|
unsigned int scriptflags = ParseScriptFlags(test[2].get_str()); |
|
|
|
|
|
|
|
|
|
|
|
CTransaction tx; |
|
|
|
CTransaction tx; |
|
|
|
BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, tx, 0, scriptflags, SIGHASH_NONE), strTest); |
|
|
|
BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, tx, 0, scriptflags), strTest); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(script_invalid) |
|
|
|
unsigned int scriptflags = ParseScriptFlags(test[2].get_str()); |
|
|
|
unsigned int scriptflags = ParseScriptFlags(test[2].get_str()); |
|
|
|
|
|
|
|
|
|
|
|
CTransaction tx; |
|
|
|
CTransaction tx; |
|
|
|
BOOST_CHECK_MESSAGE(!VerifyScript(scriptSig, scriptPubKey, tx, 0, scriptflags, SIGHASH_NONE), strTest); |
|
|
|
BOOST_CHECK_MESSAGE(!VerifyScript(scriptSig, scriptPubKey, tx, 0, scriptflags), strTest); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -116,18 +116,18 @@ BOOST_AUTO_TEST_CASE(script_PushData) |
|
|
|
static const unsigned char pushdata4[] = { OP_PUSHDATA4, 1, 0, 0, 0, 0x5a }; |
|
|
|
static const unsigned char pushdata4[] = { OP_PUSHDATA4, 1, 0, 0, 0, 0x5a }; |
|
|
|
|
|
|
|
|
|
|
|
vector<vector<unsigned char> > directStack; |
|
|
|
vector<vector<unsigned char> > directStack; |
|
|
|
BOOST_CHECK(EvalScript(directStack, CScript(&direct[0], &direct[sizeof(direct)]), CTransaction(), 0, true, 0)); |
|
|
|
BOOST_CHECK(EvalScript(directStack, CScript(&direct[0], &direct[sizeof(direct)]), CTransaction(), 0, true)); |
|
|
|
|
|
|
|
|
|
|
|
vector<vector<unsigned char> > pushdata1Stack; |
|
|
|
vector<vector<unsigned char> > pushdata1Stack; |
|
|
|
BOOST_CHECK(EvalScript(pushdata1Stack, CScript(&pushdata1[0], &pushdata1[sizeof(pushdata1)]), CTransaction(), 0, true, 0)); |
|
|
|
BOOST_CHECK(EvalScript(pushdata1Stack, CScript(&pushdata1[0], &pushdata1[sizeof(pushdata1)]), CTransaction(), 0, true)); |
|
|
|
BOOST_CHECK(pushdata1Stack == directStack); |
|
|
|
BOOST_CHECK(pushdata1Stack == directStack); |
|
|
|
|
|
|
|
|
|
|
|
vector<vector<unsigned char> > pushdata2Stack; |
|
|
|
vector<vector<unsigned char> > pushdata2Stack; |
|
|
|
BOOST_CHECK(EvalScript(pushdata2Stack, CScript(&pushdata2[0], &pushdata2[sizeof(pushdata2)]), CTransaction(), 0, true, 0)); |
|
|
|
BOOST_CHECK(EvalScript(pushdata2Stack, CScript(&pushdata2[0], &pushdata2[sizeof(pushdata2)]), CTransaction(), 0, true)); |
|
|
|
BOOST_CHECK(pushdata2Stack == directStack); |
|
|
|
BOOST_CHECK(pushdata2Stack == directStack); |
|
|
|
|
|
|
|
|
|
|
|
vector<vector<unsigned char> > pushdata4Stack; |
|
|
|
vector<vector<unsigned char> > pushdata4Stack; |
|
|
|
BOOST_CHECK(EvalScript(pushdata4Stack, CScript(&pushdata4[0], &pushdata4[sizeof(pushdata4)]), CTransaction(), 0, true, 0)); |
|
|
|
BOOST_CHECK(EvalScript(pushdata4Stack, CScript(&pushdata4[0], &pushdata4[sizeof(pushdata4)]), CTransaction(), 0, true)); |
|
|
|
BOOST_CHECK(pushdata4Stack == directStack); |
|
|
|
BOOST_CHECK(pushdata4Stack == directStack); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -185,15 +185,15 @@ BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG12) |
|
|
|
txTo12.vout[0].nValue = 1; |
|
|
|
txTo12.vout[0].nValue = 1; |
|
|
|
|
|
|
|
|
|
|
|
CScript goodsig1 = sign_multisig(scriptPubKey12, key1, txTo12); |
|
|
|
CScript goodsig1 = sign_multisig(scriptPubKey12, key1, txTo12); |
|
|
|
BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, flags, 0)); |
|
|
|
BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, flags)); |
|
|
|
txTo12.vout[0].nValue = 2; |
|
|
|
txTo12.vout[0].nValue = 2; |
|
|
|
BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, flags, 0)); |
|
|
|
BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, flags)); |
|
|
|
|
|
|
|
|
|
|
|
CScript goodsig2 = sign_multisig(scriptPubKey12, key2, txTo12); |
|
|
|
CScript goodsig2 = sign_multisig(scriptPubKey12, key2, txTo12); |
|
|
|
BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, txTo12, 0, flags, 0)); |
|
|
|
BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, txTo12, 0, flags)); |
|
|
|
|
|
|
|
|
|
|
|
CScript badsig1 = sign_multisig(scriptPubKey12, key3, txTo12); |
|
|
|
CScript badsig1 = sign_multisig(scriptPubKey12, key3, txTo12); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, txTo12, 0, flags, 0)); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, txTo12, 0, flags)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23) |
|
|
|
BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23) |
|
|
@ -221,46 +221,46 @@ BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23) |
|
|
|
std::vector<CKey> keys; |
|
|
|
std::vector<CKey> keys; |
|
|
|
keys.push_back(key1); keys.push_back(key2); |
|
|
|
keys.push_back(key1); keys.push_back(key2); |
|
|
|
CScript goodsig1 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
CScript goodsig1 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, txTo23, 0, flags, 0)); |
|
|
|
BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, txTo23, 0, flags)); |
|
|
|
|
|
|
|
|
|
|
|
keys.clear(); |
|
|
|
keys.clear(); |
|
|
|
keys.push_back(key1); keys.push_back(key3); |
|
|
|
keys.push_back(key1); keys.push_back(key3); |
|
|
|
CScript goodsig2 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
CScript goodsig2 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, txTo23, 0, flags, 0)); |
|
|
|
BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, txTo23, 0, flags)); |
|
|
|
|
|
|
|
|
|
|
|
keys.clear(); |
|
|
|
keys.clear(); |
|
|
|
keys.push_back(key2); keys.push_back(key3); |
|
|
|
keys.push_back(key2); keys.push_back(key3); |
|
|
|
CScript goodsig3 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
CScript goodsig3 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, txTo23, 0, flags, 0)); |
|
|
|
BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, txTo23, 0, flags)); |
|
|
|
|
|
|
|
|
|
|
|
keys.clear(); |
|
|
|
keys.clear(); |
|
|
|
keys.push_back(key2); keys.push_back(key2); // Can't re-use sig
|
|
|
|
keys.push_back(key2); keys.push_back(key2); // Can't re-use sig
|
|
|
|
CScript badsig1 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
CScript badsig1 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, txTo23, 0, flags, 0)); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, txTo23, 0, flags)); |
|
|
|
|
|
|
|
|
|
|
|
keys.clear(); |
|
|
|
keys.clear(); |
|
|
|
keys.push_back(key2); keys.push_back(key1); // sigs must be in correct order
|
|
|
|
keys.push_back(key2); keys.push_back(key1); // sigs must be in correct order
|
|
|
|
CScript badsig2 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
CScript badsig2 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, txTo23, 0, flags, 0)); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, txTo23, 0, flags)); |
|
|
|
|
|
|
|
|
|
|
|
keys.clear(); |
|
|
|
keys.clear(); |
|
|
|
keys.push_back(key3); keys.push_back(key2); // sigs must be in correct order
|
|
|
|
keys.push_back(key3); keys.push_back(key2); // sigs must be in correct order
|
|
|
|
CScript badsig3 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
CScript badsig3 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, txTo23, 0, flags, 0)); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, txTo23, 0, flags)); |
|
|
|
|
|
|
|
|
|
|
|
keys.clear(); |
|
|
|
keys.clear(); |
|
|
|
keys.push_back(key4); keys.push_back(key2); // sigs must match pubkeys
|
|
|
|
keys.push_back(key4); keys.push_back(key2); // sigs must match pubkeys
|
|
|
|
CScript badsig4 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
CScript badsig4 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, txTo23, 0, flags, 0)); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, txTo23, 0, flags)); |
|
|
|
|
|
|
|
|
|
|
|
keys.clear(); |
|
|
|
keys.clear(); |
|
|
|
keys.push_back(key1); keys.push_back(key4); // sigs must match pubkeys
|
|
|
|
keys.push_back(key1); keys.push_back(key4); // sigs must match pubkeys
|
|
|
|
CScript badsig5 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
CScript badsig5 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, txTo23, 0, flags, 0)); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, txTo23, 0, flags)); |
|
|
|
|
|
|
|
|
|
|
|
keys.clear(); // Must have signatures
|
|
|
|
keys.clear(); // Must have signatures
|
|
|
|
CScript badsig6 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
CScript badsig6 = sign_multisig(scriptPubKey23, keys, txTo23); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, txTo23, 0, flags, 0)); |
|
|
|
BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, txTo23, 0, flags)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(script_combineSigs) |
|
|
|
BOOST_AUTO_TEST_CASE(script_combineSigs) |
|
|
|