-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c7c5ce
commit fbdb5a3
Showing
5 changed files
with
274 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,5 @@ user-config/* | |
!user-config/.gitkeep | ||
nginx/etc/ssl/* | ||
nginx/etc/.htpasswd | ||
|
||
cmd/lndmon/lndmon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package collectors | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/btcsuite/btcutil" | ||
"github.com/lightningnetwork/lnd/lnrpc" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
var ( | ||
remotePolicies = map[uint64]*lnrpc.RoutingPolicy{ | ||
1: { | ||
FeeBaseMsat: 20000, | ||
FeeRateMilliMsat: 10000, | ||
}, | ||
2: { | ||
FeeBaseMsat: 250000, | ||
FeeRateMilliMsat: 6000, | ||
}, | ||
} | ||
|
||
remoteBalances = map[uint64]btcutil.Amount{ | ||
1: 10000, | ||
2: 10000, | ||
} | ||
) | ||
|
||
// TestGetInboundFee tests the specific-fee based inbound fee calculation. | ||
func TestGetInboundFee(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
amt btcutil.Amount | ||
expectedFee btcutil.Amount | ||
expectNoLiquidity bool | ||
}{ | ||
{ | ||
name: "single channel use all", | ||
amt: 10000, | ||
expectedFee: 120, | ||
}, | ||
{ | ||
name: "single channel partially used", | ||
amt: 5000, | ||
expectedFee: 70, | ||
}, | ||
{ | ||
name: "not enough", | ||
amt: 25000, | ||
expectNoLiquidity: true, | ||
}, | ||
{ | ||
name: "two channels use all", | ||
amt: 20000, | ||
expectedFee: 120 + 310, | ||
}, | ||
{ | ||
name: "two channels partially used", | ||
amt: 15000, | ||
expectedFee: 120 + 280, | ||
}, | ||
} | ||
|
||
for _, test := range testCases { | ||
test := test | ||
|
||
t.Run(test.name, func(t *testing.T) { | ||
testGetInboundFee( | ||
t, test.amt, test.expectedFee, | ||
test.expectNoLiquidity, | ||
) | ||
}) | ||
} | ||
} | ||
|
||
func testGetInboundFee(t *testing.T, amt, expectedFee btcutil.Amount, | ||
expectNoLiquidity bool) { | ||
|
||
fee := approximateInboundFee(amt, remotePolicies, remoteBalances) | ||
|
||
if expectNoLiquidity { | ||
require.Nil(t, fee, "expected no liquidity") | ||
return | ||
} | ||
|
||
require.NotNil(t, fee, "expected routing to be possible") | ||
require.Equal(t, expectedFee, *fee) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters