Changeset View
Changeset View
Standalone View
Standalone View
src/test/miner_tests.cpp
Show First 20 Lines • Show All 322 Lines • ▼ Show 20 Lines | tx.vin[0].scriptSig = CScript() << OP_0 << OP_0 << OP_0 << OP_NOP | ||||
<< OP_CHECKMULTISIG << OP_1; | << OP_CHECKMULTISIG << OP_1; | ||||
tx.vin[0].prevout = COutPoint(txFirst[0]->GetId(), 0); | tx.vin[0].prevout = COutPoint(txFirst[0]->GetId(), 0); | ||||
tx.vout.resize(1); | tx.vout.resize(1); | ||||
tx.vout[0].nValue = BLOCKSUBSIDY; | tx.vout[0].nValue = BLOCKSUBSIDY; | ||||
for (unsigned int i = 0; i < 1001; ++i) { | for (unsigned int i = 0; i < 1001; ++i) { | ||||
tx.vout[0].nValue -= LOWFEE; | tx.vout[0].nValue -= LOWFEE; | ||||
hash = tx.GetId(); | hash = tx.GetId(); | ||||
// Only first tx spends coinbase. | // Only first tx spends coinbase. | ||||
bool spendsCoinbase = (i == 0) ? true : false; | bool spendsCoinbase = i == 0; | ||||
// If we don't set the # of sig ops in the CTxMemPoolEntry, template | // If we don't set the # of sig ops in the CTxMemPoolEntry, template | ||||
// creation fails. | // creation fails. | ||||
g_mempool.addUnchecked(hash, entry.Fee(LOWFEE) | g_mempool.addUnchecked(hash, entry.Fee(LOWFEE) | ||||
.Time(GetTime()) | .Time(GetTime()) | ||||
.SpendsCoinbase(spendsCoinbase) | .SpendsCoinbase(spendsCoinbase) | ||||
.FromTx(tx)); | .FromTx(tx)); | ||||
tx.vin[0].prevout = COutPoint(hash, 0); | tx.vin[0].prevout = COutPoint(hash, 0); | ||||
} | } | ||||
BOOST_CHECK_THROW( | BOOST_CHECK_THROW( | ||||
BlockAssembler(config, g_mempool).CreateNewBlock(scriptPubKey), | BlockAssembler(config, g_mempool).CreateNewBlock(scriptPubKey), | ||||
std::runtime_error); | std::runtime_error); | ||||
g_mempool.clear(); | g_mempool.clear(); | ||||
tx.vin[0].prevout = COutPoint(txFirst[0]->GetId(), 0); | tx.vin[0].prevout = COutPoint(txFirst[0]->GetId(), 0); | ||||
tx.vout[0].nValue = BLOCKSUBSIDY; | tx.vout[0].nValue = BLOCKSUBSIDY; | ||||
for (unsigned int i = 0; i < 1001; ++i) { | for (unsigned int i = 0; i < 1001; ++i) { | ||||
tx.vout[0].nValue -= LOWFEE; | tx.vout[0].nValue -= LOWFEE; | ||||
hash = tx.GetId(); | hash = tx.GetId(); | ||||
// Only first tx spends coinbase. | // Only first tx spends coinbase. | ||||
bool spendsCoinbase = (i == 0) ? true : false; | bool spendsCoinbase = i == 0; | ||||
// If we do set the # of sig ops in the CTxMemPoolEntry, template | // If we do set the # of sig ops in the CTxMemPoolEntry, template | ||||
// creation passes. | // creation passes. | ||||
g_mempool.addUnchecked(hash, entry.Fee(LOWFEE) | g_mempool.addUnchecked(hash, entry.Fee(LOWFEE) | ||||
.Time(GetTime()) | .Time(GetTime()) | ||||
.SpendsCoinbase(spendsCoinbase) | .SpendsCoinbase(spendsCoinbase) | ||||
.SigOpsCost(80) | .SigOpsCost(80) | ||||
.FromTx(tx)); | .FromTx(tx)); | ||||
tx.vin[0].prevout = COutPoint(hash, 0); | tx.vin[0].prevout = COutPoint(hash, 0); | ||||
Show All 13 Lines | BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) { | ||||
tx.vin[0].scriptSig << OP_1; | tx.vin[0].scriptSig << OP_1; | ||||
tx.vin[0].prevout = COutPoint(txFirst[0]->GetId(), 0); | tx.vin[0].prevout = COutPoint(txFirst[0]->GetId(), 0); | ||||
tx.vout[0].nValue = BLOCKSUBSIDY; | tx.vout[0].nValue = BLOCKSUBSIDY; | ||||
for (unsigned int i = 0; i < 128; ++i) { | for (unsigned int i = 0; i < 128; ++i) { | ||||
tx.vout[0].nValue -= LOWFEE; | tx.vout[0].nValue -= LOWFEE; | ||||
hash = tx.GetId(); | hash = tx.GetId(); | ||||
// Only first tx spends coinbase. | // Only first tx spends coinbase. | ||||
bool spendsCoinbase = (i == 0) ? true : false; | bool spendsCoinbase = i == 0; | ||||
g_mempool.addUnchecked(hash, entry.Fee(LOWFEE) | g_mempool.addUnchecked(hash, entry.Fee(LOWFEE) | ||||
.Time(GetTime()) | .Time(GetTime()) | ||||
.SpendsCoinbase(spendsCoinbase) | .SpendsCoinbase(spendsCoinbase) | ||||
.FromTx(tx)); | .FromTx(tx)); | ||||
tx.vin[0].prevout = COutPoint(hash, 0); | tx.vin[0].prevout = COutPoint(hash, 0); | ||||
} | } | ||||
BOOST_CHECK( | BOOST_CHECK( | ||||
pblocktemplate = | pblocktemplate = | ||||
▲ Show 20 Lines • Show All 384 Lines • Show Last 20 Lines |