@@ -83,11 +83,13 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
83
83
block.clear ();
84
84
if (blocknum == 30 ) {
85
85
// At this point we should need to combine 5 buckets to get enough data points
86
- // So estimateFee(1) should fail and estimateFee(2 ) should return somewhere around
87
- // 8*baserate
86
+ // So estimateFee(1,2,3 ) should fail and estimateFee(4 ) should return somewhere around
87
+ // 8*baserate. estimateFee(4) %'s are 100,100,100,100,90 = average 98%
88
88
BOOST_CHECK (mpool.estimateFee (1 ) == CFeeRate (0 ));
89
- BOOST_CHECK (mpool.estimateFee (2 ).GetFeePerK () < 8 *baseRate.GetFeePerK () + deltaFee);
90
- BOOST_CHECK (mpool.estimateFee (2 ).GetFeePerK () > 8 *baseRate.GetFeePerK () - deltaFee);
89
+ BOOST_CHECK (mpool.estimateFee (2 ) == CFeeRate (0 ));
90
+ BOOST_CHECK (mpool.estimateFee (3 ) == CFeeRate (0 ));
91
+ BOOST_CHECK (mpool.estimateFee (4 ).GetFeePerK () < 8 *baseRate.GetFeePerK () + deltaFee);
92
+ BOOST_CHECK (mpool.estimateFee (4 ).GetFeePerK () > 8 *baseRate.GetFeePerK () - deltaFee);
91
93
}
92
94
}
93
95
@@ -96,20 +98,21 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
96
98
// Highest feerate is 10*baseRate and gets in all blocks,
97
99
// second highest feerate is 9*baseRate and gets in 9/10 blocks = 90%,
98
100
// third highest feerate is 8*base rate, and gets in 8/10 blocks = 80%,
99
- // so estimateFee(1) should return 9 *baseRate.
100
- // Third highest feerate has 90 % chance of being included by 2 blocks,
101
- // so estimateFee(2) should return 8 *baseRate etc...
101
+ // so estimateFee(1) should return 10 *baseRate.
102
+ // Second highest feerate has 100 % chance of being included by 2 blocks,
103
+ // so estimateFee(2) should return 9 *baseRate etc...
102
104
for (int i = 1 ; i < 10 ;i++) {
103
105
origFeeEst.push_back (mpool.estimateFee (i).GetFeePerK ());
104
106
origPriEst.push_back (mpool.estimatePriority (i));
105
107
if (i > 1 ) { // Fee estimates should be monotonically decreasing
106
108
BOOST_CHECK (origFeeEst[i-1 ] <= origFeeEst[i-2 ]);
107
109
BOOST_CHECK (origPriEst[i-1 ] <= origPriEst[i-2 ]);
108
110
}
109
- BOOST_CHECK (origFeeEst[i-1 ] < (10 -i)*baseRate.GetFeePerK () + deltaFee);
110
- BOOST_CHECK (origFeeEst[i-1 ] > (10 -i)*baseRate.GetFeePerK () - deltaFee);
111
- BOOST_CHECK (origPriEst[i-1 ] < pow (10 ,10 -i) * basepri + deltaPri);
112
- BOOST_CHECK (origPriEst[i-1 ] > pow (10 ,10 -i) * basepri - deltaPri);
111
+ int mult = 11 -i;
112
+ BOOST_CHECK (origFeeEst[i-1 ] < mult*baseRate.GetFeePerK () + deltaFee);
113
+ BOOST_CHECK (origFeeEst[i-1 ] > mult*baseRate.GetFeePerK () - deltaFee);
114
+ BOOST_CHECK (origPriEst[i-1 ] < pow (10 ,mult) * basepri + deltaPri);
115
+ BOOST_CHECK (origPriEst[i-1 ] > pow (10 ,mult) * basepri - deltaPri);
113
116
}
114
117
115
118
// Mine 50 more blocks with no transactions happening, estimates shouldn't change
@@ -140,8 +143,8 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
140
143
}
141
144
142
145
for (int i = 1 ; i < 10 ;i++) {
143
- BOOST_CHECK (mpool.estimateFee (i).GetFeePerK () > origFeeEst[i-1 ] - deltaFee);
144
- BOOST_CHECK (mpool.estimatePriority (i) > origPriEst[i-1 ] - deltaPri);
146
+ BOOST_CHECK (mpool.estimateFee (i) == CFeeRate ( 0 ) || mpool. estimateFee (i) .GetFeePerK () > origFeeEst[i-1 ] - deltaFee);
147
+ BOOST_CHECK (mpool.estimatePriority (i) == - 1 || mpool. estimatePriority (i) > origPriEst[i-1 ] - deltaPri);
145
148
}
146
149
147
150
// Mine all those transactions
@@ -161,9 +164,9 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
161
164
BOOST_CHECK (mpool.estimatePriority (i) > origPriEst[i-1 ] - deltaPri);
162
165
}
163
166
164
- // Mine 100 more blocks where everything is mined every block
165
- // Estimates should be below original estimates (not possible for last estimate)
166
- while (blocknum < 365 ) {
167
+ // Mine 200 more blocks where everything is mined every block
168
+ // Estimates should be below original estimates
169
+ while (blocknum < 465 ) {
167
170
for (int j = 0 ; j < 10 ; j++) { // For each fee/pri multiple
168
171
for (int k = 0 ; k < 5 ; k++) { // add 4 fee txs for every priority tx
169
172
tx.vin [0 ].prevout .n = 10000 *blocknum+100 *j+k;
@@ -177,7 +180,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
177
180
mpool.removeForBlock (block, ++blocknum, dummyConflicted);
178
181
block.clear ();
179
182
}
180
- for (int i = 1 ; i < 9 ; i++) {
183
+ for (int i = 1 ; i < 10 ; i++) {
181
184
BOOST_CHECK (mpool.estimateFee (i).GetFeePerK () < origFeeEst[i-1 ] - deltaFee);
182
185
BOOST_CHECK (mpool.estimatePriority (i) < origPriEst[i-1 ] - deltaPri);
183
186
}
0 commit comments