-
Notifications
You must be signed in to change notification settings - Fork 0
/
key_processor_mock.go
1459 lines (1143 loc) · 49.4 KB
/
key_processor_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
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package testutils
/*
DO NOT EDIT!
This code was generated automatically using github.com/gojuno/minimock v1.9
The original interface "KeyProcessor" can be found in github.com/insolar/insolar/core
*/
import (
crypto "crypto"
"sync/atomic"
"time"
"github.com/gojuno/minimock"
testify_assert "github.com/stretchr/testify/assert"
)
//KeyProcessorMock implements github.com/insolar/insolar/core.KeyProcessor
type KeyProcessorMock struct {
t minimock.Tester
ExportPrivateKeyPEMFunc func(p crypto.PrivateKey) (r []byte, r1 error)
ExportPrivateKeyPEMCounter uint64
ExportPrivateKeyPEMPreCounter uint64
ExportPrivateKeyPEMMock mKeyProcessorMockExportPrivateKeyPEM
ExportPublicKeyBinaryFunc func(p crypto.PublicKey) (r []byte, r1 error)
ExportPublicKeyBinaryCounter uint64
ExportPublicKeyBinaryPreCounter uint64
ExportPublicKeyBinaryMock mKeyProcessorMockExportPublicKeyBinary
ExportPublicKeyPEMFunc func(p crypto.PublicKey) (r []byte, r1 error)
ExportPublicKeyPEMCounter uint64
ExportPublicKeyPEMPreCounter uint64
ExportPublicKeyPEMMock mKeyProcessorMockExportPublicKeyPEM
ExtractPublicKeyFunc func(p crypto.PrivateKey) (r crypto.PublicKey)
ExtractPublicKeyCounter uint64
ExtractPublicKeyPreCounter uint64
ExtractPublicKeyMock mKeyProcessorMockExtractPublicKey
GeneratePrivateKeyFunc func() (r crypto.PrivateKey, r1 error)
GeneratePrivateKeyCounter uint64
GeneratePrivateKeyPreCounter uint64
GeneratePrivateKeyMock mKeyProcessorMockGeneratePrivateKey
ImportPrivateKeyPEMFunc func(p []byte) (r crypto.PrivateKey, r1 error)
ImportPrivateKeyPEMCounter uint64
ImportPrivateKeyPEMPreCounter uint64
ImportPrivateKeyPEMMock mKeyProcessorMockImportPrivateKeyPEM
ImportPublicKeyBinaryFunc func(p []byte) (r crypto.PublicKey, r1 error)
ImportPublicKeyBinaryCounter uint64
ImportPublicKeyBinaryPreCounter uint64
ImportPublicKeyBinaryMock mKeyProcessorMockImportPublicKeyBinary
ImportPublicKeyPEMFunc func(p []byte) (r crypto.PublicKey, r1 error)
ImportPublicKeyPEMCounter uint64
ImportPublicKeyPEMPreCounter uint64
ImportPublicKeyPEMMock mKeyProcessorMockImportPublicKeyPEM
}
//NewKeyProcessorMock returns a mock for github.com/insolar/insolar/core.KeyProcessor
func NewKeyProcessorMock(t minimock.Tester) *KeyProcessorMock {
m := &KeyProcessorMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.ExportPrivateKeyPEMMock = mKeyProcessorMockExportPrivateKeyPEM{mock: m}
m.ExportPublicKeyBinaryMock = mKeyProcessorMockExportPublicKeyBinary{mock: m}
m.ExportPublicKeyPEMMock = mKeyProcessorMockExportPublicKeyPEM{mock: m}
m.ExtractPublicKeyMock = mKeyProcessorMockExtractPublicKey{mock: m}
m.GeneratePrivateKeyMock = mKeyProcessorMockGeneratePrivateKey{mock: m}
m.ImportPrivateKeyPEMMock = mKeyProcessorMockImportPrivateKeyPEM{mock: m}
m.ImportPublicKeyBinaryMock = mKeyProcessorMockImportPublicKeyBinary{mock: m}
m.ImportPublicKeyPEMMock = mKeyProcessorMockImportPublicKeyPEM{mock: m}
return m
}
type mKeyProcessorMockExportPrivateKeyPEM struct {
mock *KeyProcessorMock
mainExpectation *KeyProcessorMockExportPrivateKeyPEMExpectation
expectationSeries []*KeyProcessorMockExportPrivateKeyPEMExpectation
}
type KeyProcessorMockExportPrivateKeyPEMExpectation struct {
input *KeyProcessorMockExportPrivateKeyPEMInput
result *KeyProcessorMockExportPrivateKeyPEMResult
}
type KeyProcessorMockExportPrivateKeyPEMInput struct {
p crypto.PrivateKey
}
type KeyProcessorMockExportPrivateKeyPEMResult struct {
r []byte
r1 error
}
//Expect specifies that invocation of KeyProcessor.ExportPrivateKeyPEM is expected from 1 to Infinity times
func (m *mKeyProcessorMockExportPrivateKeyPEM) Expect(p crypto.PrivateKey) *mKeyProcessorMockExportPrivateKeyPEM {
m.mock.ExportPrivateKeyPEMFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &KeyProcessorMockExportPrivateKeyPEMExpectation{}
}
m.mainExpectation.input = &KeyProcessorMockExportPrivateKeyPEMInput{p}
return m
}
//Return specifies results of invocation of KeyProcessor.ExportPrivateKeyPEM
func (m *mKeyProcessorMockExportPrivateKeyPEM) Return(r []byte, r1 error) *KeyProcessorMock {
m.mock.ExportPrivateKeyPEMFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &KeyProcessorMockExportPrivateKeyPEMExpectation{}
}
m.mainExpectation.result = &KeyProcessorMockExportPrivateKeyPEMResult{r, r1}
return m.mock
}
//ExpectOnce specifies that invocation of KeyProcessor.ExportPrivateKeyPEM is expected once
func (m *mKeyProcessorMockExportPrivateKeyPEM) ExpectOnce(p crypto.PrivateKey) *KeyProcessorMockExportPrivateKeyPEMExpectation {
m.mock.ExportPrivateKeyPEMFunc = nil
m.mainExpectation = nil
expectation := &KeyProcessorMockExportPrivateKeyPEMExpectation{}
expectation.input = &KeyProcessorMockExportPrivateKeyPEMInput{p}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *KeyProcessorMockExportPrivateKeyPEMExpectation) Return(r []byte, r1 error) {
e.result = &KeyProcessorMockExportPrivateKeyPEMResult{r, r1}
}
//Set uses given function f as a mock of KeyProcessor.ExportPrivateKeyPEM method
func (m *mKeyProcessorMockExportPrivateKeyPEM) Set(f func(p crypto.PrivateKey) (r []byte, r1 error)) *KeyProcessorMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.ExportPrivateKeyPEMFunc = f
return m.mock
}
//ExportPrivateKeyPEM implements github.com/insolar/insolar/core.KeyProcessor interface
func (m *KeyProcessorMock) ExportPrivateKeyPEM(p crypto.PrivateKey) (r []byte, r1 error) {
counter := atomic.AddUint64(&m.ExportPrivateKeyPEMPreCounter, 1)
defer atomic.AddUint64(&m.ExportPrivateKeyPEMCounter, 1)
if len(m.ExportPrivateKeyPEMMock.expectationSeries) > 0 {
if counter > uint64(len(m.ExportPrivateKeyPEMMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to KeyProcessorMock.ExportPrivateKeyPEM. %v", p)
return
}
input := m.ExportPrivateKeyPEMMock.expectationSeries[counter-1].input
testify_assert.Equal(m.t, *input, KeyProcessorMockExportPrivateKeyPEMInput{p}, "KeyProcessor.ExportPrivateKeyPEM got unexpected parameters")
result := m.ExportPrivateKeyPEMMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the KeyProcessorMock.ExportPrivateKeyPEM")
return
}
r = result.r
r1 = result.r1
return
}
if m.ExportPrivateKeyPEMMock.mainExpectation != nil {
input := m.ExportPrivateKeyPEMMock.mainExpectation.input
if input != nil {
testify_assert.Equal(m.t, *input, KeyProcessorMockExportPrivateKeyPEMInput{p}, "KeyProcessor.ExportPrivateKeyPEM got unexpected parameters")
}
result := m.ExportPrivateKeyPEMMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the KeyProcessorMock.ExportPrivateKeyPEM")
}
r = result.r
r1 = result.r1
return
}
if m.ExportPrivateKeyPEMFunc == nil {
m.t.Fatalf("Unexpected call to KeyProcessorMock.ExportPrivateKeyPEM. %v", p)
return
}
return m.ExportPrivateKeyPEMFunc(p)
}
//ExportPrivateKeyPEMMinimockCounter returns a count of KeyProcessorMock.ExportPrivateKeyPEMFunc invocations
func (m *KeyProcessorMock) ExportPrivateKeyPEMMinimockCounter() uint64 {
return atomic.LoadUint64(&m.ExportPrivateKeyPEMCounter)
}
//ExportPrivateKeyPEMMinimockPreCounter returns the value of KeyProcessorMock.ExportPrivateKeyPEM invocations
func (m *KeyProcessorMock) ExportPrivateKeyPEMMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.ExportPrivateKeyPEMPreCounter)
}
//ExportPrivateKeyPEMFinished returns true if mock invocations count is ok
func (m *KeyProcessorMock) ExportPrivateKeyPEMFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.ExportPrivateKeyPEMMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.ExportPrivateKeyPEMCounter) == uint64(len(m.ExportPrivateKeyPEMMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.ExportPrivateKeyPEMMock.mainExpectation != nil {
return atomic.LoadUint64(&m.ExportPrivateKeyPEMCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.ExportPrivateKeyPEMFunc != nil {
return atomic.LoadUint64(&m.ExportPrivateKeyPEMCounter) > 0
}
return true
}
type mKeyProcessorMockExportPublicKeyBinary struct {
mock *KeyProcessorMock
mainExpectation *KeyProcessorMockExportPublicKeyBinaryExpectation
expectationSeries []*KeyProcessorMockExportPublicKeyBinaryExpectation
}
type KeyProcessorMockExportPublicKeyBinaryExpectation struct {
input *KeyProcessorMockExportPublicKeyBinaryInput
result *KeyProcessorMockExportPublicKeyBinaryResult
}
type KeyProcessorMockExportPublicKeyBinaryInput struct {
p crypto.PublicKey
}
type KeyProcessorMockExportPublicKeyBinaryResult struct {
r []byte
r1 error
}
//Expect specifies that invocation of KeyProcessor.ExportPublicKeyBinary is expected from 1 to Infinity times
func (m *mKeyProcessorMockExportPublicKeyBinary) Expect(p crypto.PublicKey) *mKeyProcessorMockExportPublicKeyBinary {
m.mock.ExportPublicKeyBinaryFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &KeyProcessorMockExportPublicKeyBinaryExpectation{}
}
m.mainExpectation.input = &KeyProcessorMockExportPublicKeyBinaryInput{p}
return m
}
//Return specifies results of invocation of KeyProcessor.ExportPublicKeyBinary
func (m *mKeyProcessorMockExportPublicKeyBinary) Return(r []byte, r1 error) *KeyProcessorMock {
m.mock.ExportPublicKeyBinaryFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &KeyProcessorMockExportPublicKeyBinaryExpectation{}
}
m.mainExpectation.result = &KeyProcessorMockExportPublicKeyBinaryResult{r, r1}
return m.mock
}
//ExpectOnce specifies that invocation of KeyProcessor.ExportPublicKeyBinary is expected once
func (m *mKeyProcessorMockExportPublicKeyBinary) ExpectOnce(p crypto.PublicKey) *KeyProcessorMockExportPublicKeyBinaryExpectation {
m.mock.ExportPublicKeyBinaryFunc = nil
m.mainExpectation = nil
expectation := &KeyProcessorMockExportPublicKeyBinaryExpectation{}
expectation.input = &KeyProcessorMockExportPublicKeyBinaryInput{p}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *KeyProcessorMockExportPublicKeyBinaryExpectation) Return(r []byte, r1 error) {
e.result = &KeyProcessorMockExportPublicKeyBinaryResult{r, r1}
}
//Set uses given function f as a mock of KeyProcessor.ExportPublicKeyBinary method
func (m *mKeyProcessorMockExportPublicKeyBinary) Set(f func(p crypto.PublicKey) (r []byte, r1 error)) *KeyProcessorMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.ExportPublicKeyBinaryFunc = f
return m.mock
}
//ExportPublicKeyBinary implements github.com/insolar/insolar/core.KeyProcessor interface
func (m *KeyProcessorMock) ExportPublicKeyBinary(p crypto.PublicKey) (r []byte, r1 error) {
counter := atomic.AddUint64(&m.ExportPublicKeyBinaryPreCounter, 1)
defer atomic.AddUint64(&m.ExportPublicKeyBinaryCounter, 1)
if len(m.ExportPublicKeyBinaryMock.expectationSeries) > 0 {
if counter > uint64(len(m.ExportPublicKeyBinaryMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to KeyProcessorMock.ExportPublicKeyBinary. %v", p)
return
}
input := m.ExportPublicKeyBinaryMock.expectationSeries[counter-1].input
testify_assert.Equal(m.t, *input, KeyProcessorMockExportPublicKeyBinaryInput{p}, "KeyProcessor.ExportPublicKeyBinary got unexpected parameters")
result := m.ExportPublicKeyBinaryMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the KeyProcessorMock.ExportPublicKeyBinary")
return
}
r = result.r
r1 = result.r1
return
}
if m.ExportPublicKeyBinaryMock.mainExpectation != nil {
input := m.ExportPublicKeyBinaryMock.mainExpectation.input
if input != nil {
testify_assert.Equal(m.t, *input, KeyProcessorMockExportPublicKeyBinaryInput{p}, "KeyProcessor.ExportPublicKeyBinary got unexpected parameters")
}
result := m.ExportPublicKeyBinaryMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the KeyProcessorMock.ExportPublicKeyBinary")
}
r = result.r
r1 = result.r1
return
}
if m.ExportPublicKeyBinaryFunc == nil {
m.t.Fatalf("Unexpected call to KeyProcessorMock.ExportPublicKeyBinary. %v", p)
return
}
return m.ExportPublicKeyBinaryFunc(p)
}
//ExportPublicKeyBinaryMinimockCounter returns a count of KeyProcessorMock.ExportPublicKeyBinaryFunc invocations
func (m *KeyProcessorMock) ExportPublicKeyBinaryMinimockCounter() uint64 {
return atomic.LoadUint64(&m.ExportPublicKeyBinaryCounter)
}
//ExportPublicKeyBinaryMinimockPreCounter returns the value of KeyProcessorMock.ExportPublicKeyBinary invocations
func (m *KeyProcessorMock) ExportPublicKeyBinaryMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.ExportPublicKeyBinaryPreCounter)
}
//ExportPublicKeyBinaryFinished returns true if mock invocations count is ok
func (m *KeyProcessorMock) ExportPublicKeyBinaryFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.ExportPublicKeyBinaryMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.ExportPublicKeyBinaryCounter) == uint64(len(m.ExportPublicKeyBinaryMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.ExportPublicKeyBinaryMock.mainExpectation != nil {
return atomic.LoadUint64(&m.ExportPublicKeyBinaryCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.ExportPublicKeyBinaryFunc != nil {
return atomic.LoadUint64(&m.ExportPublicKeyBinaryCounter) > 0
}
return true
}
type mKeyProcessorMockExportPublicKeyPEM struct {
mock *KeyProcessorMock
mainExpectation *KeyProcessorMockExportPublicKeyPEMExpectation
expectationSeries []*KeyProcessorMockExportPublicKeyPEMExpectation
}
type KeyProcessorMockExportPublicKeyPEMExpectation struct {
input *KeyProcessorMockExportPublicKeyPEMInput
result *KeyProcessorMockExportPublicKeyPEMResult
}
type KeyProcessorMockExportPublicKeyPEMInput struct {
p crypto.PublicKey
}
type KeyProcessorMockExportPublicKeyPEMResult struct {
r []byte
r1 error
}
//Expect specifies that invocation of KeyProcessor.ExportPublicKeyPEM is expected from 1 to Infinity times
func (m *mKeyProcessorMockExportPublicKeyPEM) Expect(p crypto.PublicKey) *mKeyProcessorMockExportPublicKeyPEM {
m.mock.ExportPublicKeyPEMFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &KeyProcessorMockExportPublicKeyPEMExpectation{}
}
m.mainExpectation.input = &KeyProcessorMockExportPublicKeyPEMInput{p}
return m
}
//Return specifies results of invocation of KeyProcessor.ExportPublicKeyPEM
func (m *mKeyProcessorMockExportPublicKeyPEM) Return(r []byte, r1 error) *KeyProcessorMock {
m.mock.ExportPublicKeyPEMFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &KeyProcessorMockExportPublicKeyPEMExpectation{}
}
m.mainExpectation.result = &KeyProcessorMockExportPublicKeyPEMResult{r, r1}
return m.mock
}
//ExpectOnce specifies that invocation of KeyProcessor.ExportPublicKeyPEM is expected once
func (m *mKeyProcessorMockExportPublicKeyPEM) ExpectOnce(p crypto.PublicKey) *KeyProcessorMockExportPublicKeyPEMExpectation {
m.mock.ExportPublicKeyPEMFunc = nil
m.mainExpectation = nil
expectation := &KeyProcessorMockExportPublicKeyPEMExpectation{}
expectation.input = &KeyProcessorMockExportPublicKeyPEMInput{p}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *KeyProcessorMockExportPublicKeyPEMExpectation) Return(r []byte, r1 error) {
e.result = &KeyProcessorMockExportPublicKeyPEMResult{r, r1}
}
//Set uses given function f as a mock of KeyProcessor.ExportPublicKeyPEM method
func (m *mKeyProcessorMockExportPublicKeyPEM) Set(f func(p crypto.PublicKey) (r []byte, r1 error)) *KeyProcessorMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.ExportPublicKeyPEMFunc = f
return m.mock
}
//ExportPublicKeyPEM implements github.com/insolar/insolar/core.KeyProcessor interface
func (m *KeyProcessorMock) ExportPublicKeyPEM(p crypto.PublicKey) (r []byte, r1 error) {
counter := atomic.AddUint64(&m.ExportPublicKeyPEMPreCounter, 1)
defer atomic.AddUint64(&m.ExportPublicKeyPEMCounter, 1)
if len(m.ExportPublicKeyPEMMock.expectationSeries) > 0 {
if counter > uint64(len(m.ExportPublicKeyPEMMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to KeyProcessorMock.ExportPublicKeyPEM. %v", p)
return
}
input := m.ExportPublicKeyPEMMock.expectationSeries[counter-1].input
testify_assert.Equal(m.t, *input, KeyProcessorMockExportPublicKeyPEMInput{p}, "KeyProcessor.ExportPublicKeyPEM got unexpected parameters")
result := m.ExportPublicKeyPEMMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the KeyProcessorMock.ExportPublicKeyPEM")
return
}
r = result.r
r1 = result.r1
return
}
if m.ExportPublicKeyPEMMock.mainExpectation != nil {
input := m.ExportPublicKeyPEMMock.mainExpectation.input
if input != nil {
testify_assert.Equal(m.t, *input, KeyProcessorMockExportPublicKeyPEMInput{p}, "KeyProcessor.ExportPublicKeyPEM got unexpected parameters")
}
result := m.ExportPublicKeyPEMMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the KeyProcessorMock.ExportPublicKeyPEM")
}
r = result.r
r1 = result.r1
return
}
if m.ExportPublicKeyPEMFunc == nil {
m.t.Fatalf("Unexpected call to KeyProcessorMock.ExportPublicKeyPEM. %v", p)
return
}
return m.ExportPublicKeyPEMFunc(p)
}
//ExportPublicKeyPEMMinimockCounter returns a count of KeyProcessorMock.ExportPublicKeyPEMFunc invocations
func (m *KeyProcessorMock) ExportPublicKeyPEMMinimockCounter() uint64 {
return atomic.LoadUint64(&m.ExportPublicKeyPEMCounter)
}
//ExportPublicKeyPEMMinimockPreCounter returns the value of KeyProcessorMock.ExportPublicKeyPEM invocations
func (m *KeyProcessorMock) ExportPublicKeyPEMMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.ExportPublicKeyPEMPreCounter)
}
//ExportPublicKeyPEMFinished returns true if mock invocations count is ok
func (m *KeyProcessorMock) ExportPublicKeyPEMFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.ExportPublicKeyPEMMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.ExportPublicKeyPEMCounter) == uint64(len(m.ExportPublicKeyPEMMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.ExportPublicKeyPEMMock.mainExpectation != nil {
return atomic.LoadUint64(&m.ExportPublicKeyPEMCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.ExportPublicKeyPEMFunc != nil {
return atomic.LoadUint64(&m.ExportPublicKeyPEMCounter) > 0
}
return true
}
type mKeyProcessorMockExtractPublicKey struct {
mock *KeyProcessorMock
mainExpectation *KeyProcessorMockExtractPublicKeyExpectation
expectationSeries []*KeyProcessorMockExtractPublicKeyExpectation
}
type KeyProcessorMockExtractPublicKeyExpectation struct {
input *KeyProcessorMockExtractPublicKeyInput
result *KeyProcessorMockExtractPublicKeyResult
}
type KeyProcessorMockExtractPublicKeyInput struct {
p crypto.PrivateKey
}
type KeyProcessorMockExtractPublicKeyResult struct {
r crypto.PublicKey
}
//Expect specifies that invocation of KeyProcessor.ExtractPublicKey is expected from 1 to Infinity times
func (m *mKeyProcessorMockExtractPublicKey) Expect(p crypto.PrivateKey) *mKeyProcessorMockExtractPublicKey {
m.mock.ExtractPublicKeyFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &KeyProcessorMockExtractPublicKeyExpectation{}
}
m.mainExpectation.input = &KeyProcessorMockExtractPublicKeyInput{p}
return m
}
//Return specifies results of invocation of KeyProcessor.ExtractPublicKey
func (m *mKeyProcessorMockExtractPublicKey) Return(r crypto.PublicKey) *KeyProcessorMock {
m.mock.ExtractPublicKeyFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &KeyProcessorMockExtractPublicKeyExpectation{}
}
m.mainExpectation.result = &KeyProcessorMockExtractPublicKeyResult{r}
return m.mock
}
//ExpectOnce specifies that invocation of KeyProcessor.ExtractPublicKey is expected once
func (m *mKeyProcessorMockExtractPublicKey) ExpectOnce(p crypto.PrivateKey) *KeyProcessorMockExtractPublicKeyExpectation {
m.mock.ExtractPublicKeyFunc = nil
m.mainExpectation = nil
expectation := &KeyProcessorMockExtractPublicKeyExpectation{}
expectation.input = &KeyProcessorMockExtractPublicKeyInput{p}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *KeyProcessorMockExtractPublicKeyExpectation) Return(r crypto.PublicKey) {
e.result = &KeyProcessorMockExtractPublicKeyResult{r}
}
//Set uses given function f as a mock of KeyProcessor.ExtractPublicKey method
func (m *mKeyProcessorMockExtractPublicKey) Set(f func(p crypto.PrivateKey) (r crypto.PublicKey)) *KeyProcessorMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.ExtractPublicKeyFunc = f
return m.mock
}
//ExtractPublicKey implements github.com/insolar/insolar/core.KeyProcessor interface
func (m *KeyProcessorMock) ExtractPublicKey(p crypto.PrivateKey) (r crypto.PublicKey) {
counter := atomic.AddUint64(&m.ExtractPublicKeyPreCounter, 1)
defer atomic.AddUint64(&m.ExtractPublicKeyCounter, 1)
if len(m.ExtractPublicKeyMock.expectationSeries) > 0 {
if counter > uint64(len(m.ExtractPublicKeyMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to KeyProcessorMock.ExtractPublicKey. %v", p)
return
}
input := m.ExtractPublicKeyMock.expectationSeries[counter-1].input
testify_assert.Equal(m.t, *input, KeyProcessorMockExtractPublicKeyInput{p}, "KeyProcessor.ExtractPublicKey got unexpected parameters")
result := m.ExtractPublicKeyMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the KeyProcessorMock.ExtractPublicKey")
return
}
r = result.r
return
}
if m.ExtractPublicKeyMock.mainExpectation != nil {
input := m.ExtractPublicKeyMock.mainExpectation.input
if input != nil {
testify_assert.Equal(m.t, *input, KeyProcessorMockExtractPublicKeyInput{p}, "KeyProcessor.ExtractPublicKey got unexpected parameters")
}
result := m.ExtractPublicKeyMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the KeyProcessorMock.ExtractPublicKey")
}
r = result.r
return
}
if m.ExtractPublicKeyFunc == nil {
m.t.Fatalf("Unexpected call to KeyProcessorMock.ExtractPublicKey. %v", p)
return
}
return m.ExtractPublicKeyFunc(p)
}
//ExtractPublicKeyMinimockCounter returns a count of KeyProcessorMock.ExtractPublicKeyFunc invocations
func (m *KeyProcessorMock) ExtractPublicKeyMinimockCounter() uint64 {
return atomic.LoadUint64(&m.ExtractPublicKeyCounter)
}
//ExtractPublicKeyMinimockPreCounter returns the value of KeyProcessorMock.ExtractPublicKey invocations
func (m *KeyProcessorMock) ExtractPublicKeyMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.ExtractPublicKeyPreCounter)
}
//ExtractPublicKeyFinished returns true if mock invocations count is ok
func (m *KeyProcessorMock) ExtractPublicKeyFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.ExtractPublicKeyMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.ExtractPublicKeyCounter) == uint64(len(m.ExtractPublicKeyMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.ExtractPublicKeyMock.mainExpectation != nil {
return atomic.LoadUint64(&m.ExtractPublicKeyCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.ExtractPublicKeyFunc != nil {
return atomic.LoadUint64(&m.ExtractPublicKeyCounter) > 0
}
return true
}
type mKeyProcessorMockGeneratePrivateKey struct {
mock *KeyProcessorMock
mainExpectation *KeyProcessorMockGeneratePrivateKeyExpectation
expectationSeries []*KeyProcessorMockGeneratePrivateKeyExpectation
}
type KeyProcessorMockGeneratePrivateKeyExpectation struct {
result *KeyProcessorMockGeneratePrivateKeyResult
}
type KeyProcessorMockGeneratePrivateKeyResult struct {
r crypto.PrivateKey
r1 error
}
//Expect specifies that invocation of KeyProcessor.GeneratePrivateKey is expected from 1 to Infinity times
func (m *mKeyProcessorMockGeneratePrivateKey) Expect() *mKeyProcessorMockGeneratePrivateKey {
m.mock.GeneratePrivateKeyFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &KeyProcessorMockGeneratePrivateKeyExpectation{}
}
return m
}
//Return specifies results of invocation of KeyProcessor.GeneratePrivateKey
func (m *mKeyProcessorMockGeneratePrivateKey) Return(r crypto.PrivateKey, r1 error) *KeyProcessorMock {
m.mock.GeneratePrivateKeyFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &KeyProcessorMockGeneratePrivateKeyExpectation{}
}
m.mainExpectation.result = &KeyProcessorMockGeneratePrivateKeyResult{r, r1}
return m.mock
}
//ExpectOnce specifies that invocation of KeyProcessor.GeneratePrivateKey is expected once
func (m *mKeyProcessorMockGeneratePrivateKey) ExpectOnce() *KeyProcessorMockGeneratePrivateKeyExpectation {
m.mock.GeneratePrivateKeyFunc = nil
m.mainExpectation = nil
expectation := &KeyProcessorMockGeneratePrivateKeyExpectation{}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *KeyProcessorMockGeneratePrivateKeyExpectation) Return(r crypto.PrivateKey, r1 error) {
e.result = &KeyProcessorMockGeneratePrivateKeyResult{r, r1}
}
//Set uses given function f as a mock of KeyProcessor.GeneratePrivateKey method
func (m *mKeyProcessorMockGeneratePrivateKey) Set(f func() (r crypto.PrivateKey, r1 error)) *KeyProcessorMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.GeneratePrivateKeyFunc = f
return m.mock
}
//GeneratePrivateKey implements github.com/insolar/insolar/core.KeyProcessor interface
func (m *KeyProcessorMock) GeneratePrivateKey() (r crypto.PrivateKey, r1 error) {
counter := atomic.AddUint64(&m.GeneratePrivateKeyPreCounter, 1)
defer atomic.AddUint64(&m.GeneratePrivateKeyCounter, 1)
if len(m.GeneratePrivateKeyMock.expectationSeries) > 0 {
if counter > uint64(len(m.GeneratePrivateKeyMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to KeyProcessorMock.GeneratePrivateKey.")
return
}
result := m.GeneratePrivateKeyMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the KeyProcessorMock.GeneratePrivateKey")
return
}
r = result.r
r1 = result.r1
return
}
if m.GeneratePrivateKeyMock.mainExpectation != nil {
result := m.GeneratePrivateKeyMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the KeyProcessorMock.GeneratePrivateKey")
}
r = result.r
r1 = result.r1
return
}
if m.GeneratePrivateKeyFunc == nil {
m.t.Fatalf("Unexpected call to KeyProcessorMock.GeneratePrivateKey.")
return
}
return m.GeneratePrivateKeyFunc()
}
//GeneratePrivateKeyMinimockCounter returns a count of KeyProcessorMock.GeneratePrivateKeyFunc invocations
func (m *KeyProcessorMock) GeneratePrivateKeyMinimockCounter() uint64 {
return atomic.LoadUint64(&m.GeneratePrivateKeyCounter)
}
//GeneratePrivateKeyMinimockPreCounter returns the value of KeyProcessorMock.GeneratePrivateKey invocations
func (m *KeyProcessorMock) GeneratePrivateKeyMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.GeneratePrivateKeyPreCounter)
}
//GeneratePrivateKeyFinished returns true if mock invocations count is ok
func (m *KeyProcessorMock) GeneratePrivateKeyFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.GeneratePrivateKeyMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.GeneratePrivateKeyCounter) == uint64(len(m.GeneratePrivateKeyMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.GeneratePrivateKeyMock.mainExpectation != nil {
return atomic.LoadUint64(&m.GeneratePrivateKeyCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.GeneratePrivateKeyFunc != nil {
return atomic.LoadUint64(&m.GeneratePrivateKeyCounter) > 0
}
return true
}
type mKeyProcessorMockImportPrivateKeyPEM struct {
mock *KeyProcessorMock
mainExpectation *KeyProcessorMockImportPrivateKeyPEMExpectation
expectationSeries []*KeyProcessorMockImportPrivateKeyPEMExpectation
}
type KeyProcessorMockImportPrivateKeyPEMExpectation struct {
input *KeyProcessorMockImportPrivateKeyPEMInput
result *KeyProcessorMockImportPrivateKeyPEMResult
}
type KeyProcessorMockImportPrivateKeyPEMInput struct {
p []byte
}
type KeyProcessorMockImportPrivateKeyPEMResult struct {
r crypto.PrivateKey
r1 error
}
//Expect specifies that invocation of KeyProcessor.ImportPrivateKeyPEM is expected from 1 to Infinity times
func (m *mKeyProcessorMockImportPrivateKeyPEM) Expect(p []byte) *mKeyProcessorMockImportPrivateKeyPEM {
m.mock.ImportPrivateKeyPEMFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &KeyProcessorMockImportPrivateKeyPEMExpectation{}
}
m.mainExpectation.input = &KeyProcessorMockImportPrivateKeyPEMInput{p}
return m
}
//Return specifies results of invocation of KeyProcessor.ImportPrivateKeyPEM
func (m *mKeyProcessorMockImportPrivateKeyPEM) Return(r crypto.PrivateKey, r1 error) *KeyProcessorMock {
m.mock.ImportPrivateKeyPEMFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &KeyProcessorMockImportPrivateKeyPEMExpectation{}
}
m.mainExpectation.result = &KeyProcessorMockImportPrivateKeyPEMResult{r, r1}
return m.mock
}
//ExpectOnce specifies that invocation of KeyProcessor.ImportPrivateKeyPEM is expected once
func (m *mKeyProcessorMockImportPrivateKeyPEM) ExpectOnce(p []byte) *KeyProcessorMockImportPrivateKeyPEMExpectation {
m.mock.ImportPrivateKeyPEMFunc = nil
m.mainExpectation = nil
expectation := &KeyProcessorMockImportPrivateKeyPEMExpectation{}
expectation.input = &KeyProcessorMockImportPrivateKeyPEMInput{p}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *KeyProcessorMockImportPrivateKeyPEMExpectation) Return(r crypto.PrivateKey, r1 error) {
e.result = &KeyProcessorMockImportPrivateKeyPEMResult{r, r1}
}
//Set uses given function f as a mock of KeyProcessor.ImportPrivateKeyPEM method
func (m *mKeyProcessorMockImportPrivateKeyPEM) Set(f func(p []byte) (r crypto.PrivateKey, r1 error)) *KeyProcessorMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.ImportPrivateKeyPEMFunc = f
return m.mock
}
//ImportPrivateKeyPEM implements github.com/insolar/insolar/core.KeyProcessor interface
func (m *KeyProcessorMock) ImportPrivateKeyPEM(p []byte) (r crypto.PrivateKey, r1 error) {
counter := atomic.AddUint64(&m.ImportPrivateKeyPEMPreCounter, 1)
defer atomic.AddUint64(&m.ImportPrivateKeyPEMCounter, 1)
if len(m.ImportPrivateKeyPEMMock.expectationSeries) > 0 {
if counter > uint64(len(m.ImportPrivateKeyPEMMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to KeyProcessorMock.ImportPrivateKeyPEM. %v", p)
return
}
input := m.ImportPrivateKeyPEMMock.expectationSeries[counter-1].input
testify_assert.Equal(m.t, *input, KeyProcessorMockImportPrivateKeyPEMInput{p}, "KeyProcessor.ImportPrivateKeyPEM got unexpected parameters")
result := m.ImportPrivateKeyPEMMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the KeyProcessorMock.ImportPrivateKeyPEM")
return
}
r = result.r
r1 = result.r1
return
}
if m.ImportPrivateKeyPEMMock.mainExpectation != nil {
input := m.ImportPrivateKeyPEMMock.mainExpectation.input
if input != nil {
testify_assert.Equal(m.t, *input, KeyProcessorMockImportPrivateKeyPEMInput{p}, "KeyProcessor.ImportPrivateKeyPEM got unexpected parameters")
}
result := m.ImportPrivateKeyPEMMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the KeyProcessorMock.ImportPrivateKeyPEM")
}
r = result.r
r1 = result.r1
return
}
if m.ImportPrivateKeyPEMFunc == nil {
m.t.Fatalf("Unexpected call to KeyProcessorMock.ImportPrivateKeyPEM. %v", p)
return
}
return m.ImportPrivateKeyPEMFunc(p)
}
//ImportPrivateKeyPEMMinimockCounter returns a count of KeyProcessorMock.ImportPrivateKeyPEMFunc invocations
func (m *KeyProcessorMock) ImportPrivateKeyPEMMinimockCounter() uint64 {
return atomic.LoadUint64(&m.ImportPrivateKeyPEMCounter)
}
//ImportPrivateKeyPEMMinimockPreCounter returns the value of KeyProcessorMock.ImportPrivateKeyPEM invocations
func (m *KeyProcessorMock) ImportPrivateKeyPEMMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.ImportPrivateKeyPEMPreCounter)
}
//ImportPrivateKeyPEMFinished returns true if mock invocations count is ok
func (m *KeyProcessorMock) ImportPrivateKeyPEMFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.ImportPrivateKeyPEMMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.ImportPrivateKeyPEMCounter) == uint64(len(m.ImportPrivateKeyPEMMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.ImportPrivateKeyPEMMock.mainExpectation != nil {
return atomic.LoadUint64(&m.ImportPrivateKeyPEMCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.ImportPrivateKeyPEMFunc != nil {
return atomic.LoadUint64(&m.ImportPrivateKeyPEMCounter) > 0
}
return true
}
type mKeyProcessorMockImportPublicKeyBinary struct {
mock *KeyProcessorMock
mainExpectation *KeyProcessorMockImportPublicKeyBinaryExpectation
expectationSeries []*KeyProcessorMockImportPublicKeyBinaryExpectation
}
type KeyProcessorMockImportPublicKeyBinaryExpectation struct {
input *KeyProcessorMockImportPublicKeyBinaryInput
result *KeyProcessorMockImportPublicKeyBinaryResult
}
type KeyProcessorMockImportPublicKeyBinaryInput struct {
p []byte
}
type KeyProcessorMockImportPublicKeyBinaryResult struct {
r crypto.PublicKey
r1 error
}
//Expect specifies that invocation of KeyProcessor.ImportPublicKeyBinary is expected from 1 to Infinity times
func (m *mKeyProcessorMockImportPublicKeyBinary) Expect(p []byte) *mKeyProcessorMockImportPublicKeyBinary {
m.mock.ImportPublicKeyBinaryFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &KeyProcessorMockImportPublicKeyBinaryExpectation{}
}
m.mainExpectation.input = &KeyProcessorMockImportPublicKeyBinaryInput{p}
return m
}
//Return specifies results of invocation of KeyProcessor.ImportPublicKeyBinary
func (m *mKeyProcessorMockImportPublicKeyBinary) Return(r crypto.PublicKey, r1 error) *KeyProcessorMock {