mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-06 18:36:57 +02:00
lnwallet: introduce default routing fee calculation
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user