routing: use default tolerance for bimodal testing

This commit is contained in:
bitromortac committed 2025-05-02 10:24:22 +02:00
1 parent 55e7343b14
commit 04eec71d54
1 file changed
+5 -7
+5 -7
View File
@@ -15,6 +15,10 @@ const (
largeAmount = lnwire.MilliSatoshi(5_000_000_000) largeAmount = lnwire.MilliSatoshi(5_000_000_000)
capacity = lnwire.MilliSatoshi(10_000_000_000) capacity = lnwire.MilliSatoshi(10_000_000_000)
scale = lnwire.MilliSatoshi(400_000_000) scale = lnwire.MilliSatoshi(400_000_000)
// defaultTolerance is the default absolute tolerance for comparing
// probability calculations to expected values.
defaultTolerance = 0.001
) )
// TestSuccessProbability tests that we get correct probability estimates for // TestSuccessProbability tests that we get correct probability estimates for
@@ -25,7 +29,6 @@ func TestSuccessProbability(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
expectedProbability float64 expectedProbability float64
tolerance float64
successAmount lnwire.MilliSatoshi successAmount lnwire.MilliSatoshi
failAmount lnwire.MilliSatoshi failAmount lnwire.MilliSatoshi
amount lnwire.MilliSatoshi amount lnwire.MilliSatoshi
@@ -78,7 +81,6 @@ func TestSuccessProbability(t *testing.T) {
failAmount: capacity, failAmount: capacity,
amount: smallAmount, amount: smallAmount,
expectedProbability: 0.684, expectedProbability: 0.684,
tolerance: 0.001,
}, },
// If we had an unsettled success, we are sure we can send a // If we had an unsettled success, we are sure we can send a
// lower amount. // lower amount.
@@ -110,7 +112,6 @@ func TestSuccessProbability(t *testing.T) {
failAmount: capacity, failAmount: capacity,
amount: smallAmount, amount: smallAmount,
expectedProbability: 0.851, expectedProbability: 0.851,
tolerance: 0.001,
}, },
// If we had a large unsettled success before, we know we can // If we had a large unsettled success before, we know we can
// send even larger payments with high probability. // send even larger payments with high probability.
@@ -122,7 +123,6 @@ func TestSuccessProbability(t *testing.T) {
failAmount: capacity, failAmount: capacity,
amount: largeAmount, amount: largeAmount,
expectedProbability: 0.998, expectedProbability: 0.998,
tolerance: 0.001,
}, },
// If we had a failure before, we can't send with the fail // If we had a failure before, we can't send with the fail
// amount. // amount.
@@ -151,7 +151,6 @@ func TestSuccessProbability(t *testing.T) {
failAmount: largeAmount, failAmount: largeAmount,
amount: smallAmount, amount: smallAmount,
expectedProbability: 0.368, expectedProbability: 0.368,
tolerance: 0.001,
}, },
// From here on we deal with mixed previous successes and // From here on we deal with mixed previous successes and
// failures. // failures.
@@ -183,7 +182,6 @@ func TestSuccessProbability(t *testing.T) {
successAmount: smallAmount, successAmount: smallAmount,
amount: smallAmount + largeAmount/10, amount: smallAmount + largeAmount/10,
expectedProbability: 0.287, expectedProbability: 0.287,
tolerance: 0.001,
}, },
// We still can't send the fail amount. // We still can't send the fail amount.
{ {
@@ -228,7 +226,7 @@ func TestSuccessProbability(t *testing.T) {
test.failAmount, test.amount, test.failAmount, test.amount,
) )
require.InDelta(t, test.expectedProbability, p, require.InDelta(t, test.expectedProbability, p,
test.tolerance) defaultTolerance)
require.NoError(t, err) require.NoError(t, err)
}) })
} }