File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 3
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
5
5
#include < arith_uint256.h>
6
+ #include < policy/feerate.h>
6
7
#include < util/feefrac.h>
7
8
#include < test/fuzz/FuzzedDataProvider.h>
8
9
#include < test/fuzz/fuzz.h>
@@ -217,5 +218,16 @@ FUZZ_TARGET(feefrac_mul_div)
217
218
FeeFrac{mul64, div}.EvaluateFeeDown (mul32) :
218
219
FeeFrac{mul64, div}.EvaluateFeeUp (mul32);
219
220
assert (res == res_fee);
221
+
222
+ // Compare approximately with CFeeRate.
223
+ if (mul64 <= std::numeric_limits<int64_t >::max () / 1000 &&
224
+ mul64 >= std::numeric_limits<int64_t >::min () / 1000 &&
225
+ quot_abs <= arith_uint256{std::numeric_limits<int64_t >::max () / 1000 }) {
226
+ CFeeRate feerate (mul64, (uint32_t )div);
227
+ CAmount feerate_fee{feerate.GetFee (mul32)};
228
+ auto allowed_gap = static_cast <int64_t >(mul32 / 1000 + 3 + round_down);
229
+ assert (feerate_fee - res_fee >= -allowed_gap);
230
+ assert (feerate_fee - res_fee <= allowed_gap);
231
+ }
220
232
}
221
233
}
You can’t perform that action at this time.
0 commit comments