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

lightningnetwork / lnd / 12199391122

06 Dec 2024 01:10PM UTC coverage: 49.807% (-9.1%) from 58.933%
12199391122

push

github

web-flow
Merge pull request #9337 from Guayaba221/patch-1

chore: fix typo in ruby.md

100137 of 201051 relevant lines covered (49.81%)

2.07 hits per line

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

0.0
/invoices/mock.go
1
package invoices
2

3
import (
4
        "context"
5

6
        "github.com/lightningnetwork/lnd/lntypes"
7
        "github.com/stretchr/testify/mock"
8
)
9

10
type MockInvoiceDB struct {
11
        mock.Mock
12
}
13

14
func NewInvoicesDBMock() *MockInvoiceDB {
×
15
        return &MockInvoiceDB{}
×
16
}
×
17

18
func (m *MockInvoiceDB) AddInvoice(invoice *Invoice,
19
        paymentHash lntypes.Hash) (uint64, error) {
×
20

×
21
        args := m.Called(invoice, paymentHash)
×
22

×
23
        addIndex, _ := args.Get(0).(uint64)
×
24

×
25
        // NOTE: this is a side effect of the AddInvoice method.
×
26
        invoice.AddIndex = addIndex
×
27

×
28
        return addIndex, args.Error(1)
×
29
}
×
30

31
func (m *MockInvoiceDB) InvoicesAddedSince(idx uint64) ([]Invoice, error) {
×
32
        args := m.Called(idx)
×
33
        invoices, _ := args.Get(0).([]Invoice)
×
34

×
35
        return invoices, args.Error(1)
×
36
}
×
37

38
func (m *MockInvoiceDB) InvoicesSettledSince(idx uint64) ([]Invoice, error) {
×
39
        args := m.Called(idx)
×
40
        invoices, _ := args.Get(0).([]Invoice)
×
41

×
42
        return invoices, args.Error(1)
×
43
}
×
44

45
func (m *MockInvoiceDB) LookupInvoice(ref InvoiceRef) (Invoice, error) {
×
46
        args := m.Called(ref)
×
47
        invoice, _ := args.Get(0).(Invoice)
×
48

×
49
        return invoice, args.Error(1)
×
50
}
×
51

52
func (m *MockInvoiceDB) FetchPendingInvoices(ctx context.Context) (
53
        map[lntypes.Hash]Invoice, error) {
×
54

×
55
        args := m.Called(ctx)
×
56
        return args.Get(0).(map[lntypes.Hash]Invoice), args.Error(1)
×
57
}
×
58

59
func (m *MockInvoiceDB) QueryInvoices(q InvoiceQuery) (InvoiceSlice, error) {
×
60
        args := m.Called(q)
×
61
        invoiceSlice, _ := args.Get(0).(InvoiceSlice)
×
62

×
63
        return invoiceSlice, args.Error(1)
×
64
}
×
65

66
func (m *MockInvoiceDB) UpdateInvoice(ref InvoiceRef, setIDHint *SetID,
67
        callback InvoiceUpdateCallback) (*Invoice, error) {
×
68

×
69
        args := m.Called(ref, setIDHint, callback)
×
70
        invoice, _ := args.Get(0).(*Invoice)
×
71

×
72
        return invoice, args.Error(1)
×
73
}
×
74

75
func (m *MockInvoiceDB) DeleteInvoice(invoices []InvoiceDeleteRef) error {
×
76
        args := m.Called(invoices)
×
77

×
78
        return args.Error(0)
×
79
}
×
80

81
func (m *MockInvoiceDB) DeleteCanceledInvoices(ctx context.Context) error {
×
82
        args := m.Called(ctx)
×
83

×
84
        return args.Error(0)
×
85
}
×
86

87
// MockHtlcModifier is a mock implementation of the HtlcModifier interface.
88
type MockHtlcModifier struct {
89
}
90

91
// Intercept generates a new intercept session for the given invoice.
92
// The call blocks until the client has responded to the request or an
93
// error occurs. The response callback is only called if a session was
94
// created in the first place, which is only the case if a client is
95
// registered.
96
func (m *MockHtlcModifier) Intercept(
97
        _ HtlcModifyRequest, _ func(HtlcModifyResponse)) error {
×
98

×
99
        return nil
×
100
}
×
101

102
// RegisterInterceptor sets the client callback function that will be
103
// called when an invoice is intercepted. If a callback is already set,
104
// an error is returned. The returned function must be used to reset the
105
// callback to nil once the client is done or disconnects. The read-only channel
106
// closes when the server stops.
107
func (m *MockHtlcModifier) RegisterInterceptor(HtlcModifyCallback) (func(),
108
        <-chan struct{}, error) {
×
109

×
110
        return func() {}, make(chan struct{}), nil
×
111
}
112

113
// Ensure that MockHtlcModifier implements the HtlcInterceptor and HtlcModifier
114
// interfaces.
115
var _ HtlcInterceptor = (*MockHtlcModifier)(nil)
116
var _ HtlcModifier = (*MockHtlcModifier)(nil)
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