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

lightningnetwork / lnd / 13586005509

28 Feb 2025 10:14AM UTC coverage: 68.629% (+9.9%) from 58.77%
13586005509

Pull #9521

github

web-flow
Merge 37d3a70a5 into 8532955b3
Pull Request #9521: unit: remove GOACC, use Go 1.20 native coverage functionality

129950 of 189351 relevant lines covered (68.63%)

23726.46 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 {
24✔
30
        return &dummyAdapters{
24✔
31
                confChan:  make(chan *chainntnfs.TxConfirmation, 1),
24✔
32
                spendChan: make(chan *chainntnfs.SpendDetail, 1),
24✔
33
        }
24✔
34
}
24✔
35

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

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

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

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

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

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

5✔
51
        return args.Error(0)
5✔
52
}
5✔
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) {
24✔
76

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

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

24✔
81
        return &chainntnfs.SpendEvent{
24✔
82
                Spend: d.spendChan,
24✔
83
        }, err
24✔
84
}
24✔
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 {
14✔
93

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

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

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

107
func (m *mockChanObserver) DisableIncomingAdds() error {
4✔
108
        args := m.Called()
4✔
109
        return args.Error(0)
4✔
110
}
4✔
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 {
7✔
119

7✔
120
        args := m.Called(txn, local)
7✔
121
        return args.Error(0)
7✔
122
}
7✔
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] {
8✔
132
        args := m.Called()
8✔
133
        return args.Get(0).(fn.Option[ShutdownBalances])
8✔
134
}
8✔
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) {
9✔
146
        m.Called(err)
9✔
147
}
9✔
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) {
10✔
157

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

10✔
160
        return args.Get(0).(input.Signature), args.Get(1).(*wire.MsgTx),
10✔
161
                args.Get(2).(btcutil.Amount), args.Error(3)
10✔
162
}
10✔
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) {
5✔
169

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

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