Changeset View
Changeset View
Standalone View
Standalone View
src/test/transaction_tests.cpp
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | for (size_t idx = 0; idx < tests.size(); idx++) { | ||||
fValid = false; | fValid = false; | ||||
break; | break; | ||||
} | } | ||||
UniValue vinput = input.get_array(); | UniValue vinput = input.get_array(); | ||||
if (vinput.size() < 3 || vinput.size() > 4) { | if (vinput.size() < 3 || vinput.size() > 4) { | ||||
fValid = false; | fValid = false; | ||||
break; | break; | ||||
} | } | ||||
COutPoint outpoint(uint256S(vinput[0].get_str()), | COutPoint outpoint(unspentid_t(uint256S(vinput[0].get_str())), | ||||
vinput[1].get_int()); | vinput[1].get_int()); | ||||
mapprevOutScriptPubKeys[outpoint] = | mapprevOutScriptPubKeys[outpoint] = | ||||
ParseScript(vinput[2].get_str()); | ParseScript(vinput[2].get_str()); | ||||
if (vinput.size() >= 4) { | if (vinput.size() >= 4) { | ||||
mapprevOutValues[outpoint] = vinput[3].get_int64(); | mapprevOutValues[outpoint] = vinput[3].get_int64(); | ||||
} | } | ||||
} | } | ||||
if (!fValid) { | if (!fValid) { | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | for (size_t idx = 0; idx < tests.size(); idx++) { | ||||
fValid = false; | fValid = false; | ||||
break; | break; | ||||
} | } | ||||
UniValue vinput = input.get_array(); | UniValue vinput = input.get_array(); | ||||
if (vinput.size() < 3 || vinput.size() > 4) { | if (vinput.size() < 3 || vinput.size() > 4) { | ||||
fValid = false; | fValid = false; | ||||
break; | break; | ||||
} | } | ||||
COutPoint outpoint(uint256S(vinput[0].get_str()), | COutPoint outpoint(unspentid_t(uint256S(vinput[0].get_str())), | ||||
vinput[1].get_int()); | vinput[1].get_int()); | ||||
mapprevOutScriptPubKeys[outpoint] = | mapprevOutScriptPubKeys[outpoint] = | ||||
ParseScript(vinput[2].get_str()); | ParseScript(vinput[2].get_str()); | ||||
if (vinput.size() >= 4) { | if (vinput.size() >= 4) { | ||||
mapprevOutValues[outpoint] = vinput[3].get_int64(); | mapprevOutValues[outpoint] = vinput[3].get_int64(); | ||||
} | } | ||||
} | } | ||||
if (!fValid) { | if (!fValid) { | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(test_Get) { | ||||
CBasicKeyStore keystore; | CBasicKeyStore keystore; | ||||
CCoinsView coinsDummy; | CCoinsView coinsDummy; | ||||
CCoinsViewCache coins(&coinsDummy); | CCoinsViewCache coins(&coinsDummy); | ||||
std::vector<CMutableTransaction> dummyTransactions = | std::vector<CMutableTransaction> dummyTransactions = | ||||
SetupDummyInputs(keystore, coins); | SetupDummyInputs(keystore, coins); | ||||
CMutableTransaction t1; | CMutableTransaction t1; | ||||
t1.vin.resize(3); | t1.vin.resize(3); | ||||
t1.vin[0].prevout.hash = dummyTransactions[0].GetId(); | t1.vin[0].prevout.unspentid = dummyTransactions[0].GetUnspentid(); | ||||
t1.vin[0].prevout.n = 1; | t1.vin[0].prevout.n = 1; | ||||
t1.vin[0].scriptSig << std::vector<uint8_t>(65, 0); | t1.vin[0].scriptSig << std::vector<uint8_t>(65, 0); | ||||
t1.vin[1].prevout.hash = dummyTransactions[1].GetId(); | t1.vin[1].prevout.unspentid = dummyTransactions[1].GetUnspentid(); | ||||
t1.vin[1].prevout.n = 0; | t1.vin[1].prevout.n = 0; | ||||
t1.vin[1].scriptSig << std::vector<uint8_t>(65, 0) | t1.vin[1].scriptSig << std::vector<uint8_t>(65, 0) | ||||
<< std::vector<uint8_t>(33, 4); | << std::vector<uint8_t>(33, 4); | ||||
t1.vin[2].prevout.hash = dummyTransactions[1].GetId(); | t1.vin[2].prevout.unspentid = dummyTransactions[1].GetUnspentid(); | ||||
t1.vin[2].prevout.n = 1; | t1.vin[2].prevout.n = 1; | ||||
t1.vin[2].scriptSig << std::vector<uint8_t>(65, 0) | t1.vin[2].scriptSig << std::vector<uint8_t>(65, 0) | ||||
<< std::vector<uint8_t>(33, 4); | << std::vector<uint8_t>(33, 4); | ||||
t1.vout.resize(2); | t1.vout.resize(2); | ||||
t1.vout[0].nValue = 90 * CENT.GetSatoshis(); | t1.vout[0].nValue = 90 * CENT.GetSatoshis(); | ||||
t1.vout[0].scriptPubKey << OP_1; | t1.vout[0].scriptPubKey << OP_1; | ||||
BOOST_CHECK(AreInputsStandard(t1, coins)); | BOOST_CHECK(AreInputsStandard(t1, coins)); | ||||
Show All 18 Lines | void CreateCreditAndSpend(const CKeyStore &keystore, const CScript &outscript, | ||||
BOOST_CHECK_EQUAL(output->vin.size(), 1); | BOOST_CHECK_EQUAL(output->vin.size(), 1); | ||||
BOOST_CHECK(output->vin[0] == outputm.vin[0]); | BOOST_CHECK(output->vin[0] == outputm.vin[0]); | ||||
BOOST_CHECK_EQUAL(output->vout.size(), 1); | BOOST_CHECK_EQUAL(output->vout.size(), 1); | ||||
BOOST_CHECK(output->vout[0] == outputm.vout[0]); | BOOST_CHECK(output->vout[0] == outputm.vout[0]); | ||||
CMutableTransaction inputm; | CMutableTransaction inputm; | ||||
inputm.nVersion = 1; | inputm.nVersion = 1; | ||||
inputm.vin.resize(1); | inputm.vin.resize(1); | ||||
inputm.vin[0].prevout.hash = output->GetId(); | inputm.vin[0].prevout.unspentid = output->GetUnspentid(); | ||||
inputm.vin[0].prevout.n = 0; | inputm.vin[0].prevout.n = 0; | ||||
inputm.vout.resize(1); | inputm.vout.resize(1); | ||||
inputm.vout[0].nValue = 1; | inputm.vout[0].nValue = 1; | ||||
inputm.vout[0].scriptPubKey = CScript(); | inputm.vout[0].scriptPubKey = CScript(); | ||||
bool ret = SignSignature(keystore, *output, inputm, 0, | bool ret = SignSignature(keystore, *output, inputm, 0, | ||||
SIGHASH_ALL | SIGHASH_FORKID); | SIGHASH_ALL | SIGHASH_FORKID); | ||||
BOOST_CHECK_EQUAL(ret, success); | BOOST_CHECK_EQUAL(ret, success); | ||||
CDataStream ssin(SER_NETWORK, PROTOCOL_VERSION); | CDataStream ssin(SER_NETWORK, PROTOCOL_VERSION); | ||||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(test_IsStandard) { | ||||
CBasicKeyStore keystore; | CBasicKeyStore keystore; | ||||
CCoinsView coinsDummy; | CCoinsView coinsDummy; | ||||
CCoinsViewCache coins(&coinsDummy); | CCoinsViewCache coins(&coinsDummy); | ||||
std::vector<CMutableTransaction> dummyTransactions = | std::vector<CMutableTransaction> dummyTransactions = | ||||
SetupDummyInputs(keystore, coins); | SetupDummyInputs(keystore, coins); | ||||
CMutableTransaction t; | CMutableTransaction t; | ||||
t.vin.resize(1); | t.vin.resize(1); | ||||
t.vin[0].prevout.hash = dummyTransactions[0].GetId(); | t.vin[0].prevout.unspentid = dummyTransactions[0].GetUnspentid(); | ||||
t.vin[0].prevout.n = 1; | t.vin[0].prevout.n = 1; | ||||
t.vin[0].scriptSig << std::vector<uint8_t>(65, 0); | t.vin[0].scriptSig << std::vector<uint8_t>(65, 0); | ||||
t.vout.resize(1); | t.vout.resize(1); | ||||
t.vout[0].nValue = 90 * CENT.GetSatoshis(); | t.vout[0].nValue = 90 * CENT.GetSatoshis(); | ||||
CKey key; | CKey key; | ||||
key.MakeNewKey(true); | key.MakeNewKey(true); | ||||
t.vout[0].scriptPubKey = GetScriptForDestination(key.GetPubKey().GetID()); | t.vout[0].scriptPubKey = GetScriptForDestination(key.GetPubKey().GetID()); | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |