mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-04 20:19:24 +02:00
Merge pull request #7607 from yyforyongyu/itest-fix-close-chan
lntest: add temporary wait when closing channels
This commit is contained in:
commit
d9396741fa
@ -1125,25 +1125,39 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
|
|||||||
ChannelPoint: cp,
|
ChannelPoint: cp,
|
||||||
Force: force,
|
Force: force,
|
||||||
}
|
}
|
||||||
stream := hn.RPC.CloseChannel(closeReq)
|
|
||||||
|
var (
|
||||||
|
stream rpc.CloseChanClient
|
||||||
|
event *lnrpc.CloseStatusUpdate
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
// Consume the "channel close" update in order to wait for the closing
|
// Consume the "channel close" update in order to wait for the closing
|
||||||
// transaction to be broadcast, then wait for the closing tx to be seen
|
// transaction to be broadcast, then wait for the closing tx to be seen
|
||||||
// within the network.
|
// within the network.
|
||||||
event, err := h.ReceiveCloseChannelUpdate(stream)
|
//
|
||||||
if err != nil {
|
// TODO(yy): remove the wait once the following bug is fixed.
|
||||||
// TODO(yy): remove the sleep once the following bug is fixed.
|
// - https://github.com/lightningnetwork/lnd/issues/6039
|
||||||
// We may receive the error `cannot co-op close channel with
|
// We may receive the error `cannot co-op close channel with active
|
||||||
// active htlcs` or `link failed to shutdown` if we close the
|
// htlcs` or `link failed to shutdown` if we close the channel. We need
|
||||||
// channel. We need to investigate the order of settling the
|
// to investigate the order of settling the payments and updating
|
||||||
// payments and updating commitments to properly fix it.
|
// commitments to properly fix it.
|
||||||
time.Sleep(5 * time.Second)
|
err = wait.NoError(func() error {
|
||||||
|
|
||||||
// Give it another chance.
|
|
||||||
stream = hn.RPC.CloseChannel(closeReq)
|
stream = hn.RPC.CloseChannel(closeReq)
|
||||||
event, err = h.ReceiveCloseChannelUpdate(stream)
|
event, err = h.ReceiveCloseChannelUpdate(stream)
|
||||||
require.NoError(h, err)
|
if err != nil {
|
||||||
}
|
h.Logf("Test: %s, close channel got error: %v",
|
||||||
|
h.manager.currentTestCase, err)
|
||||||
|
|
||||||
|
// NoError predicates every 200ms, which is too
|
||||||
|
// frequent for closing channels. We sleep here to
|
||||||
|
// avoid trying it too much.
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}, wait.ChannelCloseTimeout)
|
||||||
|
require.NoError(h, err, "retry closing channel failed")
|
||||||
|
|
||||||
pendingClose, ok := event.Update.(*lnrpc.CloseStatusUpdate_ClosePending)
|
pendingClose, ok := event.Update.(*lnrpc.CloseStatusUpdate_ClosePending)
|
||||||
require.Truef(h, ok, "expected channel close update, instead got %v",
|
require.Truef(h, ok, "expected channel close update, instead got %v",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user