Changeset View
Changeset View
Standalone View
Standalone View
src/test/multisig_tests.cpp
Show All 15 Lines | |||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
typedef std::vector<uint8_t> valtype; | typedef std::vector<uint8_t> valtype; | ||||
BOOST_FIXTURE_TEST_SUITE(multisig_tests, BasicTestingSetup) | BOOST_FIXTURE_TEST_SUITE(multisig_tests, BasicTestingSetup) | ||||
CScript sign_multisig(CScript scriptPubKey, std::vector<CKey> keys, | CScript sign_multisig(CScript scriptPubKey, std::vector<CKey> keys, | ||||
CTransaction transaction, int whichIn) { | CMutableTransaction mutableTransaction, int whichIn) { | ||||
uint256 hash = SignatureHash(scriptPubKey, transaction, whichIn, | uint256 hash = SignatureHash(scriptPubKey, CTransaction(mutableTransaction), | ||||
SigHashType(), Amount(0)); | whichIn, SigHashType(), Amount(0)); | ||||
CScript result; | CScript result; | ||||
// CHECKMULTISIG bug workaround | // CHECKMULTISIG bug workaround | ||||
result << OP_0; | result << OP_0; | ||||
for (const CKey &key : keys) { | for (const CKey &key : keys) { | ||||
std::vector<uint8_t> vchSig; | std::vector<uint8_t> vchSig; | ||||
BOOST_CHECK(key.Sign(hash, vchSig)); | BOOST_CHECK(key.Sign(hash, vchSig)); | ||||
vchSig.push_back(uint8_t(SIGHASH_ALL)); | vchSig.push_back(uint8_t(SIGHASH_ALL)); | ||||
▲ Show 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | for (int i = 0; i < 3; i++) { | ||||
txTo[i].vin.resize(1); | txTo[i].vin.resize(1); | ||||
txTo[i].vout.resize(1); | txTo[i].vout.resize(1); | ||||
txTo[i].vin[0].prevout.n = i; | txTo[i].vin[0].prevout.n = i; | ||||
txTo[i].vin[0].prevout.hash = txFrom.GetId(); | txTo[i].vin[0].prevout.hash = txFrom.GetId(); | ||||
txTo[i].vout[0].nValue = Amount(1); | txTo[i].vout[0].nValue = Amount(1); | ||||
} | } | ||||
for (int i = 0; i < 3; i++) { | for (int i = 0; i < 3; i++) { | ||||
BOOST_CHECK_MESSAGE(SignSignature(keystore, txFrom, txTo[i], 0, | BOOST_CHECK_MESSAGE(SignSignature(keystore, CTransaction(txFrom), | ||||
txTo[i], 0, | |||||
SigHashType().withForkId(true)), | SigHashType().withForkId(true)), | ||||
strprintf("SignSignature %d", i)); | strprintf("SignSignature %d", i)); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |