lntest: adds check for reserve
This commit is contained in:
1 parent
3befeadaf3
commit
ec9cebea34
1 file changed
+33
@@ -341,6 +341,39 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// The reserved value is now back in Alice's wallet.
|
// The reserved value is now back in Alice's wallet.
|
||||||
aliceBalance := waitForConfirmedBalance()
|
aliceBalance := waitForConfirmedBalance()
|
||||||
|
|
||||||
|
// The reserved value should be equal to the required reserve for anchor
|
||||||
|
// channels.
|
||||||
|
walletBalanceResp, err := alice.WalletBalance(
|
||||||
|
ctxb, &lnrpc.WalletBalanceRequest{},
|
||||||
|
)
|
||||||
|
require.NoError(t.t, err)
|
||||||
|
require.Equal(
|
||||||
|
t.t, aliceBalance, walletBalanceResp.ReservedBalanceAnchorChan,
|
||||||
|
)
|
||||||
|
|
||||||
|
additionalChannels := int64(1)
|
||||||
|
|
||||||
|
// Required reserve when additional channels are provided.
|
||||||
|
requiredReserveResp, err := alice.WalletKitClient.RequiredReserve(
|
||||||
|
ctxb, &walletrpc.RequiredReserveRequest{
|
||||||
|
AdditionalPublicChannels: uint32(additionalChannels),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
require.NoError(t.t, err)
|
||||||
|
|
||||||
|
additionalReservedValue := btcutil.Amount(additionalChannels *
|
||||||
|
int64(lnwallet.AnchorChanReservedValue))
|
||||||
|
totalReserved := btcutil.Amount(aliceBalance) + additionalReservedValue
|
||||||
|
|
||||||
|
// The total reserved value should not exceed the maximum value reserved
|
||||||
|
// for anchor channels.
|
||||||
|
if totalReserved > lnwallet.MaxAnchorChanReservedValue {
|
||||||
|
totalReserved = lnwallet.MaxAnchorChanReservedValue
|
||||||
|
}
|
||||||
|
require.Equal(
|
||||||
|
t.t, int64(totalReserved), requiredReserveResp.RequiredReserve,
|
||||||
|
)
|
||||||
|
|
||||||
// Alice closes channel, should now be allowed to send everything to an
|
// Alice closes channel, should now be allowed to send everything to an
|
||||||
// external address.
|
// external address.
|
||||||
for _, chanPoint := range chanPoints {
|
for _, chanPoint := range chanPoints {
|
||||||
|
|||||||
Reference in new issue
Block a user