Changeset View
Changeset View
Standalone View
Standalone View
src/test/transaction_tests.cpp
Show First 20 Lines • Show All 417 Lines • ▼ Show 20 Lines | stack.back() = | ||||
std::vector<uint8_t>(redeemScript.begin(), redeemScript.end()); | std::vector<uint8_t>(redeemScript.begin(), redeemScript.end()); | ||||
script = PushAll(stack); | script = PushAll(stack); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(test_big_transaction) { | BOOST_AUTO_TEST_CASE(test_big_transaction) { | ||||
CKey key; | CKey key; | ||||
key.MakeNewKey(false); | key.MakeNewKey(false); | ||||
FillableSigningProvider keystore; | FillableSigningProvider keystore; | ||||
keystore.AddKeyPubKey(key, key.GetPubKey()); | BOOST_CHECK(keystore.AddKeyPubKey(key, key.GetPubKey())); | ||||
CScript scriptPubKey = CScript() | CScript scriptPubKey = CScript() | ||||
<< ToByteVector(key.GetPubKey()) << OP_CHECKSIG; | << ToByteVector(key.GetPubKey()) << OP_CHECKSIG; | ||||
std::vector<SigHashType> sigHashes; | std::vector<SigHashType> sigHashes; | ||||
sigHashes.emplace_back(SIGHASH_NONE | SIGHASH_FORKID); | sigHashes.emplace_back(SIGHASH_NONE | SIGHASH_FORKID); | ||||
sigHashes.emplace_back(SIGHASH_SINGLE | SIGHASH_FORKID); | sigHashes.emplace_back(SIGHASH_SINGLE | SIGHASH_FORKID); | ||||
sigHashes.emplace_back(SIGHASH_ALL | SIGHASH_FORKID); | sigHashes.emplace_back(SIGHASH_ALL | SIGHASH_FORKID); | ||||
sigHashes.emplace_back(SIGHASH_NONE | SIGHASH_FORKID | | sigHashes.emplace_back(SIGHASH_NONE | SIGHASH_FORKID | | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(test_witness) { | ||||
key3.MakeNewKey(true); | key3.MakeNewKey(true); | ||||
key1L.MakeNewKey(false); | key1L.MakeNewKey(false); | ||||
key2L.MakeNewKey(false); | key2L.MakeNewKey(false); | ||||
pubkey1 = key1.GetPubKey(); | pubkey1 = key1.GetPubKey(); | ||||
pubkey2 = key2.GetPubKey(); | pubkey2 = key2.GetPubKey(); | ||||
pubkey3 = key3.GetPubKey(); | pubkey3 = key3.GetPubKey(); | ||||
pubkey1L = key1L.GetPubKey(); | pubkey1L = key1L.GetPubKey(); | ||||
pubkey2L = key2L.GetPubKey(); | pubkey2L = key2L.GetPubKey(); | ||||
keystore.AddKeyPubKey(key1, pubkey1); | BOOST_CHECK(keystore.AddKeyPubKey(key1, pubkey1)); | ||||
keystore.AddKeyPubKey(key2, pubkey2); | BOOST_CHECK(keystore.AddKeyPubKey(key2, pubkey2)); | ||||
keystore.AddKeyPubKey(key1L, pubkey1L); | BOOST_CHECK(keystore.AddKeyPubKey(key1L, pubkey1L)); | ||||
keystore.AddKeyPubKey(key2L, pubkey2L); | BOOST_CHECK(keystore.AddKeyPubKey(key2L, pubkey2L)); | ||||
CScript scriptPubkey1, scriptPubkey2, scriptPubkey1L, scriptPubkey2L, | CScript scriptPubkey1, scriptPubkey2, scriptPubkey1L, scriptPubkey2L, | ||||
scriptMulti; | scriptMulti; | ||||
scriptPubkey1 << ToByteVector(pubkey1) << OP_CHECKSIG; | scriptPubkey1 << ToByteVector(pubkey1) << OP_CHECKSIG; | ||||
scriptPubkey2 << ToByteVector(pubkey2) << OP_CHECKSIG; | scriptPubkey2 << ToByteVector(pubkey2) << OP_CHECKSIG; | ||||
scriptPubkey1L << ToByteVector(pubkey1L) << OP_CHECKSIG; | scriptPubkey1L << ToByteVector(pubkey1L) << OP_CHECKSIG; | ||||
scriptPubkey2L << ToByteVector(pubkey2L) << OP_CHECKSIG; | scriptPubkey2L << ToByteVector(pubkey2L) << OP_CHECKSIG; | ||||
std::vector<CPubKey> oneandthree; | std::vector<CPubKey> oneandthree; | ||||
oneandthree.push_back(pubkey1); | oneandthree.push_back(pubkey1); | ||||
oneandthree.push_back(pubkey3); | oneandthree.push_back(pubkey3); | ||||
scriptMulti = GetScriptForMultisig(2, oneandthree); | scriptMulti = GetScriptForMultisig(2, oneandthree); | ||||
keystore.AddCScript(scriptPubkey1); | BOOST_CHECK(keystore.AddCScript(scriptPubkey1)); | ||||
keystore.AddCScript(scriptPubkey2); | BOOST_CHECK(keystore.AddCScript(scriptPubkey2)); | ||||
keystore.AddCScript(scriptPubkey1L); | BOOST_CHECK(keystore.AddCScript(scriptPubkey1L)); | ||||
keystore.AddCScript(scriptPubkey2L); | BOOST_CHECK(keystore.AddCScript(scriptPubkey2L)); | ||||
keystore.AddCScript(scriptMulti); | BOOST_CHECK(keystore.AddCScript(scriptMulti)); | ||||
keystore2.AddCScript(scriptMulti); | BOOST_CHECK(keystore2.AddCScript(scriptMulti)); | ||||
keystore2.AddKeyPubKey(key3, pubkey3); | BOOST_CHECK(keystore2.AddKeyPubKey(key3, pubkey3)); | ||||
CTransactionRef output1, output2; | CTransactionRef output1, output2; | ||||
CMutableTransaction input1, input2; | CMutableTransaction input1, input2; | ||||
// Normal pay-to-compressed-pubkey. | // Normal pay-to-compressed-pubkey. | ||||
CreateCreditAndSpend(keystore, scriptPubkey1, output1, input1); | CreateCreditAndSpend(keystore, scriptPubkey1, output1, input1); | ||||
CreateCreditAndSpend(keystore, scriptPubkey2, output2, input2); | CreateCreditAndSpend(keystore, scriptPubkey2, output2, input2); | ||||
CheckWithFlag(output1, input1, 0, true); | CheckWithFlag(output1, input1, 0, true); | ||||
▲ Show 20 Lines • Show All 248 Lines • Show Last 20 Lines |