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

lightningnetwork / lnd / 15736109134

18 Jun 2025 02:46PM UTC coverage: 58.197% (-10.1%) from 68.248%
15736109134

Pull #9752

github

web-flow
Merge d2634a68c into 31c74f20f
Pull Request #9752: routerrpc: reject payment to invoice that don't have payment secret or blinded paths

6 of 13 new or added lines in 2 files covered. (46.15%)

28331 existing lines in 455 files now uncovered.

97860 of 168153 relevant lines covered (58.2%)

1.81 hits per line

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

0.0
/chainntnfs/mocks.go
1
package chainntnfs
2

3
import (
4
        "github.com/btcsuite/btcd/chaincfg/chainhash"
5
        "github.com/btcsuite/btcd/wire"
6
        "github.com/lightningnetwork/lnd/fn/v2"
7
        "github.com/stretchr/testify/mock"
8
)
9

10
// MockMempoolWatcher is a mock implementation of the MempoolWatcher interface.
11
// This is used by other subsystems to mock the behavior of the mempool
12
// watcher.
13
type MockMempoolWatcher struct {
14
        mock.Mock
15
}
16

17
// NewMockMempoolWatcher returns a new instance of a mock mempool watcher.
UNCOV
18
func NewMockMempoolWatcher() *MockMempoolWatcher {
×
UNCOV
19
        return &MockMempoolWatcher{}
×
UNCOV
20
}
×
21

22
// Compile-time check to ensure MockMempoolWatcher implements MempoolWatcher.
23
var _ MempoolWatcher = (*MockMempoolWatcher)(nil)
24

25
// SubscribeMempoolSpent implements the MempoolWatcher interface.
26
func (m *MockMempoolWatcher) SubscribeMempoolSpent(
27
        op wire.OutPoint) (*MempoolSpendEvent, error) {
×
28

×
29
        args := m.Called(op)
×
30

×
31
        if args.Get(0) == nil {
×
32
                return nil, args.Error(1)
×
33
        }
×
34

35
        return args.Get(0).(*MempoolSpendEvent), args.Error(1)
×
36
}
37

38
// CancelMempoolSpendEvent implements the MempoolWatcher interface.
39
func (m *MockMempoolWatcher) CancelMempoolSpendEvent(
40
        sub *MempoolSpendEvent) {
×
41

×
42
        m.Called(sub)
×
43
}
×
44

45
// LookupInputMempoolSpend looks up the mempool to find a spending tx which
46
// spends the given outpoint.
47
func (m *MockMempoolWatcher) LookupInputMempoolSpend(
UNCOV
48
        op wire.OutPoint) fn.Option[wire.MsgTx] {
×
UNCOV
49

×
UNCOV
50
        args := m.Called(op)
×
UNCOV
51

×
UNCOV
52
        return args.Get(0).(fn.Option[wire.MsgTx])
×
UNCOV
53
}
×
54

55
// MockNotifier is a mock implementation of the ChainNotifier interface.
56
type MockChainNotifier struct {
57
        mock.Mock
58
}
59

60
// Compile-time check to ensure MockChainNotifier implements ChainNotifier.
61
var _ ChainNotifier = (*MockChainNotifier)(nil)
62

63
// RegisterConfirmationsNtfn registers an intent to be notified once txid
64
// reaches numConfs confirmations.
65
func (m *MockChainNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
66
        pkScript []byte, numConfs, heightHint uint32,
67
        opts ...NotifierOption) (*ConfirmationEvent, error) {
×
68

×
69
        args := m.Called(txid, pkScript, numConfs, heightHint)
×
70
        if args.Get(0) == nil {
×
71
                return nil, args.Error(1)
×
72
        }
×
73

74
        return args.Get(0).(*ConfirmationEvent), args.Error(1)
×
75
}
76

77
// RegisterSpendNtfn registers an intent to be notified once the target
78
// outpoint is successfully spent within a transaction.
79
func (m *MockChainNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
UNCOV
80
        pkScript []byte, heightHint uint32) (*SpendEvent, error) {
×
UNCOV
81

×
UNCOV
82
        args := m.Called(outpoint, pkScript, heightHint)
×
UNCOV
83
        if args.Get(0) == nil {
×
84
                return nil, args.Error(1)
×
85
        }
×
86

UNCOV
87
        return args.Get(0).(*SpendEvent), args.Error(1)
×
88
}
89

90
// RegisterBlockEpochNtfn registers an intent to be notified of each new block
91
// connected to the tip of the main chain.
92
func (m *MockChainNotifier) RegisterBlockEpochNtfn(epoch *BlockEpoch) (
UNCOV
93
        *BlockEpochEvent, error) {
×
UNCOV
94

×
UNCOV
95
        args := m.Called(epoch)
×
UNCOV
96
        if args.Get(0) == nil {
×
UNCOV
97
                return nil, args.Error(1)
×
UNCOV
98
        }
×
99

UNCOV
100
        return args.Get(0).(*BlockEpochEvent), args.Error(1)
×
101
}
102

103
// Start the ChainNotifier. Once started, the implementation should be ready,
104
// and able to receive notification registrations from clients.
105
func (m *MockChainNotifier) Start() error {
×
106
        args := m.Called()
×
107

×
108
        return args.Error(0)
×
109
}
×
110

111
// Started returns true if this instance has been started, and false otherwise.
112
func (m *MockChainNotifier) Started() bool {
×
113
        args := m.Called()
×
114

×
115
        return args.Bool(0)
×
116
}
×
117

118
// Stops the concrete ChainNotifier.
119
func (m *MockChainNotifier) Stop() error {
×
120
        args := m.Called()
×
121

×
122
        return args.Error(0)
×
123
}
×
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