lntest+itest: fix flakes found using neutrino backend

This commit makes sure the sweep requests are received before mining
blocks to trigger the actual sweeping.

In addition, `testFundingExpiryBlocksOnPending` is updated to deal with
the old `channel link not found` issue.
This commit is contained in:
yyforyongyu
2024-07-16 01:53:59 +08:00
parent 2608c0893e
commit 4dcce9df69
5 changed files with 43 additions and 19 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"strings"
"testing"
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
@@ -767,6 +768,18 @@ func testFundingExpiryBlocksOnPending(ht *lntest.HarnessTest) {
// channel.
ht.MineBlocksAndAssertNumTxes(1, 1)
chanPoint := lntest.ChanPointFromPendingUpdate(update)
// TODO(yy): remove the sleep once the following bug is fixed.
//
// We may get the error `unable to gracefully close channel
// while peer is offline (try force closing it instead):
// channel link not found`. This happens because the channel
// link hasn't been added yet but we now proceed to closing the
// channel. We may need to revisit how the channel open event
// is created and make sure the event is only sent after all
// relevant states have been updated.
time.Sleep(2 * time.Second)
ht.CloseChannel(alice, chanPoint)
}