Changeset View
Changeset View
Standalone View
Standalone View
src/test/policyestimator_tests.cpp
Show All 38 Lines | BOOST_AUTO_TEST_CASE(MempoolMinimumFeeEstimate) { | ||||
// Loop through 200 blocks adding transactions so we have a estimateFee | // Loop through 200 blocks adding transactions so we have a estimateFee | ||||
// that is calculable. | // that is calculable. | ||||
while (blocknum < 200) { | while (blocknum < 200) { | ||||
for (int64_t j = 0; j < 100; j++) { | for (int64_t j = 0; j < 100; j++) { | ||||
// make transaction unique | // make transaction unique | ||||
tx.vin[0].nSequence = 10000 * blocknum + j; | tx.vin[0].nSequence = 10000 * blocknum + j; | ||||
TxId txid = tx.GetId(); | TxId txid = tx.GetId(); | ||||
mpool.addUnchecked( | mpool.addUnchecked( | ||||
txid, entry.Fee((j + 1) * DEFAULT_BLOCK_MIN_TX_FEE_PER_KB) | entry.Fee((j + 1) * DEFAULT_BLOCK_MIN_TX_FEE_PER_KB) | ||||
.Time(GetTime()) | .Time(GetTime()) | ||||
.Height(blocknum) | .Height(blocknum) | ||||
.FromTx(tx)); | .FromTx(tx)); | ||||
CTransactionRef ptx = mpool.get(txid); | CTransactionRef ptx = mpool.get(txid); | ||||
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 be | // Check that the estimate is above the rolling minimum fee. This should be | ||||
Show All 14 Lines | BOOST_AUTO_TEST_CASE(MempoolMinimumFeeEstimate) { | ||||
// Add tons of transactions to the mempool, | // Add tons of transactions to the mempool, | ||||
// but don't mine them. | // but don't mine them. | ||||
for (int64_t i = 0; i < 10000; i++) { | for (int64_t i = 0; i < 10000; i++) { | ||||
// Mutate the hash | // Mutate the hash | ||||
tx.vin[0].nSequence = 10000 * blocknum + i; | tx.vin[0].nSequence = 10000 * blocknum + i; | ||||
// Add new transaction to the mempool with a increasing fee | // Add new transaction to the mempool with a increasing fee | ||||
// The average should end up as 1/2 * 100 * | // The average should end up as 1/2 * 100 * | ||||
// DEFAULT_BLOCK_MIN_TX_FEE_PER_KB | // DEFAULT_BLOCK_MIN_TX_FEE_PER_KB | ||||
mpool.addUnchecked(tx.GetId(), | mpool.addUnchecked(entry.Fee((i + 1) * DEFAULT_BLOCK_MIN_TX_FEE_PER_KB) | ||||
entry.Fee((i + 1) * DEFAULT_BLOCK_MIN_TX_FEE_PER_KB) | |||||
.Time(GetTime()) | .Time(GetTime()) | ||||
.Height(blocknum) | .Height(blocknum) | ||||
.FromTx(tx)); | .FromTx(tx)); | ||||
} | } | ||||
// Trim to size. GetMinFee should be more than 10000 * | // Trim to size. GetMinFee should be more than 10000 * | ||||
// 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. | ||||
Show All 11 Lines |