Skip to content

Commit

Permalink
itest: document a flake found on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
yyforyongyu committed Mar 6, 2025
1 parent 0f8f092 commit 08c9353
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 85 deletions.
34 changes: 34 additions & 0 deletions itest/flakes.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package itest

import (
"runtime"
"time"

"github.com/btcsuite/btcd/btcutil"
Expand Down Expand Up @@ -70,3 +71,36 @@ func flakeTxNotifierNeutrino(ht *lntest.HarnessTest) {
ht.MineEmptyBlocks(1)
}
}

// flakeSkipPendingSweepsCheckDarwin documents a flake found only in macOS
// build. When running in macOS, we might see three anchor sweeps - one from the
// local, one from the remote, and one from the pending remote:
// - the local one will be swept.
// - the remote one will be marked as failed due to `testmempoolaccept` check.
// - the pending remote one will not be attempted due to it being uneconomical
// since it was not used for CPFP.
//
// The anchor from the pending remote may or may not appear, which is a bug
// found only in macOS - when updating the commitments, the channel state
// machine somehow thinks we still have a pending remote commitment, causing it
// to sweep the anchor from that version.
//
// TODO(yy): fix the above bug in the channel state machine.
func flakeSkipPendingSweepsCheckDarwin(ht *lntest.HarnessTest,
node *node.HarnessNode, num int) {

// Skip the assertion below if it's on macOS.
if isDarwin() {
ht.Logf("Skipped AssertNumPendingSweeps for node %s",
node.Name())

return
}

ht.AssertNumPendingSweeps(node, num)
}

// isDarwin returns true if the test is running on a macOS.
func isDarwin() bool {
return runtime.GOOS == "darwin"
}
85 changes: 5 additions & 80 deletions itest/lnd_multi-hop_force_close_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,22 +423,7 @@ func runLocalClaimOutgoingHTLC(ht *lntest.HarnessTest,
numSweeps = 2
}

// When running in macOS, we might see three anchor sweeps - one from
// the local, one from the remote, and one from the pending remote:
// - the local one will be swept.
// - the remote one will be marked as failed due to `testmempoolaccept`
// check.
// - the pending remote one will not be attempted due to it being
// uneconomical since it was not used for CPFP.
// The anchor from the pending remote may or may not appear, which is a
// bug found only in macOS - when updating the commitments, the channel
// state machine somehow thinks we still have a pending remote
// commitment, causing it to sweep the anchor from that version.
//
// TODO(yy): fix the above bug in the channel state machine.
if !isDarwin() {
ht.AssertNumPendingSweeps(bob, numSweeps)
}
flakeSkipPendingSweepsCheckDarwin(ht, bob, numSweeps)

// We expect to see tow txns in the mempool,
// 1. Bob's force close tx.
Expand Down Expand Up @@ -795,22 +780,7 @@ func runMultiHopReceiverPreimageClaim(ht *lntest.HarnessTest,
numSweeps = 2
}

// When running in macOS, we might see three anchor sweeps - one from
// the local, one from the remote, and one from the pending remote:
// - the local one will be swept.
// - the remote one will be marked as failed due to `testmempoolaccept`
// check.
// - the pending remote one will not be attempted due to it being
// uneconomical since it was not used for CPFP.
// The anchor from the pending remote may or may not appear, which is a
// bug found only in macOS - when updating the commitments, the channel
// state machine somehow thinks we still have a pending remote
// commitment, causing it to sweep the anchor from that version.
//
// TODO(yy): fix the above bug in the channel state machine.
if !isDarwin() {
ht.AssertNumPendingSweeps(carol, numSweeps)
}
flakeSkipPendingSweepsCheckDarwin(ht, carol, numSweeps)

// We expect to see tow txns in the mempool,
// 1. Carol's force close tx.
Expand Down Expand Up @@ -2365,22 +2335,7 @@ func runLocalPreimageClaim(ht *lntest.HarnessTest,
numSweeps = 2
}

// When running in macOS, we might see three anchor sweeps - one from
// the local, one from the remote, and one from the pending remote:
// - the local one will be swept.
// - the remote one will be marked as failed due to `testmempoolaccept`
// check.
// - the pending remote one will not be attempted due to it being
// uneconomical since it was not used for CPFP.
// The anchor from the pending remote may or may not appear, which is a
// bug found only in macOS - when updating the commitments, the channel
// state machine somehow thinks we still have a pending remote
// commitment, causing it to sweep the anchor from that version.
//
// TODO(yy): fix the above bug in the channel state machine.
if !isDarwin() {
ht.AssertNumPendingSweeps(carol, numSweeps)
}
flakeSkipPendingSweepsCheckDarwin(ht, carol, numSweeps)

// We should see two txns in the mempool, we now a block to confirm,
// - Carol's force close tx.
Expand Down Expand Up @@ -2620,22 +2575,7 @@ func runLocalPreimageClaimLeased(ht *lntest.HarnessTest,
numSweeps = 2
}

// When running in macOS, we might see three anchor sweeps - one from
// the local, one from the remote, and one from the pending remote:
// - the local one will be swept.
// - the remote one will be marked as failed due to `testmempoolaccept`
// check.
// - the pending remote one will not be attempted due to it being
// uneconomical since it was not used for CPFP.
// The anchor from the pending remote may or may not appear, which is a
// bug found only in macOS - when updating the commitments, the channel
// state machine somehow thinks we still have a pending remote
// commitment, causing it to sweep the anchor from that version.
//
// TODO(yy): fix the above bug in the channel state machine.
if !isDarwin() {
ht.AssertNumPendingSweeps(carol, numSweeps)
}
flakeSkipPendingSweepsCheckDarwin(ht, carol, numSweeps)

// We should see two txns in the mempool, we now a block to confirm,
// - Carol's force close tx.
Expand Down Expand Up @@ -3043,22 +2983,7 @@ func runHtlcAggregation(ht *lntest.HarnessTest,
numSweeps = 2
}

// When running in macOS, we might see three anchor sweeps - one from
// the local, one from the remote, and one from the pending remote:
// - the local one will be swept.
// - the remote one will be marked as failed due to `testmempoolaccept`
// check.
// - the pending remote one will not be attempted due to it being
// uneconomical since it was not used for CPFP.
// The anchor from the pending remote may or may not appear, which is a
// bug found only in macOS - when updating the commitments, the channel
// state machine somehow thinks we still have a pending remote
// commitment, causing it to sweep the anchor from that version.
//
// TODO(yy): fix the above bug in the channel state machine.
if !isDarwin() {
ht.AssertNumPendingSweeps(bob, numSweeps)
}
flakeSkipPendingSweepsCheckDarwin(ht, bob, numSweeps)

// Bob's force close tx and anchor sweeping tx should now be found in
// the mempool.
Expand Down
5 changes: 0 additions & 5 deletions itest/lnd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,6 @@ func getLndBinary(t *testing.T) string {
return binary
}

// isDarwin returns true if the test is running on a macOS.
func isDarwin() bool {
return runtime.GOOS == "darwin"
}

// isWindowsOS returns true if the test is running on a Windows OS.
func isWindowsOS() bool {
return runtime.GOOS == "windows"
Expand Down

0 comments on commit 08c9353

Please sign in to comment.