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

Function apply_fuzz

plugins/funder_policy.c:151–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151static struct amount_sat
152apply_fuzz(u32 fuzz_factor, struct amount_sat val)
153{
154 s32 fuzz_percent;
155 s64 fuzz;
156 bool ok;
157 /* Don't even deal with stupid numbers. */
158 if ((s64)val.satoshis < 0) /* Raw: val check */
159 return AMOUNT_SAT(0);
160
161 fuzz_percent = pseudorand((fuzz_factor * 2) + 1) - fuzz_factor;
162 fuzz = (s64)val.satoshis * fuzz_percent / 100; /* Raw: fuzzing */
163 if (fuzz > 0)
164 ok = amount_sat_add(&val, val, amount_sat(fuzz));
165 else
166 ok = amount_sat_sub(&val, val, amount_sat(fuzz * -1));
167
168 assert(ok);
169 return val;
170}
171
172static struct amount_sat
173apply_policy(struct funder_policy *policy,

Callers 1

calculate_our_fundingFunction · 0.85

Calls 4

amount_satClass · 0.70
pseudorandFunction · 0.50
amount_sat_addFunction · 0.50
amount_sat_subFunction · 0.50

Tested by

no test coverage detected