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

lightningnetwork / lnd / 14193549836

01 Apr 2025 10:40AM UTC coverage: 69.046% (+0.007%) from 69.039%
14193549836

Pull #9665

github

web-flow
Merge e8825f209 into b01f4e514
Pull Request #9665: kvdb: bump etcd libs to v3.5.12

133439 of 193262 relevant lines covered (69.05%)

22119.45 hits per line

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

84.85
/lnwallet/chancloser/mock.go
1
package chancloser
2

3
import (
4
        "sync/atomic"
5

6
        "github.com/btcsuite/btcd/btcec/v2"
7
        "github.com/btcsuite/btcd/btcutil"
8
        "github.com/btcsuite/btcd/chaincfg/chainhash"
9
        "github.com/btcsuite/btcd/wire"
10
        "github.com/lightningnetwork/lnd/chainntnfs"
11
        "github.com/lightningnetwork/lnd/channeldb"
12
        "github.com/lightningnetwork/lnd/fn/v2"
13
        "github.com/lightningnetwork/lnd/input"
14
        "github.com/lightningnetwork/lnd/lnwallet"
15
        "github.com/lightningnetwork/lnd/lnwallet/chainfee"
16
        "github.com/lightningnetwork/lnd/lnwire"
17
        "github.com/stretchr/testify/mock"
18
)
19

20
type dummyAdapters struct {
21
        mock.Mock
22

23
        msgSent atomic.Bool
24

25
        confChan  chan *chainntnfs.TxConfirmation
26
        spendChan chan *chainntnfs.SpendDetail
27
}
28

29
func newDaemonAdapters() *dummyAdapters {
42✔
30
        return &dummyAdapters{
42✔
31
                confChan:  make(chan *chainntnfs.TxConfirmation, 1),
42✔
32
                spendChan: make(chan *chainntnfs.SpendDetail, 1),
42✔
33
        }
42✔
34
}
42✔
35

36
func (d *dummyAdapters) SendMessages(pub btcec.PublicKey,
37
        msgs []lnwire.Message) error {
15✔
38

15✔
39
        defer d.msgSent.Store(true)
15✔
40

15✔
41
        args := d.Called(pub, msgs)
15✔
42

15✔
43
        return args.Error(0)
15✔
44
}
15✔
45

46
func (d *dummyAdapters) BroadcastTransaction(tx *wire.MsgTx,
47
        label string) error {
9✔
48

9✔
49
        args := d.Called(tx, label)
9✔
50

9✔
51
        return args.Error(0)
9✔
52
}
9✔
53

54
func (d *dummyAdapters) DisableChannel(op wire.OutPoint) error {
×
55
        args := d.Called(op)
×
56

×
57
        return args.Error(0)
×
58
}
×
59

60
func (d *dummyAdapters) RegisterConfirmationsNtfn(txid *chainhash.Hash,
61
        pkScript []byte, numConfs, heightHint uint32,
62
        opts ...chainntnfs.NotifierOption,
63
) (*chainntnfs.ConfirmationEvent, error) {
×
64

×
65
        args := d.Called(txid, pkScript, numConfs)
×
66

×
67
        err := args.Error(0)
×
68

×
69
        return &chainntnfs.ConfirmationEvent{
×
70
                Confirmed: d.confChan,
×
71
        }, err
×
72
}
×
73

74
func (d *dummyAdapters) RegisterSpendNtfn(outpoint *wire.OutPoint,
75
        pkScript []byte, heightHint uint32) (*chainntnfs.SpendEvent, error) {
42✔
76

42✔
77
        args := d.Called(outpoint, pkScript, heightHint)
42✔
78

42✔
79
        err := args.Error(0)
42✔
80

42✔
81
        return &chainntnfs.SpendEvent{
42✔
82
                Spend: d.spendChan,
42✔
83
        }, err
42✔
84
}
42✔
85

86
type mockFeeEstimator struct {
87
        mock.Mock
88
}
89

90
func (m *mockFeeEstimator) EstimateFee(chanType channeldb.ChannelType,
91
        localTxOut, remoteTxOut *wire.TxOut,
92
        idealFeeRate chainfee.SatPerKWeight) btcutil.Amount {
15✔
93

15✔
94
        args := m.Called(chanType, localTxOut, remoteTxOut, idealFeeRate)
15✔
95
        return args.Get(0).(btcutil.Amount)
15✔
96
}
15✔
97

98
type mockChanObserver struct {
99
        mock.Mock
100
}
101

102
func (m *mockChanObserver) NoDanglingUpdates() bool {
2✔
103
        args := m.Called()
2✔
104
        return args.Bool(0)
2✔
105
}
2✔
106

107
func (m *mockChanObserver) DisableIncomingAdds() error {
3✔
108
        args := m.Called()
3✔
109
        return args.Error(0)
3✔
110
}
3✔
111

112
func (m *mockChanObserver) DisableOutgoingAdds() error {
2✔
113
        args := m.Called()
2✔
114
        return args.Error(0)
2✔
115
}
2✔
116

117
func (m *mockChanObserver) MarkCoopBroadcasted(txn *wire.MsgTx,
118
        local bool) error {
11✔
119

11✔
120
        args := m.Called(txn, local)
11✔
121
        return args.Error(0)
11✔
122
}
11✔
123

124
func (m *mockChanObserver) MarkShutdownSent(deliveryAddr []byte,
125
        isInitiator bool) error {
2✔
126

2✔
127
        args := m.Called(deliveryAddr, isInitiator)
2✔
128
        return args.Error(0)
2✔
129
}
2✔
130

131
func (m *mockChanObserver) FinalBalances() fn.Option[ShutdownBalances] {
6✔
132
        args := m.Called()
6✔
133
        return args.Get(0).(fn.Option[ShutdownBalances])
6✔
134
}
6✔
135

136
func (m *mockChanObserver) DisableChannel() error {
2✔
137
        args := m.Called()
2✔
138
        return args.Error(0)
2✔
139
}
2✔
140

141
type mockErrorReporter struct {
142
        mock.Mock
143
}
144

145
func (m *mockErrorReporter) ReportError(err error) {
14✔
146
        m.Called(err)
14✔
147
}
14✔
148

149
type mockCloseSigner struct {
150
        mock.Mock
151
}
152

153
func (m *mockCloseSigner) CreateCloseProposal(fee btcutil.Amount,
154
        localScript []byte, remoteScript []byte,
155
        closeOpt ...lnwallet.ChanCloseOpt) (
156
        input.Signature, *wire.MsgTx, btcutil.Amount, error) {
14✔
157

14✔
158
        args := m.Called(fee, localScript, remoteScript, closeOpt)
14✔
159

14✔
160
        return args.Get(0).(input.Signature), args.Get(1).(*wire.MsgTx),
14✔
161
                args.Get(2).(btcutil.Amount), args.Error(3)
14✔
162
}
14✔
163

164
func (m *mockCloseSigner) CompleteCooperativeClose(localSig,
165
        remoteSig input.Signature,
166
        localScript, remoteScript []byte,
167
        fee btcutil.Amount, closeOpt ...lnwallet.ChanCloseOpt,
168
) (*wire.MsgTx, btcutil.Amount, error) {
9✔
169

9✔
170
        args := m.Called(
9✔
171
                localSig, remoteSig, localScript, remoteScript, fee, closeOpt,
9✔
172
        )
9✔
173

9✔
174
        return args.Get(0).(*wire.MsgTx), args.Get(1).(btcutil.Amount),
9✔
175
                args.Error(2)
9✔
176
}
9✔
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