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 33// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44
55#include < arith_uint256.h>
6+ #include < policy/feerate.h>
67#include < util/feefrac.h>
78#include < test/fuzz/FuzzedDataProvider.h>
89#include < test/fuzz/fuzz.h>
@@ -217,5 +218,16 @@ FUZZ_TARGET(feefrac_mul_div)
217218 FeeFrac{mul64, div}.EvaluateFeeDown (mul32) :
218219 FeeFrac{mul64, div}.EvaluateFeeUp (mul32);
219220 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+ }
220232 }
221233}
You can’t perform that action at this time.
0 commit comments