Changeset View
Changeset View
Standalone View
Standalone View
src/test/policyestimator_tests.cpp
Show All 11 Lines | |||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
BOOST_FIXTURE_TEST_SUITE(policyestimator_tests, BasicTestingSetup) | BOOST_FIXTURE_TEST_SUITE(policyestimator_tests, BasicTestingSetup) | ||||
BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) { | BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) { | ||||
CTxMemPool mpool(CFeeRate(1000)); | CTxMemPool mpool(CFeeRate(1000)); | ||||
TestMemPoolEntryHelper entry; | TestMemPoolEntryHelper entry; | ||||
CAmount basefee(2000); | Amount basefee(2000); | ||||
CAmount deltaFee(100); | Amount deltaFee(100); | ||||
std::vector<CAmount> feeV; | std::vector<Amount> feeV; | ||||
// Populate vectors of increasing fees | // Populate vectors of increasing fees | ||||
for (int j = 0; j < 10; j++) { | for (int j = 0; j < 10; j++) { | ||||
feeV.push_back(basefee * (j + 1)); | feeV.push_back((j + 1) * basefee); | ||||
} | } | ||||
// Store the hashes of transactions that have been added to the mempool by | // Store the hashes of transactions that have been added to the mempool by | ||||
// their associate fee txHashes[j] is populated with transactions either of | // their associate fee txHashes[j] is populated with transactions either of | ||||
// fee = basefee * (j+1) | // fee = basefee * (j+1) | ||||
std::vector<uint256> txHashes[10]; | std::vector<uint256> txHashes[10]; | ||||
// Create a transaction template | // Create a transaction template | ||||
▲ Show 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) { | ||||
// minRelayTxFee + feeV[5] | // minRelayTxFee + feeV[5] | ||||
mpool.TrimToSize(1); | mpool.TrimToSize(1); | ||||
BOOST_CHECK(mpool.GetMinFee(1).GetFeePerK() > feeV[5]); | BOOST_CHECK(mpool.GetMinFee(1).GetFeePerK() > feeV[5]); | ||||
for (int i = 1; i < 10; i++) { | for (int i = 1; i < 10; i++) { | ||||
BOOST_CHECK(mpool.estimateSmartFee(i).GetFeePerK() >= | BOOST_CHECK(mpool.estimateSmartFee(i).GetFeePerK() >= | ||||
mpool.estimateFee(i).GetFeePerK()); | mpool.estimateFee(i).GetFeePerK()); | ||||
BOOST_CHECK(mpool.estimateSmartFee(i).GetFeePerK() >= | BOOST_CHECK(mpool.estimateSmartFee(i).GetFeePerK() >= | ||||
mpool.GetMinFee(1).GetFeePerK()); | mpool.GetMinFee(1).GetFeePerK()); | ||||
BOOST_CHECK(mpool.estimateSmartPriority(i) == INF_PRIORITY); | BOOST_CHECK(mpool.estimateSmartPriority(i) == | ||||
double(INF_PRIORITY.GetSatoshis())); | |||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |