mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-02 16:00: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.
|
||||
func testOpenChannelLockedBalance(ht *lntest.HarnessTest) {
|
||||
var (
|
||||
alice = ht.Alice
|
||||
bob = ht.Bob
|
||||
req *lnrpc.ChannelAcceptRequest
|
||||
err error
|
||||
bob = ht.Bob
|
||||
req *lnrpc.ChannelAcceptRequest
|
||||
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.
|
||||
balance := alice.RPC.WalletBalance()
|
||||
require.EqualValues(ht, 0, balance.LockedBalance)
|
||||
@ -851,6 +858,7 @@ func testOpenChannelLockedBalance(ht *lntest.HarnessTest) {
|
||||
openChannelReq := &lnrpc.OpenChannelRequest{
|
||||
NodePubkey: bob.PubKey[:],
|
||||
LocalFundingAmount: int64(funding.MaxBtcFundingAmount),
|
||||
TargetConf: 6,
|
||||
}
|
||||
_ = alice.RPC.OpenChannel(openChannelReq)
|
||||
|
||||
@ -862,8 +870,7 @@ func testOpenChannelLockedBalance(ht *lntest.HarnessTest) {
|
||||
}, defaultTimeout)
|
||||
require.NoError(ht, err)
|
||||
|
||||
balance = alice.RPC.WalletBalance()
|
||||
require.NotEqualValues(ht, 0, balance.LockedBalance)
|
||||
ht.AssertWalletLockedBalance(alice, btcutil.SatoshiPerBitcoin)
|
||||
|
||||
// Next, we let Bob deny the request.
|
||||
resp := &lnrpc.ChannelAcceptResponse{
|
||||
@ -876,6 +883,5 @@ func testOpenChannelLockedBalance(ht *lntest.HarnessTest) {
|
||||
require.NoError(ht, err)
|
||||
|
||||
// Finally, we check to make sure the balance is unlocked again.
|
||||
balance = alice.RPC.WalletBalance()
|
||||
require.EqualValues(ht, 0, balance.LockedBalance)
|
||||
ht.AssertWalletLockedBalance(alice, 0)
|
||||
}
|
||||
|
@ -2572,3 +2572,22 @@ func (h *HarnessTest) MineClosingTx(cp *lnrpc.ChannelPoint,
|
||||
|
||||
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