Changeset View
Changeset View
Standalone View
Standalone View
src/test/policyestimator_tests.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | while (blocknum < 200) { | ||||
block.push_back(ptx); | block.push_back(ptx); | ||||
} | } | ||||
mpool.removeForBlock(block, ++blocknum); | mpool.removeForBlock(block, ++blocknum); | ||||
block.clear(); | block.clear(); | ||||
} | } | ||||
// Check that the estimate is above the rolling minimum fee. This should | // Check that the estimate is above the rolling minimum fee. This should | ||||
// be true since we have not trimmed the mempool. | // be true since we have not trimmed the mempool. | ||||
BOOST_CHECK(CFeeRate(Amount::zero()) == mpool.estimateFee(1)); | BOOST_CHECK(CFeeRate(Amount::zero()) == mpool.estimateFee()); | ||||
BOOST_CHECK(mpool.GetMinFee(1) <= mpool.estimateFee(2)); | BOOST_CHECK(mpool.GetMinFee(1) <= mpool.estimateFee()); | ||||
BOOST_CHECK(mpool.GetMinFee(1) <= mpool.estimateFee(3)); | |||||
BOOST_CHECK(mpool.GetMinFee(1) <= mpool.estimateFee(4)); | |||||
BOOST_CHECK(mpool.GetMinFee(1) <= mpool.estimateFee(5)); | |||||
// Check that estimateFee returns the minimum rolling fee even when the | // Check that estimateFee returns the minimum rolling fee even when the | ||||
// mempool grows very quickly and no blocks have been mined. | // mempool grows very quickly and no blocks have been mined. | ||||
// Add a bunch of low fee transactions which are not in the mempool | // Add a bunch of low fee transactions which are not in the mempool | ||||
// And have zero fees. | // And have zero fees. | ||||
CMutableTransaction mtx; | CMutableTransaction mtx; | ||||
tx.vin.resize(1); | tx.vin.resize(1); | ||||
Show All 21 Lines | BOOST_AUTO_TEST_CASE(MempoolMinimumFeeEstimate) { | ||||
// DEFAULT_BLOCK_MIN_TX_FEE_PER_KB But the estimateFee should be | // DEFAULT_BLOCK_MIN_TX_FEE_PER_KB But the estimateFee should be | ||||
// unchanged. | // unchanged. | ||||
mpool.TrimToSize(1); | mpool.TrimToSize(1); | ||||
BOOST_CHECK(mpool.GetMinFee(1) >= | BOOST_CHECK(mpool.GetMinFee(1) >= | ||||
CFeeRate(10000 * DEFAULT_BLOCK_MIN_TX_FEE_PER_KB, | CFeeRate(10000 * DEFAULT_BLOCK_MIN_TX_FEE_PER_KB, | ||||
CTransaction(tx).GetTotalSize())); | CTransaction(tx).GetTotalSize())); | ||||
for (int i = 1; i < 10; i++) { | BOOST_CHECK_MESSAGE(mpool.estimateFee() == mpool.GetMinFee(1), | ||||
BOOST_CHECK_MESSAGE(mpool.estimateFee(i) == mpool.GetMinFee(1), | "Confirm blocks has failed"); | ||||
"Confirm blocks has failed on iteration " << i); | |||||
} | |||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |