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

lightningnetwork / lnd / 12266849117

10 Dec 2024 11:57PM UTC coverage: 49.54% (-0.3%) from 49.808%
12266849117

push

github

web-flow
Merge pull request #8512 from lightningnetwork/rbf-coop-fsm

[3/4] - lnwallet/chancloser: add new protofsm based RBF chan closer

26 of 1082 new or added lines in 10 files covered. (2.4%)

68 existing lines in 8 files now uncovered.

100376 of 202617 relevant lines covered (49.54%)

2.06 hits per line

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

0.0
/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

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

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

×
NEW
39
        defer d.msgSent.Store(true)
×
NEW
40

×
NEW
41
        args := d.Called(pub, msgs)
×
NEW
42

×
NEW
43
        return args.Error(0)
×
NEW
44
}
×
45

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

×
NEW
49
        args := d.Called(tx, label)
×
NEW
50

×
NEW
51
        return args.Error(0)
×
NEW
52
}
×
53

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

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

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

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

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

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

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

×
NEW
77
        args := d.Called(outpoint, pkScript, heightHint)
×
NEW
78

×
NEW
79
        err := args.Error(0)
×
NEW
80

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

NEW
145
func (m *mockErrorReporter) ReportError(err error) {
×
NEW
146
        m.Called(err)
×
NEW
147
}
×
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) (
NEW
156
        input.Signature, *wire.MsgTx, btcutil.Amount, error) {
×
NEW
157

×
NEW
158
        args := m.Called(fee, localScript, remoteScript, closeOpt)
×
NEW
159

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

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

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

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