-
Notifications
You must be signed in to change notification settings - Fork 0
/
parcel_mock.go
1835 lines (1417 loc) · 50.3 KB
/
parcel_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 "Parcel" can be found in github.com/insolar/insolar/core
*/
import (
context "context"
"sync/atomic"
"time"
"github.com/gojuno/minimock"
core "github.com/insolar/insolar/core"
testify_assert "github.com/stretchr/testify/assert"
)
//ParcelMock implements github.com/insolar/insolar/core.Parcel
type ParcelMock struct {
t minimock.Tester
AllowedSenderObjectAndRoleFunc func() (r *core.RecordRef, r1 core.DynamicRole)
AllowedSenderObjectAndRoleCounter uint64
AllowedSenderObjectAndRolePreCounter uint64
AllowedSenderObjectAndRoleMock mParcelMockAllowedSenderObjectAndRole
ContextFunc func(p context.Context) (r context.Context)
ContextCounter uint64
ContextPreCounter uint64
ContextMock mParcelMockContext
DefaultRoleFunc func() (r core.DynamicRole)
DefaultRoleCounter uint64
DefaultRolePreCounter uint64
DefaultRoleMock mParcelMockDefaultRole
DefaultTargetFunc func() (r *core.RecordRef)
DefaultTargetCounter uint64
DefaultTargetPreCounter uint64
DefaultTargetMock mParcelMockDefaultTarget
DelegationTokenFunc func() (r core.DelegationToken)
DelegationTokenCounter uint64
DelegationTokenPreCounter uint64
DelegationTokenMock mParcelMockDelegationToken
GetCallerFunc func() (r *core.RecordRef)
GetCallerCounter uint64
GetCallerPreCounter uint64
GetCallerMock mParcelMockGetCaller
GetSenderFunc func() (r core.RecordRef)
GetSenderCounter uint64
GetSenderPreCounter uint64
GetSenderMock mParcelMockGetSender
GetSignFunc func() (r []byte)
GetSignCounter uint64
GetSignPreCounter uint64
GetSignMock mParcelMockGetSign
MessageFunc func() (r core.Message)
MessageCounter uint64
MessagePreCounter uint64
MessageMock mParcelMockMessage
PulseFunc func() (r core.PulseNumber)
PulseCounter uint64
PulsePreCounter uint64
PulseMock mParcelMockPulse
TypeFunc func() (r core.MessageType)
TypeCounter uint64
TypePreCounter uint64
TypeMock mParcelMockType
}
//NewParcelMock returns a mock for github.com/insolar/insolar/core.Parcel
func NewParcelMock(t minimock.Tester) *ParcelMock {
m := &ParcelMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.AllowedSenderObjectAndRoleMock = mParcelMockAllowedSenderObjectAndRole{mock: m}
m.ContextMock = mParcelMockContext{mock: m}
m.DefaultRoleMock = mParcelMockDefaultRole{mock: m}
m.DefaultTargetMock = mParcelMockDefaultTarget{mock: m}
m.DelegationTokenMock = mParcelMockDelegationToken{mock: m}
m.GetCallerMock = mParcelMockGetCaller{mock: m}
m.GetSenderMock = mParcelMockGetSender{mock: m}
m.GetSignMock = mParcelMockGetSign{mock: m}
m.MessageMock = mParcelMockMessage{mock: m}
m.PulseMock = mParcelMockPulse{mock: m}
m.TypeMock = mParcelMockType{mock: m}
return m
}
type mParcelMockAllowedSenderObjectAndRole struct {
mock *ParcelMock
mainExpectation *ParcelMockAllowedSenderObjectAndRoleExpectation
expectationSeries []*ParcelMockAllowedSenderObjectAndRoleExpectation
}
type ParcelMockAllowedSenderObjectAndRoleExpectation struct {
result *ParcelMockAllowedSenderObjectAndRoleResult
}
type ParcelMockAllowedSenderObjectAndRoleResult struct {
r *core.RecordRef
r1 core.DynamicRole
}
//Expect specifies that invocation of Parcel.AllowedSenderObjectAndRole is expected from 1 to Infinity times
func (m *mParcelMockAllowedSenderObjectAndRole) Expect() *mParcelMockAllowedSenderObjectAndRole {
m.mock.AllowedSenderObjectAndRoleFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockAllowedSenderObjectAndRoleExpectation{}
}
return m
}
//Return specifies results of invocation of Parcel.AllowedSenderObjectAndRole
func (m *mParcelMockAllowedSenderObjectAndRole) Return(r *core.RecordRef, r1 core.DynamicRole) *ParcelMock {
m.mock.AllowedSenderObjectAndRoleFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockAllowedSenderObjectAndRoleExpectation{}
}
m.mainExpectation.result = &ParcelMockAllowedSenderObjectAndRoleResult{r, r1}
return m.mock
}
//ExpectOnce specifies that invocation of Parcel.AllowedSenderObjectAndRole is expected once
func (m *mParcelMockAllowedSenderObjectAndRole) ExpectOnce() *ParcelMockAllowedSenderObjectAndRoleExpectation {
m.mock.AllowedSenderObjectAndRoleFunc = nil
m.mainExpectation = nil
expectation := &ParcelMockAllowedSenderObjectAndRoleExpectation{}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ParcelMockAllowedSenderObjectAndRoleExpectation) Return(r *core.RecordRef, r1 core.DynamicRole) {
e.result = &ParcelMockAllowedSenderObjectAndRoleResult{r, r1}
}
//Set uses given function f as a mock of Parcel.AllowedSenderObjectAndRole method
func (m *mParcelMockAllowedSenderObjectAndRole) Set(f func() (r *core.RecordRef, r1 core.DynamicRole)) *ParcelMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.AllowedSenderObjectAndRoleFunc = f
return m.mock
}
//AllowedSenderObjectAndRole implements github.com/insolar/insolar/core.Parcel interface
func (m *ParcelMock) AllowedSenderObjectAndRole() (r *core.RecordRef, r1 core.DynamicRole) {
counter := atomic.AddUint64(&m.AllowedSenderObjectAndRolePreCounter, 1)
defer atomic.AddUint64(&m.AllowedSenderObjectAndRoleCounter, 1)
if len(m.AllowedSenderObjectAndRoleMock.expectationSeries) > 0 {
if counter > uint64(len(m.AllowedSenderObjectAndRoleMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ParcelMock.AllowedSenderObjectAndRole.")
return
}
result := m.AllowedSenderObjectAndRoleMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ParcelMock.AllowedSenderObjectAndRole")
return
}
r = result.r
r1 = result.r1
return
}
if m.AllowedSenderObjectAndRoleMock.mainExpectation != nil {
result := m.AllowedSenderObjectAndRoleMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the ParcelMock.AllowedSenderObjectAndRole")
}
r = result.r
r1 = result.r1
return
}
if m.AllowedSenderObjectAndRoleFunc == nil {
m.t.Fatalf("Unexpected call to ParcelMock.AllowedSenderObjectAndRole.")
return
}
return m.AllowedSenderObjectAndRoleFunc()
}
//AllowedSenderObjectAndRoleMinimockCounter returns a count of ParcelMock.AllowedSenderObjectAndRoleFunc invocations
func (m *ParcelMock) AllowedSenderObjectAndRoleMinimockCounter() uint64 {
return atomic.LoadUint64(&m.AllowedSenderObjectAndRoleCounter)
}
//AllowedSenderObjectAndRoleMinimockPreCounter returns the value of ParcelMock.AllowedSenderObjectAndRole invocations
func (m *ParcelMock) AllowedSenderObjectAndRoleMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.AllowedSenderObjectAndRolePreCounter)
}
//AllowedSenderObjectAndRoleFinished returns true if mock invocations count is ok
func (m *ParcelMock) AllowedSenderObjectAndRoleFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.AllowedSenderObjectAndRoleMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.AllowedSenderObjectAndRoleCounter) == uint64(len(m.AllowedSenderObjectAndRoleMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.AllowedSenderObjectAndRoleMock.mainExpectation != nil {
return atomic.LoadUint64(&m.AllowedSenderObjectAndRoleCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.AllowedSenderObjectAndRoleFunc != nil {
return atomic.LoadUint64(&m.AllowedSenderObjectAndRoleCounter) > 0
}
return true
}
type mParcelMockContext struct {
mock *ParcelMock
mainExpectation *ParcelMockContextExpectation
expectationSeries []*ParcelMockContextExpectation
}
type ParcelMockContextExpectation struct {
input *ParcelMockContextInput
result *ParcelMockContextResult
}
type ParcelMockContextInput struct {
p context.Context
}
type ParcelMockContextResult struct {
r context.Context
}
//Expect specifies that invocation of Parcel.Context is expected from 1 to Infinity times
func (m *mParcelMockContext) Expect(p context.Context) *mParcelMockContext {
m.mock.ContextFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockContextExpectation{}
}
m.mainExpectation.input = &ParcelMockContextInput{p}
return m
}
//Return specifies results of invocation of Parcel.Context
func (m *mParcelMockContext) Return(r context.Context) *ParcelMock {
m.mock.ContextFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockContextExpectation{}
}
m.mainExpectation.result = &ParcelMockContextResult{r}
return m.mock
}
//ExpectOnce specifies that invocation of Parcel.Context is expected once
func (m *mParcelMockContext) ExpectOnce(p context.Context) *ParcelMockContextExpectation {
m.mock.ContextFunc = nil
m.mainExpectation = nil
expectation := &ParcelMockContextExpectation{}
expectation.input = &ParcelMockContextInput{p}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ParcelMockContextExpectation) Return(r context.Context) {
e.result = &ParcelMockContextResult{r}
}
//Set uses given function f as a mock of Parcel.Context method
func (m *mParcelMockContext) Set(f func(p context.Context) (r context.Context)) *ParcelMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.ContextFunc = f
return m.mock
}
//Context implements github.com/insolar/insolar/core.Parcel interface
func (m *ParcelMock) Context(p context.Context) (r context.Context) {
counter := atomic.AddUint64(&m.ContextPreCounter, 1)
defer atomic.AddUint64(&m.ContextCounter, 1)
if len(m.ContextMock.expectationSeries) > 0 {
if counter > uint64(len(m.ContextMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ParcelMock.Context. %v", p)
return
}
input := m.ContextMock.expectationSeries[counter-1].input
testify_assert.Equal(m.t, *input, ParcelMockContextInput{p}, "Parcel.Context got unexpected parameters")
result := m.ContextMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ParcelMock.Context")
return
}
r = result.r
return
}
if m.ContextMock.mainExpectation != nil {
input := m.ContextMock.mainExpectation.input
if input != nil {
testify_assert.Equal(m.t, *input, ParcelMockContextInput{p}, "Parcel.Context got unexpected parameters")
}
result := m.ContextMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the ParcelMock.Context")
}
r = result.r
return
}
if m.ContextFunc == nil {
m.t.Fatalf("Unexpected call to ParcelMock.Context. %v", p)
return
}
return m.ContextFunc(p)
}
//ContextMinimockCounter returns a count of ParcelMock.ContextFunc invocations
func (m *ParcelMock) ContextMinimockCounter() uint64 {
return atomic.LoadUint64(&m.ContextCounter)
}
//ContextMinimockPreCounter returns the value of ParcelMock.Context invocations
func (m *ParcelMock) ContextMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.ContextPreCounter)
}
//ContextFinished returns true if mock invocations count is ok
func (m *ParcelMock) ContextFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.ContextMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.ContextCounter) == uint64(len(m.ContextMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.ContextMock.mainExpectation != nil {
return atomic.LoadUint64(&m.ContextCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.ContextFunc != nil {
return atomic.LoadUint64(&m.ContextCounter) > 0
}
return true
}
type mParcelMockDefaultRole struct {
mock *ParcelMock
mainExpectation *ParcelMockDefaultRoleExpectation
expectationSeries []*ParcelMockDefaultRoleExpectation
}
type ParcelMockDefaultRoleExpectation struct {
result *ParcelMockDefaultRoleResult
}
type ParcelMockDefaultRoleResult struct {
r core.DynamicRole
}
//Expect specifies that invocation of Parcel.DefaultRole is expected from 1 to Infinity times
func (m *mParcelMockDefaultRole) Expect() *mParcelMockDefaultRole {
m.mock.DefaultRoleFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockDefaultRoleExpectation{}
}
return m
}
//Return specifies results of invocation of Parcel.DefaultRole
func (m *mParcelMockDefaultRole) Return(r core.DynamicRole) *ParcelMock {
m.mock.DefaultRoleFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockDefaultRoleExpectation{}
}
m.mainExpectation.result = &ParcelMockDefaultRoleResult{r}
return m.mock
}
//ExpectOnce specifies that invocation of Parcel.DefaultRole is expected once
func (m *mParcelMockDefaultRole) ExpectOnce() *ParcelMockDefaultRoleExpectation {
m.mock.DefaultRoleFunc = nil
m.mainExpectation = nil
expectation := &ParcelMockDefaultRoleExpectation{}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ParcelMockDefaultRoleExpectation) Return(r core.DynamicRole) {
e.result = &ParcelMockDefaultRoleResult{r}
}
//Set uses given function f as a mock of Parcel.DefaultRole method
func (m *mParcelMockDefaultRole) Set(f func() (r core.DynamicRole)) *ParcelMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.DefaultRoleFunc = f
return m.mock
}
//DefaultRole implements github.com/insolar/insolar/core.Parcel interface
func (m *ParcelMock) DefaultRole() (r core.DynamicRole) {
counter := atomic.AddUint64(&m.DefaultRolePreCounter, 1)
defer atomic.AddUint64(&m.DefaultRoleCounter, 1)
if len(m.DefaultRoleMock.expectationSeries) > 0 {
if counter > uint64(len(m.DefaultRoleMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ParcelMock.DefaultRole.")
return
}
result := m.DefaultRoleMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ParcelMock.DefaultRole")
return
}
r = result.r
return
}
if m.DefaultRoleMock.mainExpectation != nil {
result := m.DefaultRoleMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the ParcelMock.DefaultRole")
}
r = result.r
return
}
if m.DefaultRoleFunc == nil {
m.t.Fatalf("Unexpected call to ParcelMock.DefaultRole.")
return
}
return m.DefaultRoleFunc()
}
//DefaultRoleMinimockCounter returns a count of ParcelMock.DefaultRoleFunc invocations
func (m *ParcelMock) DefaultRoleMinimockCounter() uint64 {
return atomic.LoadUint64(&m.DefaultRoleCounter)
}
//DefaultRoleMinimockPreCounter returns the value of ParcelMock.DefaultRole invocations
func (m *ParcelMock) DefaultRoleMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.DefaultRolePreCounter)
}
//DefaultRoleFinished returns true if mock invocations count is ok
func (m *ParcelMock) DefaultRoleFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.DefaultRoleMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.DefaultRoleCounter) == uint64(len(m.DefaultRoleMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.DefaultRoleMock.mainExpectation != nil {
return atomic.LoadUint64(&m.DefaultRoleCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.DefaultRoleFunc != nil {
return atomic.LoadUint64(&m.DefaultRoleCounter) > 0
}
return true
}
type mParcelMockDefaultTarget struct {
mock *ParcelMock
mainExpectation *ParcelMockDefaultTargetExpectation
expectationSeries []*ParcelMockDefaultTargetExpectation
}
type ParcelMockDefaultTargetExpectation struct {
result *ParcelMockDefaultTargetResult
}
type ParcelMockDefaultTargetResult struct {
r *core.RecordRef
}
//Expect specifies that invocation of Parcel.DefaultTarget is expected from 1 to Infinity times
func (m *mParcelMockDefaultTarget) Expect() *mParcelMockDefaultTarget {
m.mock.DefaultTargetFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockDefaultTargetExpectation{}
}
return m
}
//Return specifies results of invocation of Parcel.DefaultTarget
func (m *mParcelMockDefaultTarget) Return(r *core.RecordRef) *ParcelMock {
m.mock.DefaultTargetFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockDefaultTargetExpectation{}
}
m.mainExpectation.result = &ParcelMockDefaultTargetResult{r}
return m.mock
}
//ExpectOnce specifies that invocation of Parcel.DefaultTarget is expected once
func (m *mParcelMockDefaultTarget) ExpectOnce() *ParcelMockDefaultTargetExpectation {
m.mock.DefaultTargetFunc = nil
m.mainExpectation = nil
expectation := &ParcelMockDefaultTargetExpectation{}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ParcelMockDefaultTargetExpectation) Return(r *core.RecordRef) {
e.result = &ParcelMockDefaultTargetResult{r}
}
//Set uses given function f as a mock of Parcel.DefaultTarget method
func (m *mParcelMockDefaultTarget) Set(f func() (r *core.RecordRef)) *ParcelMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.DefaultTargetFunc = f
return m.mock
}
//DefaultTarget implements github.com/insolar/insolar/core.Parcel interface
func (m *ParcelMock) DefaultTarget() (r *core.RecordRef) {
counter := atomic.AddUint64(&m.DefaultTargetPreCounter, 1)
defer atomic.AddUint64(&m.DefaultTargetCounter, 1)
if len(m.DefaultTargetMock.expectationSeries) > 0 {
if counter > uint64(len(m.DefaultTargetMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ParcelMock.DefaultTarget.")
return
}
result := m.DefaultTargetMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ParcelMock.DefaultTarget")
return
}
r = result.r
return
}
if m.DefaultTargetMock.mainExpectation != nil {
result := m.DefaultTargetMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the ParcelMock.DefaultTarget")
}
r = result.r
return
}
if m.DefaultTargetFunc == nil {
m.t.Fatalf("Unexpected call to ParcelMock.DefaultTarget.")
return
}
return m.DefaultTargetFunc()
}
//DefaultTargetMinimockCounter returns a count of ParcelMock.DefaultTargetFunc invocations
func (m *ParcelMock) DefaultTargetMinimockCounter() uint64 {
return atomic.LoadUint64(&m.DefaultTargetCounter)
}
//DefaultTargetMinimockPreCounter returns the value of ParcelMock.DefaultTarget invocations
func (m *ParcelMock) DefaultTargetMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.DefaultTargetPreCounter)
}
//DefaultTargetFinished returns true if mock invocations count is ok
func (m *ParcelMock) DefaultTargetFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.DefaultTargetMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.DefaultTargetCounter) == uint64(len(m.DefaultTargetMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.DefaultTargetMock.mainExpectation != nil {
return atomic.LoadUint64(&m.DefaultTargetCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.DefaultTargetFunc != nil {
return atomic.LoadUint64(&m.DefaultTargetCounter) > 0
}
return true
}
type mParcelMockDelegationToken struct {
mock *ParcelMock
mainExpectation *ParcelMockDelegationTokenExpectation
expectationSeries []*ParcelMockDelegationTokenExpectation
}
type ParcelMockDelegationTokenExpectation struct {
result *ParcelMockDelegationTokenResult
}
type ParcelMockDelegationTokenResult struct {
r core.DelegationToken
}
//Expect specifies that invocation of Parcel.DelegationToken is expected from 1 to Infinity times
func (m *mParcelMockDelegationToken) Expect() *mParcelMockDelegationToken {
m.mock.DelegationTokenFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockDelegationTokenExpectation{}
}
return m
}
//Return specifies results of invocation of Parcel.DelegationToken
func (m *mParcelMockDelegationToken) Return(r core.DelegationToken) *ParcelMock {
m.mock.DelegationTokenFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockDelegationTokenExpectation{}
}
m.mainExpectation.result = &ParcelMockDelegationTokenResult{r}
return m.mock
}
//ExpectOnce specifies that invocation of Parcel.DelegationToken is expected once
func (m *mParcelMockDelegationToken) ExpectOnce() *ParcelMockDelegationTokenExpectation {
m.mock.DelegationTokenFunc = nil
m.mainExpectation = nil
expectation := &ParcelMockDelegationTokenExpectation{}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ParcelMockDelegationTokenExpectation) Return(r core.DelegationToken) {
e.result = &ParcelMockDelegationTokenResult{r}
}
//Set uses given function f as a mock of Parcel.DelegationToken method
func (m *mParcelMockDelegationToken) Set(f func() (r core.DelegationToken)) *ParcelMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.DelegationTokenFunc = f
return m.mock
}
//DelegationToken implements github.com/insolar/insolar/core.Parcel interface
func (m *ParcelMock) DelegationToken() (r core.DelegationToken) {
counter := atomic.AddUint64(&m.DelegationTokenPreCounter, 1)
defer atomic.AddUint64(&m.DelegationTokenCounter, 1)
if len(m.DelegationTokenMock.expectationSeries) > 0 {
if counter > uint64(len(m.DelegationTokenMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ParcelMock.DelegationToken.")
return
}
result := m.DelegationTokenMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ParcelMock.DelegationToken")
return
}
r = result.r
return
}
if m.DelegationTokenMock.mainExpectation != nil {
result := m.DelegationTokenMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the ParcelMock.DelegationToken")
}
r = result.r
return
}
if m.DelegationTokenFunc == nil {
m.t.Fatalf("Unexpected call to ParcelMock.DelegationToken.")
return
}
return m.DelegationTokenFunc()
}
//DelegationTokenMinimockCounter returns a count of ParcelMock.DelegationTokenFunc invocations
func (m *ParcelMock) DelegationTokenMinimockCounter() uint64 {
return atomic.LoadUint64(&m.DelegationTokenCounter)
}
//DelegationTokenMinimockPreCounter returns the value of ParcelMock.DelegationToken invocations
func (m *ParcelMock) DelegationTokenMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.DelegationTokenPreCounter)
}
//DelegationTokenFinished returns true if mock invocations count is ok
func (m *ParcelMock) DelegationTokenFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.DelegationTokenMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.DelegationTokenCounter) == uint64(len(m.DelegationTokenMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.DelegationTokenMock.mainExpectation != nil {
return atomic.LoadUint64(&m.DelegationTokenCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.DelegationTokenFunc != nil {
return atomic.LoadUint64(&m.DelegationTokenCounter) > 0
}
return true
}
type mParcelMockGetCaller struct {
mock *ParcelMock
mainExpectation *ParcelMockGetCallerExpectation
expectationSeries []*ParcelMockGetCallerExpectation
}
type ParcelMockGetCallerExpectation struct {
result *ParcelMockGetCallerResult
}
type ParcelMockGetCallerResult struct {
r *core.RecordRef
}
//Expect specifies that invocation of Parcel.GetCaller is expected from 1 to Infinity times
func (m *mParcelMockGetCaller) Expect() *mParcelMockGetCaller {
m.mock.GetCallerFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockGetCallerExpectation{}
}
return m
}
//Return specifies results of invocation of Parcel.GetCaller
func (m *mParcelMockGetCaller) Return(r *core.RecordRef) *ParcelMock {
m.mock.GetCallerFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockGetCallerExpectation{}
}
m.mainExpectation.result = &ParcelMockGetCallerResult{r}
return m.mock
}
//ExpectOnce specifies that invocation of Parcel.GetCaller is expected once
func (m *mParcelMockGetCaller) ExpectOnce() *ParcelMockGetCallerExpectation {
m.mock.GetCallerFunc = nil
m.mainExpectation = nil
expectation := &ParcelMockGetCallerExpectation{}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ParcelMockGetCallerExpectation) Return(r *core.RecordRef) {
e.result = &ParcelMockGetCallerResult{r}
}
//Set uses given function f as a mock of Parcel.GetCaller method
func (m *mParcelMockGetCaller) Set(f func() (r *core.RecordRef)) *ParcelMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.GetCallerFunc = f
return m.mock
}
//GetCaller implements github.com/insolar/insolar/core.Parcel interface
func (m *ParcelMock) GetCaller() (r *core.RecordRef) {
counter := atomic.AddUint64(&m.GetCallerPreCounter, 1)
defer atomic.AddUint64(&m.GetCallerCounter, 1)
if len(m.GetCallerMock.expectationSeries) > 0 {
if counter > uint64(len(m.GetCallerMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ParcelMock.GetCaller.")
return
}
result := m.GetCallerMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ParcelMock.GetCaller")
return
}
r = result.r
return
}
if m.GetCallerMock.mainExpectation != nil {
result := m.GetCallerMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the ParcelMock.GetCaller")
}
r = result.r
return
}
if m.GetCallerFunc == nil {
m.t.Fatalf("Unexpected call to ParcelMock.GetCaller.")
return
}
return m.GetCallerFunc()
}
//GetCallerMinimockCounter returns a count of ParcelMock.GetCallerFunc invocations
func (m *ParcelMock) GetCallerMinimockCounter() uint64 {
return atomic.LoadUint64(&m.GetCallerCounter)
}
//GetCallerMinimockPreCounter returns the value of ParcelMock.GetCaller invocations
func (m *ParcelMock) GetCallerMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.GetCallerPreCounter)
}
//GetCallerFinished returns true if mock invocations count is ok
func (m *ParcelMock) GetCallerFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.GetCallerMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.GetCallerCounter) == uint64(len(m.GetCallerMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.GetCallerMock.mainExpectation != nil {
return atomic.LoadUint64(&m.GetCallerCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.GetCallerFunc != nil {
return atomic.LoadUint64(&m.GetCallerCounter) > 0
}
return true
}
type mParcelMockGetSender struct {
mock *ParcelMock
mainExpectation *ParcelMockGetSenderExpectation
expectationSeries []*ParcelMockGetSenderExpectation
}
type ParcelMockGetSenderExpectation struct {
result *ParcelMockGetSenderResult
}
type ParcelMockGetSenderResult struct {
r core.RecordRef
}
//Expect specifies that invocation of Parcel.GetSender is expected from 1 to Infinity times
func (m *mParcelMockGetSender) Expect() *mParcelMockGetSender {
m.mock.GetSenderFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockGetSenderExpectation{}
}
return m
}
//Return specifies results of invocation of Parcel.GetSender
func (m *mParcelMockGetSender) Return(r core.RecordRef) *ParcelMock {
m.mock.GetSenderFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ParcelMockGetSenderExpectation{}
}
m.mainExpectation.result = &ParcelMockGetSenderResult{r}
return m.mock
}
//ExpectOnce specifies that invocation of Parcel.GetSender is expected once
func (m *mParcelMockGetSender) ExpectOnce() *ParcelMockGetSenderExpectation {
m.mock.GetSenderFunc = nil
m.mainExpectation = nil
expectation := &ParcelMockGetSenderExpectation{}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ParcelMockGetSenderExpectation) Return(r core.RecordRef) {
e.result = &ParcelMockGetSenderResult{r}
}
//Set uses given function f as a mock of Parcel.GetSender method
func (m *mParcelMockGetSender) Set(f func() (r core.RecordRef)) *ParcelMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.GetSenderFunc = f
return m.mock
}
//GetSender implements github.com/insolar/insolar/core.Parcel interface
func (m *ParcelMock) GetSender() (r core.RecordRef) {
counter := atomic.AddUint64(&m.GetSenderPreCounter, 1)
defer atomic.AddUint64(&m.GetSenderCounter, 1)
if len(m.GetSenderMock.expectationSeries) > 0 {
if counter > uint64(len(m.GetSenderMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ParcelMock.GetSender.")
return
}
result := m.GetSenderMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ParcelMock.GetSender")
return
}