Skip to content

Commit 04eec71

Browse files
committed
routing: use default tolerance for bimodal testing
1 parent 55e7343 commit 04eec71

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

routing/probability_bimodal_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ const (
1515
largeAmount = lnwire.MilliSatoshi(5_000_000_000)
1616
capacity = lnwire.MilliSatoshi(10_000_000_000)
1717
scale = lnwire.MilliSatoshi(400_000_000)
18+
19+
// defaultTolerance is the default absolute tolerance for comparing
20+
// probability calculations to expected values.
21+
defaultTolerance = 0.001
1822
)
1923

2024
// TestSuccessProbability tests that we get correct probability estimates for
@@ -25,7 +29,6 @@ func TestSuccessProbability(t *testing.T) {
2529
tests := []struct {
2630
name string
2731
expectedProbability float64
28-
tolerance float64
2932
successAmount lnwire.MilliSatoshi
3033
failAmount lnwire.MilliSatoshi
3134
amount lnwire.MilliSatoshi
@@ -78,7 +81,6 @@ func TestSuccessProbability(t *testing.T) {
7881
failAmount: capacity,
7982
amount: smallAmount,
8083
expectedProbability: 0.684,
81-
tolerance: 0.001,
8284
},
8385
// If we had an unsettled success, we are sure we can send a
8486
// lower amount.
@@ -110,7 +112,6 @@ func TestSuccessProbability(t *testing.T) {
110112
failAmount: capacity,
111113
amount: smallAmount,
112114
expectedProbability: 0.851,
113-
tolerance: 0.001,
114115
},
115116
// If we had a large unsettled success before, we know we can
116117
// send even larger payments with high probability.
@@ -122,7 +123,6 @@ func TestSuccessProbability(t *testing.T) {
122123
failAmount: capacity,
123124
amount: largeAmount,
124125
expectedProbability: 0.998,
125-
tolerance: 0.001,
126126
},
127127
// If we had a failure before, we can't send with the fail
128128
// amount.
@@ -151,7 +151,6 @@ func TestSuccessProbability(t *testing.T) {
151151
failAmount: largeAmount,
152152
amount: smallAmount,
153153
expectedProbability: 0.368,
154-
tolerance: 0.001,
155154
},
156155
// From here on we deal with mixed previous successes and
157156
// failures.
@@ -183,7 +182,6 @@ func TestSuccessProbability(t *testing.T) {
183182
successAmount: smallAmount,
184183
amount: smallAmount + largeAmount/10,
185184
expectedProbability: 0.287,
186-
tolerance: 0.001,
187185
},
188186
// We still can't send the fail amount.
189187
{
@@ -228,7 +226,7 @@ func TestSuccessProbability(t *testing.T) {
228226
test.failAmount, test.amount,
229227
)
230228
require.InDelta(t, test.expectedProbability, p,
231-
test.tolerance)
229+
defaultTolerance)
232230
require.NoError(t, err)
233231
})
234232
}

0 commit comments

Comments
 (0)