Changeset View
Changeset View
Standalone View
Standalone View
src/test/miner_tests.cpp
Show First 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | void MinerTestingSetup::TestPackageSelection( | ||||
TxId highFeeTxId = tx.GetId(); | TxId highFeeTxId = tx.GetId(); | ||||
m_node.mempool->addUnchecked(entry.Fee(50000 * SATOSHI) | m_node.mempool->addUnchecked(entry.Fee(50000 * SATOSHI) | ||||
.Time(GetTime()) | .Time(GetTime()) | ||||
.SpendsCoinbase(false) | .SpendsCoinbase(false) | ||||
.FromTx(tx)); | .FromTx(tx)); | ||||
std::unique_ptr<CBlockTemplate> pblocktemplate = | std::unique_ptr<CBlockTemplate> pblocktemplate = | ||||
AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey); | AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey); | ||||
BOOST_REQUIRE_EQUAL(pblocktemplate->block.vtx.size(), 4u); | |||||
BOOST_CHECK(pblocktemplate->block.vtx[1]->GetId() == parentTxId); | BOOST_CHECK(pblocktemplate->block.vtx[1]->GetId() == parentTxId); | ||||
BOOST_CHECK(pblocktemplate->block.vtx[2]->GetId() == highFeeTxId); | BOOST_CHECK(pblocktemplate->block.vtx[2]->GetId() == highFeeTxId); | ||||
BOOST_CHECK(pblocktemplate->block.vtx[3]->GetId() == mediumFeeTxId); | BOOST_CHECK(pblocktemplate->block.vtx[3]->GetId() == mediumFeeTxId); | ||||
// Test that a package below the block min tx fee doesn't get included | // Test that a package below the block min tx fee doesn't get included | ||||
tx.vin[0].prevout = COutPoint(highFeeTxId, 0); | tx.vin[0].prevout = COutPoint(highFeeTxId, 0); | ||||
// 0 fee. | // 0 fee. | ||||
tx.vout[0].nValue = int64_t(5000000000LL - 1000 - 50000) * SATOSHI; | tx.vout[0].nValue = int64_t(5000000000LL - 1000 - 50000) * SATOSHI; | ||||
Show All 22 Lines | void MinerTestingSetup::TestPackageSelection( | ||||
// transaction and replace with a higher fee transaction | // transaction and replace with a higher fee transaction | ||||
m_node.mempool->removeRecursive(CTransaction(tx), | m_node.mempool->removeRecursive(CTransaction(tx), | ||||
MemPoolRemovalReason::REPLACED); | MemPoolRemovalReason::REPLACED); | ||||
// Now we should be just over the min relay fee. | // Now we should be just over the min relay fee. | ||||
tx.vout[0].nValue -= 2 * SATOSHI; | tx.vout[0].nValue -= 2 * SATOSHI; | ||||
lowFeeTxId = tx.GetId(); | lowFeeTxId = tx.GetId(); | ||||
m_node.mempool->addUnchecked(entry.Fee(feeToUse + 2 * SATOSHI).FromTx(tx)); | m_node.mempool->addUnchecked(entry.Fee(feeToUse + 2 * SATOSHI).FromTx(tx)); | ||||
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey); | pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey); | ||||
BOOST_REQUIRE_EQUAL(pblocktemplate->block.vtx.size(), 6u); | |||||
BOOST_CHECK(pblocktemplate->block.vtx[4]->GetId() == freeTxId); | BOOST_CHECK(pblocktemplate->block.vtx[4]->GetId() == freeTxId); | ||||
BOOST_CHECK(pblocktemplate->block.vtx[5]->GetId() == lowFeeTxId); | BOOST_CHECK(pblocktemplate->block.vtx[5]->GetId() == lowFeeTxId); | ||||
// Test that transaction selection properly updates ancestor fee | // Test that transaction selection properly updates ancestor fee | ||||
// calculations as ancestor transactions get included in a block. Add a | // calculations as ancestor transactions get included in a block. Add a | ||||
// 0-fee transaction that has 2 outputs. | // 0-fee transaction that has 2 outputs. | ||||
tx.vin[0].prevout = COutPoint(txFirst[2]->GetId(), 0); | tx.vin[0].prevout = COutPoint(txFirst[2]->GetId(), 0); | ||||
tx.vout.resize(2); | tx.vout.resize(2); | ||||
Show All 22 Lines | void MinerTestingSetup::TestPackageSelection( | ||||
// This tx will be mineable, and should cause lowFeeTxId2 to be selected as | // This tx will be mineable, and should cause lowFeeTxId2 to be selected as | ||||
// well. | // well. | ||||
tx.vin[0].prevout = COutPoint(freeTxId2, 1); | tx.vin[0].prevout = COutPoint(freeTxId2, 1); | ||||
// 10k satoshi fee. | // 10k satoshi fee. | ||||
tx.vout[0].nValue = (100000000 - 10000) * SATOSHI; | tx.vout[0].nValue = (100000000 - 10000) * SATOSHI; | ||||
m_node.mempool->addUnchecked(entry.Fee(10000 * SATOSHI).FromTx(tx)); | m_node.mempool->addUnchecked(entry.Fee(10000 * SATOSHI).FromTx(tx)); | ||||
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey); | pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey); | ||||
BOOST_REQUIRE_EQUAL(pblocktemplate->block.vtx.size(), 9u); | |||||
BOOST_CHECK(pblocktemplate->block.vtx[8]->GetId() == lowFeeTxId2); | BOOST_CHECK(pblocktemplate->block.vtx[8]->GetId() == lowFeeTxId2); | ||||
} | } | ||||
static void TestCoinbaseMessageEB(uint64_t eb, std::string cbmsg, | static void TestCoinbaseMessageEB(uint64_t eb, std::string cbmsg, | ||||
const CTxMemPool &mempool, | const CTxMemPool &mempool, | ||||
const ChainstateManager &chainman) { | const ChainstateManager &chainman) { | ||||
GlobalConfig config; | GlobalConfig config; | ||||
config.SetMaxBlockSize(eb); | config.SetMaxBlockSize(eb); | ||||
▲ Show 20 Lines • Show All 544 Lines • Show Last 20 Lines |