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

lightningnetwork / lnd / 11965896165

22 Nov 2024 03:26AM UTC coverage: 49.579% (-9.4%) from 58.98%
11965896165

Pull #8512

github

Roasbeef
lnwallet/chancloser: add unit tests for new rbf coop close
Pull Request #8512: [3/4] - lnwallet/chancloser: add new protofsm based RBF chan closer

30 of 1081 new or added lines in 8 files covered. (2.78%)

25859 existing lines in 424 files now uncovered.

99910 of 201515 relevant lines covered (49.58%)

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"
13
        "github.com/lightningnetwork/lnd/lnwallet/chainfee"
14
        "github.com/lightningnetwork/lnd/lnwire"
15
        "github.com/stretchr/testify/mock"
16

17
        "github.com/lightningnetwork/lnd/input"
18
        "github.com/lightningnetwork/lnd/lnwallet"
19
)
20

21
type dummyAdapters struct {
22
        mock.Mock
23

24
        msgSent atomic.Bool
25

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

NEW
125
func (m *mockChanObserver) MarkShutdownSent(deliveryAddr []byte, isInitiator bool) error {
×
NEW
126
        args := m.Called(deliveryAddr, isInitiator)
×
NEW
127
        return args.Error(0)
×
NEW
128
}
×
129

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

135
type mockErrorReporter struct {
136
        mock.Mock
137
}
138

NEW
139
func (m *mockErrorReporter) ReportError(err error) {
×
NEW
140
        m.Called(err)
×
NEW
141
}
×
142

143
type mockCloseSigner struct {
144
        mock.Mock
145
}
146

147
func (m *mockCloseSigner) CreateCloseProposal(fee btcutil.Amount,
148
        localScript []byte, remoteScript []byte,
149
        closeOpt ...lnwallet.ChanCloseOpt) (
NEW
150
        input.Signature, *chainhash.Hash, btcutil.Amount, error) {
×
NEW
151

×
NEW
152
        args := m.Called(fee, localScript, remoteScript, closeOpt)
×
NEW
153

×
NEW
154
        return args.Get(0).(input.Signature), args.Get(1).(*chainhash.Hash),
×
NEW
155
                args.Get(2).(btcutil.Amount), args.Error(3)
×
NEW
156
}
×
157

158
func (m *mockCloseSigner) CompleteCooperativeClose(localSig,
159
        remoteSig input.Signature,
160
        localScript, remoteScript []byte,
161
        fee btcutil.Amount, closeOpt ...lnwallet.ChanCloseOpt,
NEW
162
) (*wire.MsgTx, btcutil.Amount, error) {
×
NEW
163

×
NEW
164
        args := m.Called(
×
NEW
165
                localSig, remoteSig, localScript, remoteScript, fee, closeOpt,
×
NEW
166
        )
×
NEW
167

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