Return fuzzed amount ~= target, but never exceeding max */
| 3512 | |
| 3513 | /* Return fuzzed amount ~= target, but never exceeding max */ |
| 3514 | static struct amount_msat fuzzed_near(struct amount_msat target, |
| 3515 | struct amount_msat max) |
| 3516 | { |
| 3517 | s64 fuzz; |
| 3518 | struct amount_msat res = target; |
| 3519 | |
| 3520 | /* Somewhere within 25% of target please. */ |
| 3521 | fuzz = pseudorand(target.millisatoshis / 2) /* Raw: fuzz */ |
| 3522 | - target.millisatoshis / 4; /* Raw: fuzz */ |
| 3523 | res.millisatoshis = target.millisatoshis + fuzz; /* Raw: fuzz < msat */ |
| 3524 | |
| 3525 | if (amount_msat_greater(res, max)) |
| 3526 | res = max; |
| 3527 | return res; |
| 3528 | } |
| 3529 | |
| 3530 | static void presplit_cb(struct presplit_mod_data *d, struct payment *p) |
| 3531 | { |
no test coverage detected