|
|
@ -95,25 +95,31 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) |
|
|
|
// Highest feerate is 10*baseRate and gets in all blocks,
|
|
|
|
// Highest feerate is 10*baseRate and gets in all blocks,
|
|
|
|
// second highest feerate is 9*baseRate and gets in 9/10 blocks = 90%,
|
|
|
|
// second highest feerate is 9*baseRate and gets in 9/10 blocks = 90%,
|
|
|
|
// third highest feerate is 8*base rate, and gets in 8/10 blocks = 80%,
|
|
|
|
// third highest feerate is 8*base rate, and gets in 8/10 blocks = 80%,
|
|
|
|
// so estimateFee(1) should return 10*baseRate.
|
|
|
|
// so estimateFee(1) would return 10*baseRate but is hardcoded to return failure
|
|
|
|
// Second highest feerate has 100% chance of being included by 2 blocks,
|
|
|
|
// Second highest feerate has 100% chance of being included by 2 blocks,
|
|
|
|
// so estimateFee(2) should return 9*baseRate etc...
|
|
|
|
// so estimateFee(2) should return 9*baseRate etc...
|
|
|
|
for (int i = 1; i < 10;i++) { |
|
|
|
for (int i = 1; i < 10;i++) { |
|
|
|
origFeeEst.push_back(mpool.estimateFee(i).GetFeePerK()); |
|
|
|
origFeeEst.push_back(mpool.estimateFee(i).GetFeePerK()); |
|
|
|
if (i > 1) { // Fee estimates should be monotonically decreasing
|
|
|
|
if (i > 2) { // Fee estimates should be monotonically decreasing
|
|
|
|
BOOST_CHECK(origFeeEst[i-1] <= origFeeEst[i-2]); |
|
|
|
BOOST_CHECK(origFeeEst[i-1] <= origFeeEst[i-2]); |
|
|
|
} |
|
|
|
} |
|
|
|
int mult = 11-i; |
|
|
|
int mult = 11-i; |
|
|
|
|
|
|
|
if (i > 1) { |
|
|
|
BOOST_CHECK(origFeeEst[i-1] < mult*baseRate.GetFeePerK() + deltaFee); |
|
|
|
BOOST_CHECK(origFeeEst[i-1] < mult*baseRate.GetFeePerK() + deltaFee); |
|
|
|
BOOST_CHECK(origFeeEst[i-1] > mult*baseRate.GetFeePerK() - deltaFee); |
|
|
|
BOOST_CHECK(origFeeEst[i-1] > mult*baseRate.GetFeePerK() - deltaFee); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
BOOST_CHECK(origFeeEst[i-1] == CFeeRate(0).GetFeePerK()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Mine 50 more blocks with no transactions happening, estimates shouldn't change
|
|
|
|
// Mine 50 more blocks with no transactions happening, estimates shouldn't change
|
|
|
|
// We haven't decayed the moving average enough so we still have enough data points in every bucket
|
|
|
|
// We haven't decayed the moving average enough so we still have enough data points in every bucket
|
|
|
|
while (blocknum < 250) |
|
|
|
while (blocknum < 250) |
|
|
|
mpool.removeForBlock(block, ++blocknum); |
|
|
|
mpool.removeForBlock(block, ++blocknum); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < 10;i++) { |
|
|
|
BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(0)); |
|
|
|
|
|
|
|
for (int i = 2; i < 10;i++) { |
|
|
|
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() < origFeeEst[i-1] + deltaFee); |
|
|
|
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() < origFeeEst[i-1] + deltaFee); |
|
|
|
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() > origFeeEst[i-1] - deltaFee); |
|
|
|
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() > origFeeEst[i-1] - deltaFee); |
|
|
|
} |
|
|
|
} |
|
|
@ -151,7 +157,8 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) |
|
|
|
} |
|
|
|
} |
|
|
|
mpool.removeForBlock(block, 265); |
|
|
|
mpool.removeForBlock(block, 265); |
|
|
|
block.clear(); |
|
|
|
block.clear(); |
|
|
|
for (int i = 1; i < 10;i++) { |
|
|
|
BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(0)); |
|
|
|
|
|
|
|
for (int i = 2; i < 10;i++) { |
|
|
|
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() > origFeeEst[i-1] - deltaFee); |
|
|
|
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() > origFeeEst[i-1] - deltaFee); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -172,7 +179,8 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) |
|
|
|
mpool.removeForBlock(block, ++blocknum); |
|
|
|
mpool.removeForBlock(block, ++blocknum); |
|
|
|
block.clear(); |
|
|
|
block.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
for (int i = 1; i < 10; i++) { |
|
|
|
BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(0)); |
|
|
|
|
|
|
|
for (int i = 2; i < 10; i++) { |
|
|
|
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() < origFeeEst[i-1] - deltaFee); |
|
|
|
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() < origFeeEst[i-1] - deltaFee); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|