itest: update num of sweeps in AssertNumPendingSweeps

Since we now return all sweeps, we need to update the call to include
immature sweeps.
This commit is contained in:
yyforyongyu committed 2025-04-29 14:15:31 +08:00
1 parent d991f5659a
commit 8f936aa9eb
8 files changed
+201 -91

No files matched your search

+49 -4
View File
@@ -711,8 +711,11 @@ func (h *HarnessTest) AssertStreamChannelForceClosed(hn *node.HarnessNode,
}
// Assert there's a pending anchor sweep.
//
// NOTE: We may have a local sweep here, that's why we use
// AssertAtLeastNumPendingSweeps instead of AssertNumPendingSweeps.
if anchorSweep {
h.AssertNumPendingSweeps(hn, 1)
h.AssertAtLeastNumPendingSweeps(hn, 1)
}
return closingTxid
@@ -2723,9 +2726,10 @@ func (h *HarnessTest) AssertNumPendingSweeps(hn *node.HarnessNode,
numDesc := "\n"
for _, s := range resp.PendingSweeps {
desc := fmt.Sprintf("op=%v:%v, amt=%v, type=%v, "+
"deadline=%v\n", s.Outpoint.TxidStr,
s.Outpoint.OutputIndex, s.AmountSat,
s.WitnessType, s.DeadlineHeight)
"deadline=%v, maturityHeight=%v\n",
s.Outpoint.TxidStr, s.Outpoint.OutputIndex,
s.AmountSat, s.WitnessType, s.DeadlineHeight,
s.MaturityHeight)
numDesc += desc
// The deadline height must be set, otherwise the
@@ -2749,6 +2753,47 @@ func (h *HarnessTest) AssertNumPendingSweeps(hn *node.HarnessNode,
return results
}
// AssertAtLeastNumPendingSweeps asserts there are at least n pending sweeps for
// the given node.
func (h *HarnessTest) AssertAtLeastNumPendingSweeps(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)
numDesc := "\n"
for _, s := range resp.PendingSweeps {
desc := fmt.Sprintf("op=%v:%v, amt=%v, type=%v, "+
"deadline=%v, maturityHeight=%v\n",
s.Outpoint.TxidStr, s.Outpoint.OutputIndex,
s.AmountSat, s.WitnessType, s.DeadlineHeight,
s.MaturityHeight)
numDesc += desc
// The deadline height must be set, otherwise the
// pending input response is not update-to-date.
if s.DeadlineHeight == 0 {
return fmt.Errorf("input not updated: %s", desc)
}
}
if num >= n {
results = resp.PendingSweeps
return nil
}
return fmt.Errorf("want %d , got %d, sweeps: %s", n, num,
numDesc)
}, 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
// the txns specified and return them.
func (h *HarnessTest) FindSweepingTxns(txns []*wire.MsgTx,