routing: skip fuzzing when capacity is 0

probabilityFormula() is expected to return an error if capacity is 0, so
we should exclude that case from fuzzing.

Previously it was attempted to avoid this case by seeding the corpus
with an input that had capacity 1. That is not an effective solution
since the fuzzer can still generate an input with capacity 0.
This commit is contained in:
Matt Morehouse 2024-09-10 15:17:39 -05:00
parent 65046561c4
commit 8373cca43c
No known key found for this signature in database
GPG Key ID: CC8ECA224831C982

View File

@ -692,10 +692,11 @@ func FuzzProbability(f *testing.F) {
BimodalConfig: BimodalConfig{BimodalScaleMsat: scale},
}
// We don't start fuzzing at zero, because that would cause an error.
f.Add(uint64(1), uint64(0), uint64(0), uint64(0))
f.Fuzz(func(t *testing.T, capacity, successAmt, failAmt, amt uint64) {
if capacity == 0 {
return
}
_, err := estimator.probabilityFormula(
lnwire.MilliSatoshi(capacity),
lnwire.MilliSatoshi(successAmt),