-
Notifications
You must be signed in to change notification settings - Fork 5
/
peer_handler_gen_mock.go
381 lines (356 loc) · 12.3 KB
/
peer_handler_gen_mock.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package p2p
import (
"github.com/libsv/go-p2p/wire"
"sync"
)
// Ensure, that PeerHandlerIMock does implement PeerHandlerI.
// If this is not the case, regenerate this file with moq.
var _ PeerHandlerI = &PeerHandlerIMock{}
// PeerHandlerIMock is a mock implementation of PeerHandlerI.
//
// func TestSomethingThatUsesPeerHandlerI(t *testing.T) {
//
// // make and configure a mocked PeerHandlerI
// mockedPeerHandlerI := &PeerHandlerIMock{
// HandleBlockFunc: func(msg wire.Message, peer PeerI) error {
// panic("mock out the HandleBlock method")
// },
// HandleBlockAnnouncementFunc: func(msg *wire.InvVect, peer PeerI) error {
// panic("mock out the HandleBlockAnnouncement method")
// },
// HandleTransactionFunc: func(msg *wire.MsgTx, peer PeerI) error {
// panic("mock out the HandleTransaction method")
// },
// HandleTransactionAnnouncementFunc: func(msg *wire.InvVect, peer PeerI) error {
// panic("mock out the HandleTransactionAnnouncement method")
// },
// HandleTransactionRejectionFunc: func(rejMsg *wire.MsgReject, peer PeerI) error {
// panic("mock out the HandleTransactionRejection method")
// },
// HandleTransactionSentFunc: func(msg *wire.MsgTx, peer PeerI) error {
// panic("mock out the HandleTransactionSent method")
// },
// HandleTransactionsGetFunc: func(msgs []*wire.InvVect, peer PeerI) ([][]byte, error) {
// panic("mock out the HandleTransactionsGet method")
// },
// }
//
// // use mockedPeerHandlerI in code that requires PeerHandlerI
// // and then make assertions.
//
// }
type PeerHandlerIMock struct {
// HandleBlockFunc mocks the HandleBlock method.
HandleBlockFunc func(msg wire.Message, peer PeerI) error
// HandleBlockAnnouncementFunc mocks the HandleBlockAnnouncement method.
HandleBlockAnnouncementFunc func(msg *wire.InvVect, peer PeerI) error
// HandleTransactionFunc mocks the HandleTransaction method.
HandleTransactionFunc func(msg *wire.MsgTx, peer PeerI) error
// HandleTransactionAnnouncementFunc mocks the HandleTransactionAnnouncement method.
HandleTransactionAnnouncementFunc func(msg *wire.InvVect, peer PeerI) error
// HandleTransactionRejectionFunc mocks the HandleTransactionRejection method.
HandleTransactionRejectionFunc func(rejMsg *wire.MsgReject, peer PeerI) error
// HandleTransactionSentFunc mocks the HandleTransactionSent method.
HandleTransactionSentFunc func(msg *wire.MsgTx, peer PeerI) error
// HandleTransactionsGetFunc mocks the HandleTransactionsGet method.
HandleTransactionsGetFunc func(msgs []*wire.InvVect, peer PeerI) ([][]byte, error)
// calls tracks calls to the methods.
calls struct {
// HandleBlock holds details about calls to the HandleBlock method.
HandleBlock []struct {
// Msg is the msg argument value.
Msg wire.Message
// Peer is the peer argument value.
Peer PeerI
}
// HandleBlockAnnouncement holds details about calls to the HandleBlockAnnouncement method.
HandleBlockAnnouncement []struct {
// Msg is the msg argument value.
Msg *wire.InvVect
// Peer is the peer argument value.
Peer PeerI
}
// HandleTransaction holds details about calls to the HandleTransaction method.
HandleTransaction []struct {
// Msg is the msg argument value.
Msg *wire.MsgTx
// Peer is the peer argument value.
Peer PeerI
}
// HandleTransactionAnnouncement holds details about calls to the HandleTransactionAnnouncement method.
HandleTransactionAnnouncement []struct {
// Msg is the msg argument value.
Msg *wire.InvVect
// Peer is the peer argument value.
Peer PeerI
}
// HandleTransactionRejection holds details about calls to the HandleTransactionRejection method.
HandleTransactionRejection []struct {
// RejMsg is the rejMsg argument value.
RejMsg *wire.MsgReject
// Peer is the peer argument value.
Peer PeerI
}
// HandleTransactionSent holds details about calls to the HandleTransactionSent method.
HandleTransactionSent []struct {
// Msg is the msg argument value.
Msg *wire.MsgTx
// Peer is the peer argument value.
Peer PeerI
}
// HandleTransactionsGet holds details about calls to the HandleTransactionsGet method.
HandleTransactionsGet []struct {
// Msgs is the msgs argument value.
Msgs []*wire.InvVect
// Peer is the peer argument value.
Peer PeerI
}
}
lockHandleBlock sync.RWMutex
lockHandleBlockAnnouncement sync.RWMutex
lockHandleTransaction sync.RWMutex
lockHandleTransactionAnnouncement sync.RWMutex
lockHandleTransactionRejection sync.RWMutex
lockHandleTransactionSent sync.RWMutex
lockHandleTransactionsGet sync.RWMutex
}
// HandleBlock calls HandleBlockFunc.
func (mock *PeerHandlerIMock) HandleBlock(msg wire.Message, peer PeerI) error {
if mock.HandleBlockFunc == nil {
panic("PeerHandlerIMock.HandleBlockFunc: method is nil but PeerHandlerI.HandleBlock was just called")
}
callInfo := struct {
Msg wire.Message
Peer PeerI
}{
Msg: msg,
Peer: peer,
}
mock.lockHandleBlock.Lock()
mock.calls.HandleBlock = append(mock.calls.HandleBlock, callInfo)
mock.lockHandleBlock.Unlock()
return mock.HandleBlockFunc(msg, peer)
}
// HandleBlockCalls gets all the calls that were made to HandleBlock.
// Check the length with:
//
// len(mockedPeerHandlerI.HandleBlockCalls())
func (mock *PeerHandlerIMock) HandleBlockCalls() []struct {
Msg wire.Message
Peer PeerI
} {
var calls []struct {
Msg wire.Message
Peer PeerI
}
mock.lockHandleBlock.RLock()
calls = mock.calls.HandleBlock
mock.lockHandleBlock.RUnlock()
return calls
}
// HandleBlockAnnouncement calls HandleBlockAnnouncementFunc.
func (mock *PeerHandlerIMock) HandleBlockAnnouncement(msg *wire.InvVect, peer PeerI) error {
if mock.HandleBlockAnnouncementFunc == nil {
panic("PeerHandlerIMock.HandleBlockAnnouncementFunc: method is nil but PeerHandlerI.HandleBlockAnnouncement was just called")
}
callInfo := struct {
Msg *wire.InvVect
Peer PeerI
}{
Msg: msg,
Peer: peer,
}
mock.lockHandleBlockAnnouncement.Lock()
mock.calls.HandleBlockAnnouncement = append(mock.calls.HandleBlockAnnouncement, callInfo)
mock.lockHandleBlockAnnouncement.Unlock()
return mock.HandleBlockAnnouncementFunc(msg, peer)
}
// HandleBlockAnnouncementCalls gets all the calls that were made to HandleBlockAnnouncement.
// Check the length with:
//
// len(mockedPeerHandlerI.HandleBlockAnnouncementCalls())
func (mock *PeerHandlerIMock) HandleBlockAnnouncementCalls() []struct {
Msg *wire.InvVect
Peer PeerI
} {
var calls []struct {
Msg *wire.InvVect
Peer PeerI
}
mock.lockHandleBlockAnnouncement.RLock()
calls = mock.calls.HandleBlockAnnouncement
mock.lockHandleBlockAnnouncement.RUnlock()
return calls
}
// HandleTransaction calls HandleTransactionFunc.
func (mock *PeerHandlerIMock) HandleTransaction(msg *wire.MsgTx, peer PeerI) error {
if mock.HandleTransactionFunc == nil {
panic("PeerHandlerIMock.HandleTransactionFunc: method is nil but PeerHandlerI.HandleTransaction was just called")
}
callInfo := struct {
Msg *wire.MsgTx
Peer PeerI
}{
Msg: msg,
Peer: peer,
}
mock.lockHandleTransaction.Lock()
mock.calls.HandleTransaction = append(mock.calls.HandleTransaction, callInfo)
mock.lockHandleTransaction.Unlock()
return mock.HandleTransactionFunc(msg, peer)
}
// HandleTransactionCalls gets all the calls that were made to HandleTransaction.
// Check the length with:
//
// len(mockedPeerHandlerI.HandleTransactionCalls())
func (mock *PeerHandlerIMock) HandleTransactionCalls() []struct {
Msg *wire.MsgTx
Peer PeerI
} {
var calls []struct {
Msg *wire.MsgTx
Peer PeerI
}
mock.lockHandleTransaction.RLock()
calls = mock.calls.HandleTransaction
mock.lockHandleTransaction.RUnlock()
return calls
}
// HandleTransactionAnnouncement calls HandleTransactionAnnouncementFunc.
func (mock *PeerHandlerIMock) HandleTransactionAnnouncement(msg *wire.InvVect, peer PeerI) error {
if mock.HandleTransactionAnnouncementFunc == nil {
panic("PeerHandlerIMock.HandleTransactionAnnouncementFunc: method is nil but PeerHandlerI.HandleTransactionAnnouncement was just called")
}
callInfo := struct {
Msg *wire.InvVect
Peer PeerI
}{
Msg: msg,
Peer: peer,
}
mock.lockHandleTransactionAnnouncement.Lock()
mock.calls.HandleTransactionAnnouncement = append(mock.calls.HandleTransactionAnnouncement, callInfo)
mock.lockHandleTransactionAnnouncement.Unlock()
return mock.HandleTransactionAnnouncementFunc(msg, peer)
}
// HandleTransactionAnnouncementCalls gets all the calls that were made to HandleTransactionAnnouncement.
// Check the length with:
//
// len(mockedPeerHandlerI.HandleTransactionAnnouncementCalls())
func (mock *PeerHandlerIMock) HandleTransactionAnnouncementCalls() []struct {
Msg *wire.InvVect
Peer PeerI
} {
var calls []struct {
Msg *wire.InvVect
Peer PeerI
}
mock.lockHandleTransactionAnnouncement.RLock()
calls = mock.calls.HandleTransactionAnnouncement
mock.lockHandleTransactionAnnouncement.RUnlock()
return calls
}
// HandleTransactionRejection calls HandleTransactionRejectionFunc.
func (mock *PeerHandlerIMock) HandleTransactionRejection(rejMsg *wire.MsgReject, peer PeerI) error {
if mock.HandleTransactionRejectionFunc == nil {
panic("PeerHandlerIMock.HandleTransactionRejectionFunc: method is nil but PeerHandlerI.HandleTransactionRejection was just called")
}
callInfo := struct {
RejMsg *wire.MsgReject
Peer PeerI
}{
RejMsg: rejMsg,
Peer: peer,
}
mock.lockHandleTransactionRejection.Lock()
mock.calls.HandleTransactionRejection = append(mock.calls.HandleTransactionRejection, callInfo)
mock.lockHandleTransactionRejection.Unlock()
return mock.HandleTransactionRejectionFunc(rejMsg, peer)
}
// HandleTransactionRejectionCalls gets all the calls that were made to HandleTransactionRejection.
// Check the length with:
//
// len(mockedPeerHandlerI.HandleTransactionRejectionCalls())
func (mock *PeerHandlerIMock) HandleTransactionRejectionCalls() []struct {
RejMsg *wire.MsgReject
Peer PeerI
} {
var calls []struct {
RejMsg *wire.MsgReject
Peer PeerI
}
mock.lockHandleTransactionRejection.RLock()
calls = mock.calls.HandleTransactionRejection
mock.lockHandleTransactionRejection.RUnlock()
return calls
}
// HandleTransactionSent calls HandleTransactionSentFunc.
func (mock *PeerHandlerIMock) HandleTransactionSent(msg *wire.MsgTx, peer PeerI) error {
if mock.HandleTransactionSentFunc == nil {
panic("PeerHandlerIMock.HandleTransactionSentFunc: method is nil but PeerHandlerI.HandleTransactionSent was just called")
}
callInfo := struct {
Msg *wire.MsgTx
Peer PeerI
}{
Msg: msg,
Peer: peer,
}
mock.lockHandleTransactionSent.Lock()
mock.calls.HandleTransactionSent = append(mock.calls.HandleTransactionSent, callInfo)
mock.lockHandleTransactionSent.Unlock()
return mock.HandleTransactionSentFunc(msg, peer)
}
// HandleTransactionSentCalls gets all the calls that were made to HandleTransactionSent.
// Check the length with:
//
// len(mockedPeerHandlerI.HandleTransactionSentCalls())
func (mock *PeerHandlerIMock) HandleTransactionSentCalls() []struct {
Msg *wire.MsgTx
Peer PeerI
} {
var calls []struct {
Msg *wire.MsgTx
Peer PeerI
}
mock.lockHandleTransactionSent.RLock()
calls = mock.calls.HandleTransactionSent
mock.lockHandleTransactionSent.RUnlock()
return calls
}
// HandleTransactionsGet calls HandleTransactionsGetFunc.
func (mock *PeerHandlerIMock) HandleTransactionsGet(msgs []*wire.InvVect, peer PeerI) ([][]byte, error) {
if mock.HandleTransactionsGetFunc == nil {
panic("PeerHandlerIMock.HandleTransactionsGetFunc: method is nil but PeerHandlerI.HandleTransactionsGet was just called")
}
callInfo := struct {
Msgs []*wire.InvVect
Peer PeerI
}{
Msgs: msgs,
Peer: peer,
}
mock.lockHandleTransactionsGet.Lock()
mock.calls.HandleTransactionsGet = append(mock.calls.HandleTransactionsGet, callInfo)
mock.lockHandleTransactionsGet.Unlock()
return mock.HandleTransactionsGetFunc(msgs, peer)
}
// HandleTransactionsGetCalls gets all the calls that were made to HandleTransactionsGet.
// Check the length with:
//
// len(mockedPeerHandlerI.HandleTransactionsGetCalls())
func (mock *PeerHandlerIMock) HandleTransactionsGetCalls() []struct {
Msgs []*wire.InvVect
Peer PeerI
} {
var calls []struct {
Msgs []*wire.InvVect
Peer PeerI
}
mock.lockHandleTransactionsGet.RLock()
calls = mock.calls.HandleTransactionsGet
mock.lockHandleTransactionsGet.RUnlock()
return calls
}