Changeset View
Changeset View
Standalone View
Standalone View
src/test/transaction_tests.cpp
Show First 20 Lines • Show All 293 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.hash = dummyTransactions[0].GetHash(); | ||||
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.hash = dummyTransactions[1].GetHash(); | ||||
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.hash = dummyTransactions[1].GetHash(); | ||||
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.hash = output->GetHash(); | ||||
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.hash = dummyTransactions[0].GetHash(); | ||||
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 |