-
Notifications
You must be signed in to change notification settings - Fork 46
/
cryptography_service_mock.go
667 lines (551 loc) · 24.4 KB
/
cryptography_service_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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
package testutils
// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
import (
"crypto"
"sync"
mm_atomic "sync/atomic"
mm_time "time"
"github.com/gojuno/minimock/v3"
mm_insolar "github.com/insolar/insolar/insolar"
)
// CryptographyServiceMock implements insolar.CryptographyService
type CryptographyServiceMock struct {
t minimock.Tester
funcGetPublicKey func() (p1 crypto.PublicKey, err error)
inspectFuncGetPublicKey func()
afterGetPublicKeyCounter uint64
beforeGetPublicKeyCounter uint64
GetPublicKeyMock mCryptographyServiceMockGetPublicKey
funcSign func(ba1 []byte) (sp1 *mm_insolar.Signature, err error)
inspectFuncSign func(ba1 []byte)
afterSignCounter uint64
beforeSignCounter uint64
SignMock mCryptographyServiceMockSign
funcVerify func(p1 crypto.PublicKey, s1 mm_insolar.Signature, ba1 []byte) (b1 bool)
inspectFuncVerify func(p1 crypto.PublicKey, s1 mm_insolar.Signature, ba1 []byte)
afterVerifyCounter uint64
beforeVerifyCounter uint64
VerifyMock mCryptographyServiceMockVerify
}
// NewCryptographyServiceMock returns a mock for insolar.CryptographyService
func NewCryptographyServiceMock(t minimock.Tester) *CryptographyServiceMock {
m := &CryptographyServiceMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.GetPublicKeyMock = mCryptographyServiceMockGetPublicKey{mock: m}
m.SignMock = mCryptographyServiceMockSign{mock: m}
m.SignMock.callArgs = []*CryptographyServiceMockSignParams{}
m.VerifyMock = mCryptographyServiceMockVerify{mock: m}
m.VerifyMock.callArgs = []*CryptographyServiceMockVerifyParams{}
return m
}
type mCryptographyServiceMockGetPublicKey struct {
mock *CryptographyServiceMock
defaultExpectation *CryptographyServiceMockGetPublicKeyExpectation
expectations []*CryptographyServiceMockGetPublicKeyExpectation
}
// CryptographyServiceMockGetPublicKeyExpectation specifies expectation struct of the CryptographyService.GetPublicKey
type CryptographyServiceMockGetPublicKeyExpectation struct {
mock *CryptographyServiceMock
results *CryptographyServiceMockGetPublicKeyResults
Counter uint64
}
// CryptographyServiceMockGetPublicKeyResults contains results of the CryptographyService.GetPublicKey
type CryptographyServiceMockGetPublicKeyResults struct {
p1 crypto.PublicKey
err error
}
// Expect sets up expected params for CryptographyService.GetPublicKey
func (mmGetPublicKey *mCryptographyServiceMockGetPublicKey) Expect() *mCryptographyServiceMockGetPublicKey {
if mmGetPublicKey.mock.funcGetPublicKey != nil {
mmGetPublicKey.mock.t.Fatalf("CryptographyServiceMock.GetPublicKey mock is already set by Set")
}
if mmGetPublicKey.defaultExpectation == nil {
mmGetPublicKey.defaultExpectation = &CryptographyServiceMockGetPublicKeyExpectation{}
}
return mmGetPublicKey
}
// Inspect accepts an inspector function that has same arguments as the CryptographyService.GetPublicKey
func (mmGetPublicKey *mCryptographyServiceMockGetPublicKey) Inspect(f func()) *mCryptographyServiceMockGetPublicKey {
if mmGetPublicKey.mock.inspectFuncGetPublicKey != nil {
mmGetPublicKey.mock.t.Fatalf("Inspect function is already set for CryptographyServiceMock.GetPublicKey")
}
mmGetPublicKey.mock.inspectFuncGetPublicKey = f
return mmGetPublicKey
}
// Return sets up results that will be returned by CryptographyService.GetPublicKey
func (mmGetPublicKey *mCryptographyServiceMockGetPublicKey) Return(p1 crypto.PublicKey, err error) *CryptographyServiceMock {
if mmGetPublicKey.mock.funcGetPublicKey != nil {
mmGetPublicKey.mock.t.Fatalf("CryptographyServiceMock.GetPublicKey mock is already set by Set")
}
if mmGetPublicKey.defaultExpectation == nil {
mmGetPublicKey.defaultExpectation = &CryptographyServiceMockGetPublicKeyExpectation{mock: mmGetPublicKey.mock}
}
mmGetPublicKey.defaultExpectation.results = &CryptographyServiceMockGetPublicKeyResults{p1, err}
return mmGetPublicKey.mock
}
//Set uses given function f to mock the CryptographyService.GetPublicKey method
func (mmGetPublicKey *mCryptographyServiceMockGetPublicKey) Set(f func() (p1 crypto.PublicKey, err error)) *CryptographyServiceMock {
if mmGetPublicKey.defaultExpectation != nil {
mmGetPublicKey.mock.t.Fatalf("Default expectation is already set for the CryptographyService.GetPublicKey method")
}
if len(mmGetPublicKey.expectations) > 0 {
mmGetPublicKey.mock.t.Fatalf("Some expectations are already set for the CryptographyService.GetPublicKey method")
}
mmGetPublicKey.mock.funcGetPublicKey = f
return mmGetPublicKey.mock
}
// GetPublicKey implements insolar.CryptographyService
func (mmGetPublicKey *CryptographyServiceMock) GetPublicKey() (p1 crypto.PublicKey, err error) {
mm_atomic.AddUint64(&mmGetPublicKey.beforeGetPublicKeyCounter, 1)
defer mm_atomic.AddUint64(&mmGetPublicKey.afterGetPublicKeyCounter, 1)
if mmGetPublicKey.inspectFuncGetPublicKey != nil {
mmGetPublicKey.inspectFuncGetPublicKey()
}
if mmGetPublicKey.GetPublicKeyMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmGetPublicKey.GetPublicKeyMock.defaultExpectation.Counter, 1)
mm_results := mmGetPublicKey.GetPublicKeyMock.defaultExpectation.results
if mm_results == nil {
mmGetPublicKey.t.Fatal("No results are set for the CryptographyServiceMock.GetPublicKey")
}
return (*mm_results).p1, (*mm_results).err
}
if mmGetPublicKey.funcGetPublicKey != nil {
return mmGetPublicKey.funcGetPublicKey()
}
mmGetPublicKey.t.Fatalf("Unexpected call to CryptographyServiceMock.GetPublicKey.")
return
}
// GetPublicKeyAfterCounter returns a count of finished CryptographyServiceMock.GetPublicKey invocations
func (mmGetPublicKey *CryptographyServiceMock) GetPublicKeyAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmGetPublicKey.afterGetPublicKeyCounter)
}
// GetPublicKeyBeforeCounter returns a count of CryptographyServiceMock.GetPublicKey invocations
func (mmGetPublicKey *CryptographyServiceMock) GetPublicKeyBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmGetPublicKey.beforeGetPublicKeyCounter)
}
// MinimockGetPublicKeyDone returns true if the count of the GetPublicKey invocations corresponds
// the number of defined expectations
func (m *CryptographyServiceMock) MinimockGetPublicKeyDone() bool {
for _, e := range m.GetPublicKeyMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.GetPublicKeyMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetPublicKeyCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcGetPublicKey != nil && mm_atomic.LoadUint64(&m.afterGetPublicKeyCounter) < 1 {
return false
}
return true
}
// MinimockGetPublicKeyInspect logs each unmet expectation
func (m *CryptographyServiceMock) MinimockGetPublicKeyInspect() {
for _, e := range m.GetPublicKeyMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Error("Expected call to CryptographyServiceMock.GetPublicKey")
}
}
// if default expectation was set then invocations count should be greater than zero
if m.GetPublicKeyMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetPublicKeyCounter) < 1 {
m.t.Error("Expected call to CryptographyServiceMock.GetPublicKey")
}
// if func was set then invocations count should be greater than zero
if m.funcGetPublicKey != nil && mm_atomic.LoadUint64(&m.afterGetPublicKeyCounter) < 1 {
m.t.Error("Expected call to CryptographyServiceMock.GetPublicKey")
}
}
type mCryptographyServiceMockSign struct {
mock *CryptographyServiceMock
defaultExpectation *CryptographyServiceMockSignExpectation
expectations []*CryptographyServiceMockSignExpectation
callArgs []*CryptographyServiceMockSignParams
mutex sync.RWMutex
}
// CryptographyServiceMockSignExpectation specifies expectation struct of the CryptographyService.Sign
type CryptographyServiceMockSignExpectation struct {
mock *CryptographyServiceMock
params *CryptographyServiceMockSignParams
results *CryptographyServiceMockSignResults
Counter uint64
}
// CryptographyServiceMockSignParams contains parameters of the CryptographyService.Sign
type CryptographyServiceMockSignParams struct {
ba1 []byte
}
// CryptographyServiceMockSignResults contains results of the CryptographyService.Sign
type CryptographyServiceMockSignResults struct {
sp1 *mm_insolar.Signature
err error
}
// Expect sets up expected params for CryptographyService.Sign
func (mmSign *mCryptographyServiceMockSign) Expect(ba1 []byte) *mCryptographyServiceMockSign {
if mmSign.mock.funcSign != nil {
mmSign.mock.t.Fatalf("CryptographyServiceMock.Sign mock is already set by Set")
}
if mmSign.defaultExpectation == nil {
mmSign.defaultExpectation = &CryptographyServiceMockSignExpectation{}
}
mmSign.defaultExpectation.params = &CryptographyServiceMockSignParams{ba1}
for _, e := range mmSign.expectations {
if minimock.Equal(e.params, mmSign.defaultExpectation.params) {
mmSign.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSign.defaultExpectation.params)
}
}
return mmSign
}
// Inspect accepts an inspector function that has same arguments as the CryptographyService.Sign
func (mmSign *mCryptographyServiceMockSign) Inspect(f func(ba1 []byte)) *mCryptographyServiceMockSign {
if mmSign.mock.inspectFuncSign != nil {
mmSign.mock.t.Fatalf("Inspect function is already set for CryptographyServiceMock.Sign")
}
mmSign.mock.inspectFuncSign = f
return mmSign
}
// Return sets up results that will be returned by CryptographyService.Sign
func (mmSign *mCryptographyServiceMockSign) Return(sp1 *mm_insolar.Signature, err error) *CryptographyServiceMock {
if mmSign.mock.funcSign != nil {
mmSign.mock.t.Fatalf("CryptographyServiceMock.Sign mock is already set by Set")
}
if mmSign.defaultExpectation == nil {
mmSign.defaultExpectation = &CryptographyServiceMockSignExpectation{mock: mmSign.mock}
}
mmSign.defaultExpectation.results = &CryptographyServiceMockSignResults{sp1, err}
return mmSign.mock
}
//Set uses given function f to mock the CryptographyService.Sign method
func (mmSign *mCryptographyServiceMockSign) Set(f func(ba1 []byte) (sp1 *mm_insolar.Signature, err error)) *CryptographyServiceMock {
if mmSign.defaultExpectation != nil {
mmSign.mock.t.Fatalf("Default expectation is already set for the CryptographyService.Sign method")
}
if len(mmSign.expectations) > 0 {
mmSign.mock.t.Fatalf("Some expectations are already set for the CryptographyService.Sign method")
}
mmSign.mock.funcSign = f
return mmSign.mock
}
// When sets expectation for the CryptographyService.Sign which will trigger the result defined by the following
// Then helper
func (mmSign *mCryptographyServiceMockSign) When(ba1 []byte) *CryptographyServiceMockSignExpectation {
if mmSign.mock.funcSign != nil {
mmSign.mock.t.Fatalf("CryptographyServiceMock.Sign mock is already set by Set")
}
expectation := &CryptographyServiceMockSignExpectation{
mock: mmSign.mock,
params: &CryptographyServiceMockSignParams{ba1},
}
mmSign.expectations = append(mmSign.expectations, expectation)
return expectation
}
// Then sets up CryptographyService.Sign return parameters for the expectation previously defined by the When method
func (e *CryptographyServiceMockSignExpectation) Then(sp1 *mm_insolar.Signature, err error) *CryptographyServiceMock {
e.results = &CryptographyServiceMockSignResults{sp1, err}
return e.mock
}
// Sign implements insolar.CryptographyService
func (mmSign *CryptographyServiceMock) Sign(ba1 []byte) (sp1 *mm_insolar.Signature, err error) {
mm_atomic.AddUint64(&mmSign.beforeSignCounter, 1)
defer mm_atomic.AddUint64(&mmSign.afterSignCounter, 1)
if mmSign.inspectFuncSign != nil {
mmSign.inspectFuncSign(ba1)
}
mm_params := &CryptographyServiceMockSignParams{ba1}
// Record call args
mmSign.SignMock.mutex.Lock()
mmSign.SignMock.callArgs = append(mmSign.SignMock.callArgs, mm_params)
mmSign.SignMock.mutex.Unlock()
for _, e := range mmSign.SignMock.expectations {
if minimock.Equal(e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.sp1, e.results.err
}
}
if mmSign.SignMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmSign.SignMock.defaultExpectation.Counter, 1)
mm_want := mmSign.SignMock.defaultExpectation.params
mm_got := CryptographyServiceMockSignParams{ba1}
if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
mmSign.t.Errorf("CryptographyServiceMock.Sign got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmSign.SignMock.defaultExpectation.results
if mm_results == nil {
mmSign.t.Fatal("No results are set for the CryptographyServiceMock.Sign")
}
return (*mm_results).sp1, (*mm_results).err
}
if mmSign.funcSign != nil {
return mmSign.funcSign(ba1)
}
mmSign.t.Fatalf("Unexpected call to CryptographyServiceMock.Sign. %v", ba1)
return
}
// SignAfterCounter returns a count of finished CryptographyServiceMock.Sign invocations
func (mmSign *CryptographyServiceMock) SignAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmSign.afterSignCounter)
}
// SignBeforeCounter returns a count of CryptographyServiceMock.Sign invocations
func (mmSign *CryptographyServiceMock) SignBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmSign.beforeSignCounter)
}
// Calls returns a list of arguments used in each call to CryptographyServiceMock.Sign.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmSign *mCryptographyServiceMockSign) Calls() []*CryptographyServiceMockSignParams {
mmSign.mutex.RLock()
argCopy := make([]*CryptographyServiceMockSignParams, len(mmSign.callArgs))
copy(argCopy, mmSign.callArgs)
mmSign.mutex.RUnlock()
return argCopy
}
// MinimockSignDone returns true if the count of the Sign invocations corresponds
// the number of defined expectations
func (m *CryptographyServiceMock) MinimockSignDone() bool {
for _, e := range m.SignMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.SignMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSignCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcSign != nil && mm_atomic.LoadUint64(&m.afterSignCounter) < 1 {
return false
}
return true
}
// MinimockSignInspect logs each unmet expectation
func (m *CryptographyServiceMock) MinimockSignInspect() {
for _, e := range m.SignMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to CryptographyServiceMock.Sign with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.SignMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSignCounter) < 1 {
if m.SignMock.defaultExpectation.params == nil {
m.t.Error("Expected call to CryptographyServiceMock.Sign")
} else {
m.t.Errorf("Expected call to CryptographyServiceMock.Sign with params: %#v", *m.SignMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcSign != nil && mm_atomic.LoadUint64(&m.afterSignCounter) < 1 {
m.t.Error("Expected call to CryptographyServiceMock.Sign")
}
}
type mCryptographyServiceMockVerify struct {
mock *CryptographyServiceMock
defaultExpectation *CryptographyServiceMockVerifyExpectation
expectations []*CryptographyServiceMockVerifyExpectation
callArgs []*CryptographyServiceMockVerifyParams
mutex sync.RWMutex
}
// CryptographyServiceMockVerifyExpectation specifies expectation struct of the CryptographyService.Verify
type CryptographyServiceMockVerifyExpectation struct {
mock *CryptographyServiceMock
params *CryptographyServiceMockVerifyParams
results *CryptographyServiceMockVerifyResults
Counter uint64
}
// CryptographyServiceMockVerifyParams contains parameters of the CryptographyService.Verify
type CryptographyServiceMockVerifyParams struct {
p1 crypto.PublicKey
s1 mm_insolar.Signature
ba1 []byte
}
// CryptographyServiceMockVerifyResults contains results of the CryptographyService.Verify
type CryptographyServiceMockVerifyResults struct {
b1 bool
}
// Expect sets up expected params for CryptographyService.Verify
func (mmVerify *mCryptographyServiceMockVerify) Expect(p1 crypto.PublicKey, s1 mm_insolar.Signature, ba1 []byte) *mCryptographyServiceMockVerify {
if mmVerify.mock.funcVerify != nil {
mmVerify.mock.t.Fatalf("CryptographyServiceMock.Verify mock is already set by Set")
}
if mmVerify.defaultExpectation == nil {
mmVerify.defaultExpectation = &CryptographyServiceMockVerifyExpectation{}
}
mmVerify.defaultExpectation.params = &CryptographyServiceMockVerifyParams{p1, s1, ba1}
for _, e := range mmVerify.expectations {
if minimock.Equal(e.params, mmVerify.defaultExpectation.params) {
mmVerify.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmVerify.defaultExpectation.params)
}
}
return mmVerify
}
// Inspect accepts an inspector function that has same arguments as the CryptographyService.Verify
func (mmVerify *mCryptographyServiceMockVerify) Inspect(f func(p1 crypto.PublicKey, s1 mm_insolar.Signature, ba1 []byte)) *mCryptographyServiceMockVerify {
if mmVerify.mock.inspectFuncVerify != nil {
mmVerify.mock.t.Fatalf("Inspect function is already set for CryptographyServiceMock.Verify")
}
mmVerify.mock.inspectFuncVerify = f
return mmVerify
}
// Return sets up results that will be returned by CryptographyService.Verify
func (mmVerify *mCryptographyServiceMockVerify) Return(b1 bool) *CryptographyServiceMock {
if mmVerify.mock.funcVerify != nil {
mmVerify.mock.t.Fatalf("CryptographyServiceMock.Verify mock is already set by Set")
}
if mmVerify.defaultExpectation == nil {
mmVerify.defaultExpectation = &CryptographyServiceMockVerifyExpectation{mock: mmVerify.mock}
}
mmVerify.defaultExpectation.results = &CryptographyServiceMockVerifyResults{b1}
return mmVerify.mock
}
//Set uses given function f to mock the CryptographyService.Verify method
func (mmVerify *mCryptographyServiceMockVerify) Set(f func(p1 crypto.PublicKey, s1 mm_insolar.Signature, ba1 []byte) (b1 bool)) *CryptographyServiceMock {
if mmVerify.defaultExpectation != nil {
mmVerify.mock.t.Fatalf("Default expectation is already set for the CryptographyService.Verify method")
}
if len(mmVerify.expectations) > 0 {
mmVerify.mock.t.Fatalf("Some expectations are already set for the CryptographyService.Verify method")
}
mmVerify.mock.funcVerify = f
return mmVerify.mock
}
// When sets expectation for the CryptographyService.Verify which will trigger the result defined by the following
// Then helper
func (mmVerify *mCryptographyServiceMockVerify) When(p1 crypto.PublicKey, s1 mm_insolar.Signature, ba1 []byte) *CryptographyServiceMockVerifyExpectation {
if mmVerify.mock.funcVerify != nil {
mmVerify.mock.t.Fatalf("CryptographyServiceMock.Verify mock is already set by Set")
}
expectation := &CryptographyServiceMockVerifyExpectation{
mock: mmVerify.mock,
params: &CryptographyServiceMockVerifyParams{p1, s1, ba1},
}
mmVerify.expectations = append(mmVerify.expectations, expectation)
return expectation
}
// Then sets up CryptographyService.Verify return parameters for the expectation previously defined by the When method
func (e *CryptographyServiceMockVerifyExpectation) Then(b1 bool) *CryptographyServiceMock {
e.results = &CryptographyServiceMockVerifyResults{b1}
return e.mock
}
// Verify implements insolar.CryptographyService
func (mmVerify *CryptographyServiceMock) Verify(p1 crypto.PublicKey, s1 mm_insolar.Signature, ba1 []byte) (b1 bool) {
mm_atomic.AddUint64(&mmVerify.beforeVerifyCounter, 1)
defer mm_atomic.AddUint64(&mmVerify.afterVerifyCounter, 1)
if mmVerify.inspectFuncVerify != nil {
mmVerify.inspectFuncVerify(p1, s1, ba1)
}
mm_params := &CryptographyServiceMockVerifyParams{p1, s1, ba1}
// Record call args
mmVerify.VerifyMock.mutex.Lock()
mmVerify.VerifyMock.callArgs = append(mmVerify.VerifyMock.callArgs, mm_params)
mmVerify.VerifyMock.mutex.Unlock()
for _, e := range mmVerify.VerifyMock.expectations {
if minimock.Equal(e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.b1
}
}
if mmVerify.VerifyMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmVerify.VerifyMock.defaultExpectation.Counter, 1)
mm_want := mmVerify.VerifyMock.defaultExpectation.params
mm_got := CryptographyServiceMockVerifyParams{p1, s1, ba1}
if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
mmVerify.t.Errorf("CryptographyServiceMock.Verify got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmVerify.VerifyMock.defaultExpectation.results
if mm_results == nil {
mmVerify.t.Fatal("No results are set for the CryptographyServiceMock.Verify")
}
return (*mm_results).b1
}
if mmVerify.funcVerify != nil {
return mmVerify.funcVerify(p1, s1, ba1)
}
mmVerify.t.Fatalf("Unexpected call to CryptographyServiceMock.Verify. %v %v %v", p1, s1, ba1)
return
}
// VerifyAfterCounter returns a count of finished CryptographyServiceMock.Verify invocations
func (mmVerify *CryptographyServiceMock) VerifyAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmVerify.afterVerifyCounter)
}
// VerifyBeforeCounter returns a count of CryptographyServiceMock.Verify invocations
func (mmVerify *CryptographyServiceMock) VerifyBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmVerify.beforeVerifyCounter)
}
// Calls returns a list of arguments used in each call to CryptographyServiceMock.Verify.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmVerify *mCryptographyServiceMockVerify) Calls() []*CryptographyServiceMockVerifyParams {
mmVerify.mutex.RLock()
argCopy := make([]*CryptographyServiceMockVerifyParams, len(mmVerify.callArgs))
copy(argCopy, mmVerify.callArgs)
mmVerify.mutex.RUnlock()
return argCopy
}
// MinimockVerifyDone returns true if the count of the Verify invocations corresponds
// the number of defined expectations
func (m *CryptographyServiceMock) MinimockVerifyDone() bool {
for _, e := range m.VerifyMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.VerifyMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterVerifyCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcVerify != nil && mm_atomic.LoadUint64(&m.afterVerifyCounter) < 1 {
return false
}
return true
}
// MinimockVerifyInspect logs each unmet expectation
func (m *CryptographyServiceMock) MinimockVerifyInspect() {
for _, e := range m.VerifyMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to CryptographyServiceMock.Verify with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.VerifyMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterVerifyCounter) < 1 {
if m.VerifyMock.defaultExpectation.params == nil {
m.t.Error("Expected call to CryptographyServiceMock.Verify")
} else {
m.t.Errorf("Expected call to CryptographyServiceMock.Verify with params: %#v", *m.VerifyMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcVerify != nil && mm_atomic.LoadUint64(&m.afterVerifyCounter) < 1 {
m.t.Error("Expected call to CryptographyServiceMock.Verify")
}
}
// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *CryptographyServiceMock) MinimockFinish() {
if !m.minimockDone() {
m.MinimockGetPublicKeyInspect()
m.MinimockSignInspect()
m.MinimockVerifyInspect()
m.t.FailNow()
}
}
// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *CryptographyServiceMock) MinimockWait(timeout mm_time.Duration) {
timeoutCh := mm_time.After(timeout)
for {
if m.minimockDone() {
return
}
select {
case <-timeoutCh:
m.MinimockFinish()
return
case <-mm_time.After(10 * mm_time.Millisecond):
}
}
}
func (m *CryptographyServiceMock) minimockDone() bool {
done := true
return done &&
m.MinimockGetPublicKeyDone() &&
m.MinimockSignDone() &&
m.MinimockVerifyDone()
}