mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 09:48:19 +01:00
Merge pull request #5615 from yyforyongyu/itest-fix-commitment-deadline
itest: fix commit deadline for neutrino backend
This commit is contained in:
commit
9e8b9ccd4c
4 changed files with 26 additions and 12 deletions
|
@ -1100,7 +1100,7 @@ func (c *ChannelArbitrator) sweepAnchors(anchors *lnwallet.AnchorResolutions,
|
|||
// sweepWithDeadline is a helper closure that takes an anchor
|
||||
// resolution and sweeps it with its corresponding deadline.
|
||||
sweepWithDeadline := func(anchor *lnwallet.AnchorResolution,
|
||||
htlcs htlcSet) error {
|
||||
htlcs htlcSet, anchorPath string) error {
|
||||
|
||||
// Find the deadline for this specific anchor.
|
||||
deadline, err := c.findCommitmentDeadline(heightHint, htlcs)
|
||||
|
@ -1109,7 +1109,8 @@ func (c *ChannelArbitrator) sweepAnchors(anchors *lnwallet.AnchorResolutions,
|
|||
}
|
||||
|
||||
log.Debugf("ChannelArbitrator(%v): pre-confirmation sweep of "+
|
||||
"anchor of tx %v", c.cfg.ChanPoint, anchor.CommitAnchor)
|
||||
"anchor of %s commit tx %v", c.cfg.ChanPoint,
|
||||
anchorPath, anchor.CommitAnchor)
|
||||
|
||||
// Prepare anchor output for sweeping.
|
||||
anchorInput := input.MakeBaseInput(
|
||||
|
@ -1153,13 +1154,15 @@ func (c *ChannelArbitrator) sweepAnchors(anchors *lnwallet.AnchorResolutions,
|
|||
for htlcSet, htlcs := range c.activeHTLCs {
|
||||
switch {
|
||||
case htlcSet == LocalHtlcSet && anchors.Local != nil:
|
||||
err := sweepWithDeadline(anchors.Local, htlcs)
|
||||
err := sweepWithDeadline(anchors.Local, htlcs, "local")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
case htlcSet == RemoteHtlcSet && anchors.Remote != nil:
|
||||
err := sweepWithDeadline(anchors.Remote, htlcs)
|
||||
err := sweepWithDeadline(
|
||||
anchors.Remote, htlcs, "remote",
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1167,7 +1170,9 @@ func (c *ChannelArbitrator) sweepAnchors(anchors *lnwallet.AnchorResolutions,
|
|||
case htlcSet == RemotePendingHtlcSet &&
|
||||
anchors.RemotePending != nil:
|
||||
|
||||
err := sweepWithDeadline(anchors.RemotePending, htlcs)
|
||||
err := sweepWithDeadline(
|
||||
anchors.RemotePending, htlcs, "remote pending",
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -114,6 +114,8 @@ you.
|
|||
|
||||
* [Fixed context timeout when closing channels in tests](https://github.com/lightningnetwork/lnd/pull/5616).
|
||||
|
||||
* [Fixed transaction not found in mempool flake in commitment deadline itest](https://github.com/lightningnetwork/lnd/pull/5615).
|
||||
|
||||
* [Fixed a missing import and git tag in the healthcheck package](https://github.com/lightningnetwork/lnd/pull/5582).
|
||||
|
||||
* [Fixed a data race in payment unit test](https://github.com/lightningnetwork/lnd/pull/5573).
|
||||
|
|
|
@ -1613,8 +1613,9 @@ func assertActiveHtlcs(nodes []*lntest.HarnessNode, payHashes ...[]byte) error {
|
|||
|
||||
// Channel should have exactly the payHashes active.
|
||||
if len(payHashes) != len(htlcHashes) {
|
||||
return fmt.Errorf("node %x had %v htlcs active, "+
|
||||
"expected %v", node.PubKey[:],
|
||||
return fmt.Errorf("node [%s:%x] had %v "+
|
||||
"htlcs active, expected %v",
|
||||
node.Cfg.Name, node.PubKey[:],
|
||||
len(htlcHashes), len(payHashes))
|
||||
}
|
||||
|
||||
|
@ -1624,9 +1625,9 @@ func assertActiveHtlcs(nodes []*lntest.HarnessNode, payHashes ...[]byte) error {
|
|||
if _, ok := htlcHashes[h]; ok {
|
||||
continue
|
||||
}
|
||||
return fmt.Errorf("node %x didn't have the "+
|
||||
"payHash %v active", node.PubKey[:],
|
||||
h)
|
||||
return fmt.Errorf("node [%s:%x] didn't have: "+
|
||||
"the payHash %v active", node.Cfg.Name,
|
||||
node.PubKey[:], h)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,6 +81,13 @@ func testCommitmentTransactionDeadline(net *lntest.NetworkHarness,
|
|||
|
||||
// Send some coins to the node.
|
||||
net.SendCoins(ctx, t.t, btcutil.SatoshiPerBitcoin, node)
|
||||
|
||||
// For neutrino backend, we need one additional UTXO to create
|
||||
// the sweeping tx for the remote anchor.
|
||||
if net.BackendCfg.Name() == lntest.NeutrinoBackendName {
|
||||
net.SendCoins(ctx, t.t, btcutil.SatoshiPerBitcoin, node)
|
||||
}
|
||||
|
||||
return node
|
||||
}
|
||||
|
||||
|
@ -151,8 +158,7 @@ func testCommitmentTransactionDeadline(net *lntest.NetworkHarness,
|
|||
t.t, checkNumWaitingCloseChannels(pendingChanResp, 1),
|
||||
)
|
||||
|
||||
// We should see only one sweep transaction because the anchor
|
||||
// sweep is skipped.
|
||||
// Check our sweep transactions can be found in mempool.
|
||||
sweepTxns, err := getNTxsFromMempool(
|
||||
net.Miner.Client,
|
||||
expectedSweepTxNum, minerMempoolTimeout,
|
||||
|
|
Loading…
Add table
Reference in a new issue