Changeset View
Changeset View
Standalone View
Standalone View
src/test/policyestimator_tests.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) { | ||||
while (blocknum < 200) { | while (blocknum < 200) { | ||||
// For each fee | // For each fee | ||||
for (size_t j = 0; j < txIds.size(); j++) { | for (size_t j = 0; j < txIds.size(); j++) { | ||||
// add 4 fee txs | // add 4 fee txs | ||||
for (int k = 0; k < 4; k++) { | for (int k = 0; k < 4; k++) { | ||||
// make transaction unique | // make transaction unique | ||||
tx.vin[0].nSequence = 10000 * blocknum + 100 * j + k; | tx.vin[0].nSequence = 10000 * blocknum + 100 * j + k; | ||||
TxId txid = tx.GetId(); | TxId txid = tx.GetId(); | ||||
mpool.addUnchecked(txid, | mpool.addUnchecked(txid, entry.Fee(feeV[j]) | ||||
entry.Fee(feeV[j]) | |||||
.Time(GetTime()) | .Time(GetTime()) | ||||
.Priority(0) | .Priority(0) | ||||
.Height(blocknum) | .Height(blocknum) | ||||
.FromTx(tx, &mpool)); | .FromTx(tx, &mpool)); | ||||
txIds[j].push_back(txid); | txIds[j].push_back(txid); | ||||
} | } | ||||
} | } | ||||
// Create blocks where higher fee txs are included more often | // Create blocks where higher fee txs are included more often | ||||
for (size_t h = 0; h <= blocknum % txIds.size(); h++) { | for (size_t h = 0; h <= blocknum % txIds.size(); h++) { | ||||
// 10/10 blocks add highest fee transactions | // 10/10 blocks add highest fee transactions | ||||
// 9/10 blocks add 2nd highest and so on until ... | // 9/10 blocks add 2nd highest and so on until ... | ||||
// 1/10 blocks add lowest fee transactions | // 1/10 blocks add lowest fee transactions | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) { | ||||
// mined. Estimates should go up | // mined. Estimates should go up | ||||
while (blocknum < 265) { | while (blocknum < 265) { | ||||
// For each fee multiple | // For each fee multiple | ||||
for (size_t j = 0; j < txIds.size(); j++) { | for (size_t j = 0; j < txIds.size(); j++) { | ||||
// add 4 fee txs | // add 4 fee txs | ||||
for (int k = 0; k < 4; k++) { | for (int k = 0; k < 4; k++) { | ||||
tx.vin[0].nSequence = 10000 * blocknum + 100 * j + k; | tx.vin[0].nSequence = 10000 * blocknum + 100 * j + k; | ||||
TxId txid = tx.GetId(); | TxId txid = tx.GetId(); | ||||
mpool.addUnchecked(txid, | mpool.addUnchecked(txid, entry.Fee(feeV[j]) | ||||
entry.Fee(feeV[j]) | |||||
.Time(GetTime()) | .Time(GetTime()) | ||||
.Priority(0) | .Priority(0) | ||||
.Height(blocknum) | .Height(blocknum) | ||||
.FromTx(tx, &mpool)); | .FromTx(tx, &mpool)); | ||||
txIds[j].push_back(txid); | txIds[j].push_back(txid); | ||||
} | } | ||||
} | } | ||||
mpool.removeForBlock(block, ++blocknum); | mpool.removeForBlock(block, ++blocknum); | ||||
} | } | ||||
int answerFound; | int answerFound; | ||||
for (int i = 1; i < 10; i++) { | for (int i = 1; i < 10; i++) { | ||||
Show All 28 Lines | BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) { | ||||
// Estimates should be below original estimates | // Estimates should be below original estimates | ||||
while (blocknum < 465) { | while (blocknum < 465) { | ||||
// For each fee multiple | // For each fee multiple | ||||
for (size_t j = 0; j < txIds.size(); j++) { | for (size_t j = 0; j < txIds.size(); j++) { | ||||
// add 4 fee txs | // add 4 fee txs | ||||
for (int k = 0; k < 4; k++) { | for (int k = 0; k < 4; k++) { | ||||
tx.vin[0].nSequence = 10000 * blocknum + 100 * j + k; | tx.vin[0].nSequence = 10000 * blocknum + 100 * j + k; | ||||
TxId txid = tx.GetId(); | TxId txid = tx.GetId(); | ||||
mpool.addUnchecked(txid, | mpool.addUnchecked(txid, entry.Fee(feeV[j]) | ||||
entry.Fee(feeV[j]) | |||||
.Time(GetTime()) | .Time(GetTime()) | ||||
.Priority(0) | .Priority(0) | ||||
.Height(blocknum) | .Height(blocknum) | ||||
.FromTx(tx, &mpool)); | .FromTx(tx, &mpool)); | ||||
CTransactionRef ptx = mpool.get(txid); | CTransactionRef ptx = mpool.get(txid); | ||||
if (ptx) { | if (ptx) { | ||||
block.push_back(ptx); | block.push_back(ptx); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
mpool.removeForBlock(block, ++blocknum); | mpool.removeForBlock(block, ++blocknum); | ||||
block.clear(); | block.clear(); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 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, | 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()) | ||||
.Priority(0) | .Priority(0) | ||||
.Height(blocknum) | .Height(blocknum) | ||||
.FromTx(tx, &mpool)); | .FromTx(tx, &mpool)); | ||||
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 | // Check that the estimate is above the rolling minimum fee. This should | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |