mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-03 08:20:30 +02:00
lntest+itest: fix testOpenChannelLockedBalance
This commit is contained in:
parent
536ac9f8a4
commit
6f5b7a9fd3
@ -829,12 +829,19 @@ func testSimpleTaprootChannelActivation(ht *lntest.HarnessTest) {
|
|||||||
// up as locked balance in the WalletBalance response.
|
// up as locked balance in the WalletBalance response.
|
||||||
func testOpenChannelLockedBalance(ht *lntest.HarnessTest) {
|
func testOpenChannelLockedBalance(ht *lntest.HarnessTest) {
|
||||||
var (
|
var (
|
||||||
alice = ht.Alice
|
bob = ht.Bob
|
||||||
bob = ht.Bob
|
req *lnrpc.ChannelAcceptRequest
|
||||||
req *lnrpc.ChannelAcceptRequest
|
err error
|
||||||
err error
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Create a new node so we can assert exactly how much fund has been
|
||||||
|
// locked later.
|
||||||
|
alice := ht.NewNode("alice", nil)
|
||||||
|
ht.FundCoins(btcutil.SatoshiPerBitcoin, alice)
|
||||||
|
|
||||||
|
// Connect the nodes.
|
||||||
|
ht.EnsureConnected(alice, bob)
|
||||||
|
|
||||||
// We first make sure Alice has no locked wallet balance.
|
// We first make sure Alice has no locked wallet balance.
|
||||||
balance := alice.RPC.WalletBalance()
|
balance := alice.RPC.WalletBalance()
|
||||||
require.EqualValues(ht, 0, balance.LockedBalance)
|
require.EqualValues(ht, 0, balance.LockedBalance)
|
||||||
@ -851,6 +858,7 @@ func testOpenChannelLockedBalance(ht *lntest.HarnessTest) {
|
|||||||
openChannelReq := &lnrpc.OpenChannelRequest{
|
openChannelReq := &lnrpc.OpenChannelRequest{
|
||||||
NodePubkey: bob.PubKey[:],
|
NodePubkey: bob.PubKey[:],
|
||||||
LocalFundingAmount: int64(funding.MaxBtcFundingAmount),
|
LocalFundingAmount: int64(funding.MaxBtcFundingAmount),
|
||||||
|
TargetConf: 6,
|
||||||
}
|
}
|
||||||
_ = alice.RPC.OpenChannel(openChannelReq)
|
_ = alice.RPC.OpenChannel(openChannelReq)
|
||||||
|
|
||||||
@ -862,8 +870,7 @@ func testOpenChannelLockedBalance(ht *lntest.HarnessTest) {
|
|||||||
}, defaultTimeout)
|
}, defaultTimeout)
|
||||||
require.NoError(ht, err)
|
require.NoError(ht, err)
|
||||||
|
|
||||||
balance = alice.RPC.WalletBalance()
|
ht.AssertWalletLockedBalance(alice, btcutil.SatoshiPerBitcoin)
|
||||||
require.NotEqualValues(ht, 0, balance.LockedBalance)
|
|
||||||
|
|
||||||
// Next, we let Bob deny the request.
|
// Next, we let Bob deny the request.
|
||||||
resp := &lnrpc.ChannelAcceptResponse{
|
resp := &lnrpc.ChannelAcceptResponse{
|
||||||
@ -876,6 +883,5 @@ func testOpenChannelLockedBalance(ht *lntest.HarnessTest) {
|
|||||||
require.NoError(ht, err)
|
require.NoError(ht, err)
|
||||||
|
|
||||||
// Finally, we check to make sure the balance is unlocked again.
|
// Finally, we check to make sure the balance is unlocked again.
|
||||||
balance = alice.RPC.WalletBalance()
|
ht.AssertWalletLockedBalance(alice, 0)
|
||||||
require.EqualValues(ht, 0, balance.LockedBalance)
|
|
||||||
}
|
}
|
||||||
|
@ -2572,3 +2572,22 @@ func (h *HarnessTest) MineClosingTx(cp *lnrpc.ChannelPoint,
|
|||||||
|
|
||||||
return closeTx
|
return closeTx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AssertWalletLockedBalance asserts the expected amount has been marked as
|
||||||
|
// locked in the node's WalletBalance response.
|
||||||
|
func (h *HarnessTest) AssertWalletLockedBalance(hn *node.HarnessNode,
|
||||||
|
balance int64) {
|
||||||
|
|
||||||
|
err := wait.NoError(func() error {
|
||||||
|
balanceResp := hn.RPC.WalletBalance()
|
||||||
|
got := balanceResp.LockedBalance
|
||||||
|
|
||||||
|
if got != balance {
|
||||||
|
return fmt.Errorf("want %d, got %d", balance, got)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}, wait.DefaultTimeout)
|
||||||
|
require.NoError(h, err, "%s: timeout checking locked balance",
|
||||||
|
hn.Name())
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user