diff --git a/itest/lnd_mpp_test.go b/itest/lnd_mpp_test.go index 690658208..9a28846dc 100644 --- a/itest/lnd_mpp_test.go +++ b/itest/lnd_mpp_test.go @@ -309,15 +309,6 @@ func (m *mppTestScenario) closeChannels() { return } - // TODO(yy): remove the sleep once the following bug is fixed. When the - // payment is reported as settled by Alice, it's expected the - // commitment dance is finished and all subsequent states have been - // updated. Yet we'd receive the error `cannot co-op close channel with - // active htlcs` or `link failed to shutdown` if we close the channel. - // We need to investigate the order of settling the payments and - // updating commitments to understand and fix . - time.Sleep(5 * time.Second) - // Close all channels without mining the closing transactions. m.ht.CloseChannelAssertPending(m.alice, m.channelPoints[0], false) m.ht.CloseChannelAssertPending(m.alice, m.channelPoints[1], false) diff --git a/itest/lnd_psbt_test.go b/itest/lnd_psbt_test.go index 6c9d92d60..cef773579 100644 --- a/itest/lnd_psbt_test.go +++ b/itest/lnd_psbt_test.go @@ -312,15 +312,6 @@ func runPsbtChanFunding(ht *lntest.HarnessTest, carol, dave *node.HarnessNode, resp := dave.RPC.AddInvoice(invoice) ht.CompletePaymentRequests(carol, []string{resp.PaymentRequest}) - // TODO(yy): remove the sleep once the following bug is fixed. When the - // payment is reported as settled by Carol, it's expected the - // commitment dance is finished and all subsequent states have been - // updated. Yet we'd receive the error `cannot co-op close channel with - // active htlcs` or `link failed to shutdown` if we close the channel. - // We need to investigate the order of settling the payments and - // updating commitments to understand and fix . - time.Sleep(2 * time.Second) - // To conclude, we'll close the newly created channel between Carol and // Dave. This function will also block until the channel is closed and // will additionally assert the relevant channel closing post @@ -496,15 +487,6 @@ func runPsbtChanFundingExternal(ht *lntest.HarnessTest, carol, resp := dave.RPC.AddInvoice(invoice) ht.CompletePaymentRequests(carol, []string{resp.PaymentRequest}) - // TODO(yy): remove the sleep once the following bug is fixed. When the - // payment is reported as settled by Carol, it's expected the - // commitment dance is finished and all subsequent states have been - // updated. Yet we'd receive the error `cannot co-op close channel with - // active htlcs` or `link failed to shutdown` if we close the channel. - // We need to investigate the order of settling the payments and - // updating commitments to understand and fix . - time.Sleep(2 * time.Second) - // To conclude, we'll close the newly created channel between Carol and // Dave. This function will also block until the channels are closed and // will additionally assert the relevant channel closing post @@ -656,15 +638,6 @@ func runPsbtChanFundingSingleStep(ht *lntest.HarnessTest, carol, resp := dave.RPC.AddInvoice(invoice) ht.CompletePaymentRequests(carol, []string{resp.PaymentRequest}) - // TODO(yy): remove the sleep once the following bug is fixed. When the - // payment is reported as settled by Carol, it's expected the - // commitment dance is finished and all subsequent states have been - // updated. Yet we'd receive the error `cannot co-op close channel with - // active htlcs` or `link failed to shutdown` if we close the channel. - // We need to investigate the order of settling the payments and - // updating commitments to understand and fix . - time.Sleep(2 * time.Second) - // To conclude, we'll close the newly created channel between Carol and // Dave. This function will also block until the channel is closed and // will additionally assert the relevant channel closing post diff --git a/itest/lnd_routing_test.go b/itest/lnd_routing_test.go index 55d5e7d32..93a890bad 100644 --- a/itest/lnd_routing_test.go +++ b/itest/lnd_routing_test.go @@ -1323,15 +1323,6 @@ func testRouteFeeCutoff(ht *lntest.HarnessTest) { } testFeeCutoff(feeLimitFixed) - // TODO(yy): remove the sleep once the following bug is fixed. When the - // payment is reported as settled by Carol, it's expected the - // commitment dance is finished and all subsequent states have been - // updated. Yet we'd receive the error `cannot co-op close channel with - // active htlcs` or `link failed to shutdown` if we close the channel. - // We need to investigate the order of settling the payments and - // updating commitments to understand and fix . - time.Sleep(2 * time.Second) - // Once we're done, close the channels and shut down the nodes created // throughout this test. ht.CloseChannel(alice, chanPointAliceBob) diff --git a/itest/lnd_wallet_import_test.go b/itest/lnd_wallet_import_test.go index c0012213d..2d41da893 100644 --- a/itest/lnd_wallet_import_test.go +++ b/itest/lnd_wallet_import_test.go @@ -426,15 +426,6 @@ func fundChanAndCloseFromImportedAccount(ht *lntest.HarnessTest, srcNode, ht.CompletePaymentRequests(srcNode, []string{resp.PaymentRequest}) - // TODO(yy): remove the sleep once the following bug is fixed. When the - // payment is reported as settled by srcNode, it's expected the - // commitment dance is finished and all subsequent states have been - // updated. Yet we'd receive the error `cannot co-op close channel with - // active htlcs` or `link failed to shutdown` if we close the channel. - // We need to investigate the order of settling the payments and - // updating commitments to understand and fix . - time.Sleep(2 * time.Second) - // Now that we've confirmed the opened channel works, we'll close it. ht.CloseChannel(srcNode, chanPoint) diff --git a/itest/lnd_zero_conf_test.go b/itest/lnd_zero_conf_test.go index f2190bd2a..a02e5c006 100644 --- a/itest/lnd_zero_conf_test.go +++ b/itest/lnd_zero_conf_test.go @@ -865,15 +865,6 @@ func testOptionScidUpgrade(ht *lntest.HarnessTest) { daveInvoice2 := dave.RPC.AddInvoice(daveParams) ht.CompletePaymentRequests(bob, []string{daveInvoice2.PaymentRequest}) - // TODO(yy): remove the sleep once the following bug is fixed. When - // the payment is reported as settled by Bob, it's expected the - // commitment dance is finished and all subsequent states have been - // updated. Yet we'd receive the error `cannot co-op close channel with - // active htlcs` or `link failed to shutdown` if we close the channel. - // We need to investigate the order of settling the payments and - // updating commitments to understand and fix. - time.Sleep(2 * time.Second) - // Close standby node's channels. ht.CloseChannel(bob, fundingPoint2) } diff --git a/lntest/harness.go b/lntest/harness.go index 14ca26614..724d7ca5c 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -1207,6 +1207,7 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode, closeReq := &lnrpc.CloseChannelRequest{ ChannelPoint: cp, Force: force, + NoWait: true, } var ( @@ -1218,28 +1219,15 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode, // 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 // within the network. - // - // TODO(yy): remove the wait once the following bug is fixed. - // - https://github.com/lightningnetwork/lnd/issues/6039 - // We may receive the error `cannot co-op close channel with active - // htlcs` or `link failed to shutdown` if we close the channel. We need - // to investigate the order of settling the payments and updating - // commitments to properly fix it. - err = wait.NoError(func() error { - stream = hn.RPC.CloseChannel(closeReq) - event, err = h.ReceiveCloseChannelUpdate(stream) - if err != nil { - h.Logf("Test: %s, close channel got error: %v", - h.manager.currentTestCase, err) + stream = hn.RPC.CloseChannel(closeReq) + _, err = h.ReceiveCloseChannelUpdate(stream) + require.NoError(h, err, "close channel update got error: %v", 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) + event, err = h.ReceiveCloseChannelUpdate(stream) + if err != nil { + h.Logf("Test: %s, close channel got error: %v", + h.manager.currentTestCase, err) + } require.NoError(h, err, "retry closing channel failed") pendingClose, ok := event.Update.(*lnrpc.CloseStatusUpdate_ClosePending)