From 615b617cdac44bdb318e93540a1d72a424512943 Mon Sep 17 00:00:00 2001 From: bitromortac Date: Thu, 7 Nov 2024 11:56:46 +0100 Subject: [PATCH] routing: add test for fuzz test special case This test demonstrates an error found in a fuzz test by adding a previously found seed, which will be fixed in an upcoming commit. The following fuzz test is expected to fail: go test -v -fuzz=Prob ./routing/ --- routing/probability_bimodal_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/routing/probability_bimodal_test.go b/routing/probability_bimodal_test.go index e78f07ca8..e9be28f43 100644 --- a/routing/probability_bimodal_test.go +++ b/routing/probability_bimodal_test.go @@ -690,6 +690,21 @@ func FuzzProbability(f *testing.F) { BimodalConfig: BimodalConfig{BimodalScaleMsat: 400_000}, } + // Predefined seed reported in + // https://github.com/lightningnetwork/lnd/issues/9085. This test found + // a case where we could not compute a normalization factor because we + // learned that the balance lies somewhere in the middle of the channel, + // a surprising result for the bimodal model, which predicts two + // distinct modes at the edges and therefore has numerical issues in the + // middle. Additionally, the scale is small with respect to the values + // used here. + f.Add( + uint64(1_000_000_000), + uint64(300_000_000), + uint64(400_000_000), + uint64(300_000_000), + ) + f.Fuzz(func(t *testing.T, capacity, successAmt, failAmt, amt uint64) { if capacity == 0 { return