• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 13725104123

07 Mar 2025 04:37PM UTC coverage: 68.615% (-0.03%) from 68.644%
13725104123

push

github

web-flow
Merge pull request #9582 from yyforyongyu/flake-doc

itest: properly document the known flakes

0 of 51 new or added lines in 1 file covered. (0.0%)

70 existing lines in 13 files now uncovered.

129975 of 189427 relevant lines covered (68.61%)

23632.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/itest/flakes.go
1
package itest
2

3
import (
4
        "runtime"
5
        "time"
6

7
        "github.com/btcsuite/btcd/btcutil"
8
        "github.com/lightningnetwork/lnd/lntest"
9
        "github.com/lightningnetwork/lnd/lntest/node"
10
)
11

12
// flakePreimageSettlement documents a flake found when testing the preimage
13
// extraction logic in a force close. The scenario is,
14
//   - Alice and Bob have a channel.
15
//   - Alice sends an HTLC to Bob, and Bob won't settle it.
16
//   - Alice goes offline.
17
//   - Bob force closes the channel and claims the HTLC using the preimage using
18
//     a sweeping tx.
19
//
20
// TODO(yy): Expose blockbeat to the link layer so the preimage extraction
21
// happens in the same block where it's spent.
NEW
22
func flakePreimageSettlement(ht *lntest.HarnessTest) {
×
NEW
23
        // Mine a block to trigger the sweep. This is needed because the
×
NEW
24
        // preimage extraction logic from the link is not managed by the
×
NEW
25
        // blockbeat, which means the preimage may be sent to the contest
×
NEW
26
        // resolver after it's launched, which means Bob would miss the block to
×
NEW
27
        // launch the resolver.
×
NEW
28
        ht.MineEmptyBlocks(1)
×
NEW
29

×
NEW
30
        // Sleep for 2 seconds, which is needed to make sure the mempool has the
×
NEW
31
        // correct tx. The above mined block can cause an RBF, if the preimage
×
NEW
32
        // extraction has already been finished before the block is mined. This
×
NEW
33
        // means Bob would have created the sweeping tx - mining another block
×
NEW
34
        // would cause the sweeper to RBF it.
×
NEW
35
        time.Sleep(2 * time.Second)
×
NEW
36
}
×
37

38
// flakeFundExtraUTXO documents a flake found when testing the sweeping behavior
39
// of the given node, which would fail due to no wallet UTXO available, while
40
// there should be enough.
41
//
42
// TODO(yy): remove it once the issue is resolved.
NEW
43
func flakeFundExtraUTXO(ht *lntest.HarnessTest, node *node.HarnessNode) {
×
NEW
44
        // The node should have enough wallet UTXOs here to sweep the HTLC in
×
NEW
45
        // the end of this test. However, due to a known issue, the node's
×
NEW
46
        // wallet may report there's no UTXO available. For details,
×
NEW
47
        // - https://github.com/lightningnetwork/lnd/issues/8786
×
NEW
48
        ht.FundCoins(btcutil.SatoshiPerBitcoin, node)
×
NEW
49
}
×
50

51
// flakeTxNotifierNeutrino documents a flake found when running force close
52
// tests using neutrino backend, which is a race between two notifications - one
53
// for the spending notification, the other for the block which contains the
54
// spending tx.
55
//
56
// TODO(yy): remove it once the issue is resolved.
NEW
57
func flakeTxNotifierNeutrino(ht *lntest.HarnessTest) {
×
NEW
58
        // Mine an empty block the for neutrino backend. We need this step to
×
NEW
59
        // trigger Bob's chain watcher to detect the force close tx. Deep down,
×
NEW
60
        // this happens because the notification system for neutrino is very
×
NEW
61
        // different from others. Specifically, when a block contains the force
×
NEW
62
        // close tx is notified, these two calls,
×
NEW
63
        // - RegisterBlockEpochNtfn, will notify the block first.
×
NEW
64
        // - RegisterSpendNtfn, will wait for the neutrino notifier to sync to
×
NEW
65
        //   the block, then perform a GetUtxo, which, by the time the spend
×
NEW
66
        //   details are sent, the blockbeat is considered processed in Bob's
×
NEW
67
        //   chain watcher.
×
NEW
68
        //
×
NEW
69
        // TODO(yy): refactor txNotifier to fix the above issue.
×
NEW
70
        if ht.IsNeutrinoBackend() {
×
NEW
71
                ht.MineEmptyBlocks(1)
×
NEW
72
        }
×
73
}
74

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

×
NEW
92
        // Skip the assertion below if it's on macOS.
×
NEW
93
        if isDarwin() {
×
NEW
94
                ht.Logf("Skipped AssertNumPendingSweeps for node %s",
×
NEW
95
                        node.Name())
×
NEW
96

×
NEW
97
                return
×
NEW
98
        }
×
99

NEW
100
        ht.AssertNumPendingSweeps(node, num)
×
101
}
102

103
// isDarwin returns true if the test is running on a macOS.
NEW
104
func isDarwin() bool {
×
NEW
105
        return runtime.GOOS == "darwin"
×
NEW
106
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc