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

lightningnetwork / lnd / 18852986778

27 Oct 2025 07:10PM UTC coverage: 54.859% (-11.8%) from 66.648%
18852986778

Pull #10265

github

web-flow
Merge 45787b3d5 into 9a7b526c0
Pull Request #10265: multi: update close logic to handle re-orgs of depth n-1, where n is num confs - add min conf floor

529 of 828 new or added lines in 17 files covered. (63.89%)

24026 existing lines in 286 files now uncovered.

110927 of 202205 relevant lines covered (54.86%)

21658.16 hits per line

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

65.85
/lntest/mock/chainnotifier.go
1
package mock
2

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

7
        "github.com/btcsuite/btcd/chaincfg/chainhash"
8
        "github.com/btcsuite/btcd/wire"
9
        "github.com/lightningnetwork/lnd/chainntnfs"
10
)
11

12
// ChainNotifier is a mock implementation of the ChainNotifier interface.
13
type ChainNotifier struct {
14
        SpendChan      chan *chainntnfs.SpendDetail
15
        EpochChan      chan *chainntnfs.BlockEpoch
16
        ConfChan       chan *chainntnfs.TxConfirmation
17
        ConfRegistered chan struct{}
18
}
19

20
// RegisterConfirmationsNtfn returns a ConfirmationEvent that contains a channel
21
// that the tx confirmation will go over.
22
func (c *ChainNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
23
        pkScript []byte, numConfs, heightHint uint32,
24
        opts ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent, error) {
28✔
25

28✔
26
        // Signal that a confirmation registration occurred.
28✔
27
        if c.ConfRegistered != nil {
43✔
28
                select {
15✔
29
                case c.ConfRegistered <- struct{}{}:
15✔
NEW
30
                default:
×
31
                }
32
        }
33

34
        return &chainntnfs.ConfirmationEvent{
28✔
35
                Confirmed: c.ConfChan,
28✔
36
                Cancel:    func() {},
46✔
37
        }, nil
38
}
39

40
// RegisterSpendNtfn returns a SpendEvent that contains a channel that the spend
41
// details will go over.
42
func (c *ChainNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
43
        pkScript []byte, heightHint uint32) (*chainntnfs.SpendEvent, error) {
60✔
44

60✔
45
        return &chainntnfs.SpendEvent{
60✔
46
                Spend:  c.SpendChan,
60✔
47
                Cancel: func() {},
86✔
48
        }, nil
49
}
50

51
// RegisterBlockEpochNtfn returns a BlockEpochEvent that contains a channel that
52
// block epochs will go over.
53
func (c *ChainNotifier) RegisterBlockEpochNtfn(blockEpoch *chainntnfs.BlockEpoch) (
54
        *chainntnfs.BlockEpochEvent, error) {
243✔
55

243✔
56
        return &chainntnfs.BlockEpochEvent{
243✔
57
                Epochs: c.EpochChan,
243✔
58
                Cancel: func() {},
485✔
59
        }, nil
60
}
61

62
// Start currently returns a dummy value.
63
func (c *ChainNotifier) Start() error {
×
64
        return nil
×
65
}
×
66

67
// Started currently returns a dummy value.
68
func (c *ChainNotifier) Started() bool {
×
69
        return true
×
70
}
×
71

72
// Stop currently returns a dummy value.
73
func (c *ChainNotifier) Stop() error {
×
74
        return nil
×
75
}
×
76

77
// WaitForConfRegistrationAndSend waits for a confirmation registration to occur
78
// and then sends a confirmation notification. This is a helper function for tests
79
// that need to ensure the chain watcher has registered for confirmations before
80
// sending the confirmation.
81
func (c *ChainNotifier) WaitForConfRegistrationAndSend(t *testing.T) {
15✔
82
        t.Helper()
15✔
83

15✔
84
        // Wait for the chain watcher to register for confirmations.
15✔
85
        select {
15✔
86
        case <-c.ConfRegistered:
15✔
NEW
87
        case <-time.After(time.Second * 2):
×
NEW
88
                t.Fatalf("timeout waiting for conf registration")
×
89
        }
90

91
        // Send the confirmation to satisfy the confirmation requirement.
92
        select {
15✔
93
        case c.ConfChan <- &chainntnfs.TxConfirmation{}:
15✔
NEW
94
        case <-time.After(time.Second * 1):
×
NEW
95
                t.Fatalf("unable to send confirmation")
×
96
        }
97
}
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