lnwallet: introduce default routing fee calculation

This commit is contained in:
Oliver Gugger
2022-02-02 14:24:52 +01:00
parent 5a827dd19b
commit bfa1cf17b9
2 changed files with 68 additions and 0 deletions

View File

@@ -1,13 +1,52 @@
package lnwallet
import (
"fmt"
"testing"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/stretchr/testify/require"
)
// TestDefaultRoutingFeeLimitForAmount tests that we use the correct default
// routing fee depending on the amount.
func TestDefaultRoutingFeeLimitForAmount(t *testing.T) {
t.Parallel()
tests := []struct {
amount lnwire.MilliSatoshi
expectedLimit lnwire.MilliSatoshi
}{
{
amount: 1,
expectedLimit: 1,
},
{
amount: 50_000,
expectedLimit: 50_000,
},
{
amount: 50_001,
expectedLimit: 2_500,
},
{
amount: 5_000_000_000,
expectedLimit: 250_000_000,
},
}
for _, test := range tests {
test := test
t.Run(fmt.Sprintf("%d sats", test.amount), func(t *testing.T) {
feeLimit := DefaultRoutingFeeLimitForAmount(test.amount)
require.Equal(t, test.expectedLimit, feeLimit)
})
}
}
// TestDustLimitForSize tests that we receive the expected dust limits for
// various script types from btcd's GetDustThreshold function.
func TestDustLimitForSize(t *testing.T) {