@@ -90,6 +90,11 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
90
90
BOOST_CHECK (mpool.estimateFee (3 ) == CFeeRate (0 ));
91
91
BOOST_CHECK (mpool.estimateFee (4 ).GetFeePerK () < 8 *baseRate.GetFeePerK () + deltaFee);
92
92
BOOST_CHECK (mpool.estimateFee (4 ).GetFeePerK () > 8 *baseRate.GetFeePerK () - deltaFee);
93
+ int answerFound;
94
+ BOOST_CHECK (mpool.estimateSmartFee (1 , &answerFound) == mpool.estimateFee (4 ) && answerFound == 4 );
95
+ BOOST_CHECK (mpool.estimateSmartFee (3 , &answerFound) == mpool.estimateFee (4 ) && answerFound == 4 );
96
+ BOOST_CHECK (mpool.estimateSmartFee (4 , &answerFound) == mpool.estimateFee (4 ) && answerFound == 4 );
97
+ BOOST_CHECK (mpool.estimateSmartFee (8 , &answerFound) == mpool.estimateFee (8 ) && answerFound == 8 );
93
98
}
94
99
}
95
100
@@ -142,9 +147,12 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
142
147
mpool.removeForBlock (block, ++blocknum, dummyConflicted);
143
148
}
144
149
150
+ int answerFound;
145
151
for (int i = 1 ; i < 10 ;i++) {
146
152
BOOST_CHECK (mpool.estimateFee (i) == CFeeRate (0 ) || mpool.estimateFee (i).GetFeePerK () > origFeeEst[i-1 ] - deltaFee);
153
+ BOOST_CHECK (mpool.estimateSmartFee (i, &answerFound).GetFeePerK () > origFeeEst[answerFound-1 ] - deltaFee);
147
154
BOOST_CHECK (mpool.estimatePriority (i) == -1 || mpool.estimatePriority (i) > origPriEst[i-1 ] - deltaPri);
155
+ BOOST_CHECK (mpool.estimateSmartPriority (i, &answerFound) > origPriEst[answerFound-1 ] - deltaPri);
148
156
}
149
157
150
158
// Mine all those transactions
@@ -184,6 +192,18 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
184
192
BOOST_CHECK (mpool.estimateFee (i).GetFeePerK () < origFeeEst[i-1 ] - deltaFee);
185
193
BOOST_CHECK (mpool.estimatePriority (i) < origPriEst[i-1 ] - deltaPri);
186
194
}
195
+
196
+ // Test that if the mempool is limited, estimateSmartFee won't return a value below the mempool min fee
197
+ // and that estimateSmartPriority returns essentially an infinite value
198
+ mpool.addUnchecked (tx.GetHash (), CTxMemPoolEntry (tx, feeV[0 ][5 ], GetTime (), priV[1 ][5 ], blocknum, mpool.HasNoInputsOf (tx)));
199
+ // evict that transaction which should set a mempool min fee of minRelayTxFee + feeV[0][5]
200
+ mpool.TrimToSize (1 );
201
+ BOOST_CHECK (mpool.GetMinFee (1 ).GetFeePerK () > feeV[0 ][5 ]);
202
+ for (int i = 1 ; i < 10 ; i++) {
203
+ BOOST_CHECK (mpool.estimateSmartFee (i).GetFeePerK () >= mpool.estimateFee (i).GetFeePerK ());
204
+ BOOST_CHECK (mpool.estimateSmartFee (i).GetFeePerK () >= mpool.GetMinFee (1 ).GetFeePerK ());
205
+ BOOST_CHECK (mpool.estimateSmartPriority (i) == INF_PRIORITY);
206
+ }
187
207
}
188
208
189
209
BOOST_AUTO_TEST_SUITE_END ()
0 commit comments