MCPcopy Create free account
hub / github.com/ElementsProject/lightning / apply_fuzz

Function apply_fuzz

plugins/funder_policy.c:163–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163static struct amount_sat
164apply_fuzz(u32 fuzz_factor, struct amount_sat val)
165{
166 s32 fuzz_percent;
167 s64 fuzz;
168 bool ok;
169 /* Don't even deal with stupid numbers. */
170 if ((s64)val.satoshis < 0) /* Raw: val check */
171 return AMOUNT_SAT(0);
172
173 fuzz_percent = pseudorand((fuzz_factor * 2) + 1) - fuzz_factor;
174 fuzz = (s64)val.satoshis * fuzz_percent / 100; /* Raw: fuzzing */
175 if (fuzz > 0)
176 ok = amount_sat_add(&val, val, amount_sat(fuzz));
177 else
178 ok = amount_sat_sub(&val, val, amount_sat(fuzz * -1));
179
180 assert(ok);
181 return val;
182}
183
184static struct amount_sat
185apply_policy(struct funder_policy *policy,

Callers 1

calculate_our_fundingFunction · 0.85

Calls 3

amount_satClass · 0.70
amount_sat_addFunction · 0.50
amount_sat_subFunction · 0.50

Tested by

no test coverage detected