-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
chain.go
165 lines (115 loc) · 3.34 KB
/
chain.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package lnmock
import (
"github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/chain"
"github.com/btcsuite/btcwallet/waddrmgr"
"github.com/stretchr/testify/mock"
)
// MockChain is a mock implementation of the Chain interface.
type MockChain struct {
mock.Mock
}
// Compile-time constraint to ensure MockChain implements the Chain interface.
var _ chain.Interface = (*MockChain)(nil)
func (m *MockChain) Start() error {
args := m.Called()
return args.Error(0)
}
func (m *MockChain) Stop() {
m.Called()
}
func (m *MockChain) WaitForShutdown() {
m.Called()
}
func (m *MockChain) GetBestBlock() (*chainhash.Hash, int32, error) {
args := m.Called()
if args.Get(0) == nil {
return nil, args.Get(1).(int32), args.Error(2)
}
return args.Get(0).(*chainhash.Hash), args.Get(1).(int32), args.Error(2)
}
func (m *MockChain) GetBlock(hash *chainhash.Hash) (*wire.MsgBlock, error) {
args := m.Called(hash)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*wire.MsgBlock), args.Error(1)
}
func (m *MockChain) GetBlockHash(height int64) (*chainhash.Hash, error) {
args := m.Called(height)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*chainhash.Hash), args.Error(1)
}
func (m *MockChain) GetBlockHeader(hash *chainhash.Hash) (
*wire.BlockHeader, error) {
args := m.Called(hash)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*wire.BlockHeader), args.Error(1)
}
func (m *MockChain) IsCurrent() bool {
args := m.Called()
return args.Bool(0)
}
func (m *MockChain) FilterBlocks(req *chain.FilterBlocksRequest) (
*chain.FilterBlocksResponse, error) {
args := m.Called(req)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*chain.FilterBlocksResponse), args.Error(1)
}
func (m *MockChain) BlockStamp() (*waddrmgr.BlockStamp, error) {
args := m.Called()
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*waddrmgr.BlockStamp), args.Error(1)
}
func (m *MockChain) SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (
*chainhash.Hash, error) {
args := m.Called(tx, allowHighFees)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*chainhash.Hash), args.Error(1)
}
func (m *MockChain) Rescan(startHash *chainhash.Hash, addrs []btcutil.Address,
outPoints map[wire.OutPoint]btcutil.Address) error {
args := m.Called(startHash, addrs, outPoints)
return args.Error(0)
}
func (m *MockChain) NotifyReceived(addrs []btcutil.Address) error {
args := m.Called(addrs)
return args.Error(0)
}
func (m *MockChain) NotifyBlocks() error {
args := m.Called()
return args.Error(0)
}
func (m *MockChain) Notifications() <-chan interface{} {
args := m.Called()
return args.Get(0).(<-chan interface{})
}
func (m *MockChain) BackEnd() string {
args := m.Called()
return args.String(0)
}
func (m *MockChain) TestMempoolAccept(txns []*wire.MsgTx, maxFeeRate float64) (
[]*btcjson.TestMempoolAcceptResult, error) {
args := m.Called(txns, maxFeeRate)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).([]*btcjson.TestMempoolAcceptResult), args.Error(1)
}
func (m *MockChain) MapRPCErr(err error) error {
args := m.Called(err)
return args.Error(0)
}