mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 06:07:16 +01:00
itest+lntest: fix channel force close itest
This commit is contained in:
@@ -42,6 +42,10 @@ const (
|
||||
// lndErrorChanSize specifies the buffer size used to receive errors
|
||||
// from lnd process.
|
||||
lndErrorChanSize = 10
|
||||
|
||||
// maxBlocksAllowed specifies the max allowed value to be used when
|
||||
// mining blocks.
|
||||
maxBlocksAllowed = 100
|
||||
)
|
||||
|
||||
// TestCase defines a test case that's been used in the integration test.
|
||||
@@ -1701,6 +1705,9 @@ func (h *HarnessTest) RestartNodeAndRestoreDB(hn *node.HarnessNode) {
|
||||
// NOTE: this differs from miner's `MineBlocks` as it requires the nodes to be
|
||||
// synced.
|
||||
func (h *HarnessTest) MineBlocks(num uint32) []*wire.MsgBlock {
|
||||
require.Less(h, num, uint32(maxBlocksAllowed),
|
||||
"too many blocks to mine")
|
||||
|
||||
// Mining the blocks slow to give `lnd` more time to sync.
|
||||
blocks := h.Miner.MineBlocksSlow(num)
|
||||
|
||||
@@ -1789,6 +1796,8 @@ func (h *HarnessTest) CleanShutDown() {
|
||||
// NOTE: this differs from miner's `MineEmptyBlocks` as it requires the nodes
|
||||
// to be synced.
|
||||
func (h *HarnessTest) MineEmptyBlocks(num int) []*wire.MsgBlock {
|
||||
require.Less(h, num, maxBlocksAllowed, "too many blocks to mine")
|
||||
|
||||
blocks := h.Miner.MineEmptyBlocks(num)
|
||||
|
||||
// Finally, make sure all the active nodes are synced.
|
||||
@@ -2087,17 +2096,24 @@ func (h *HarnessTest) FindCommitAndAnchor(sweepTxns []*wire.MsgTx,
|
||||
func (h *HarnessTest) AssertSweepFound(hn *node.HarnessNode,
|
||||
sweep string, verbose bool, startHeight int32) {
|
||||
|
||||
// List all sweeps that alice's node had broadcast.
|
||||
sweepResp := hn.RPC.ListSweeps(verbose, startHeight)
|
||||
err := wait.NoError(func() error {
|
||||
// List all sweeps that alice's node had broadcast.
|
||||
sweepResp := hn.RPC.ListSweeps(verbose, startHeight)
|
||||
|
||||
var found bool
|
||||
if verbose {
|
||||
found = findSweepInDetails(h, sweep, sweepResp)
|
||||
} else {
|
||||
found = findSweepInTxids(h, sweep, sweepResp)
|
||||
}
|
||||
var found bool
|
||||
if verbose {
|
||||
found = findSweepInDetails(h, sweep, sweepResp)
|
||||
} else {
|
||||
found = findSweepInTxids(h, sweep, sweepResp)
|
||||
}
|
||||
|
||||
require.Truef(h, found, "%s: sweep: %v not found", sweep, hn.Name())
|
||||
if found {
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("sweep tx %v not found", sweep)
|
||||
}, wait.DefaultTimeout)
|
||||
require.NoError(h, err, "%s: timeout checking sweep tx", hn.Name())
|
||||
}
|
||||
|
||||
func findSweepInTxids(ht *HarnessTest, sweepTxid string,
|
||||
|
||||
@@ -2594,12 +2594,17 @@ func (h *HarnessTest) AssertWalletLockedBalance(hn *node.HarnessNode,
|
||||
|
||||
// AssertNumPendingSweeps asserts the number of pending sweeps for the given
|
||||
// node.
|
||||
func (h *HarnessTest) AssertNumPendingSweeps(hn *node.HarnessNode, n int) {
|
||||
func (h *HarnessTest) AssertNumPendingSweeps(hn *node.HarnessNode,
|
||||
n int) []*walletrpc.PendingSweep {
|
||||
|
||||
results := make([]*walletrpc.PendingSweep, 0, n)
|
||||
|
||||
err := wait.NoError(func() error {
|
||||
resp := hn.RPC.PendingSweeps()
|
||||
num := len(resp.PendingSweeps)
|
||||
|
||||
if num == n {
|
||||
results = resp.PendingSweeps
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2614,6 +2619,8 @@ func (h *HarnessTest) AssertNumPendingSweeps(hn *node.HarnessNode, n int) {
|
||||
}, DefaultTimeout)
|
||||
|
||||
require.NoErrorf(h, err, "%s: check pending sweeps timeout", hn.Name())
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
// FindSweepingTxns asserts the expected number of sweeping txns are found in
|
||||
|
||||
Reference in New Issue
Block a user