github.com/lzy4123/fabric@v2.1.1+incompatible/internal/pkg/peer/blocksprovider/fake/sleeper.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package fake 3 4 import ( 5 "sync" 6 "time" 7 ) 8 9 type Sleeper struct { 10 SleepStub func(time.Duration) 11 sleepMutex sync.RWMutex 12 sleepArgsForCall []struct { 13 arg1 time.Duration 14 } 15 invocations map[string][][]interface{} 16 invocationsMutex sync.RWMutex 17 } 18 19 func (fake *Sleeper) Sleep(arg1 time.Duration) { 20 fake.sleepMutex.Lock() 21 fake.sleepArgsForCall = append(fake.sleepArgsForCall, struct { 22 arg1 time.Duration 23 }{arg1}) 24 fake.recordInvocation("Sleep", []interface{}{arg1}) 25 fake.sleepMutex.Unlock() 26 if fake.SleepStub != nil { 27 fake.SleepStub(arg1) 28 } 29 } 30 31 func (fake *Sleeper) SleepCallCount() int { 32 fake.sleepMutex.RLock() 33 defer fake.sleepMutex.RUnlock() 34 return len(fake.sleepArgsForCall) 35 } 36 37 func (fake *Sleeper) SleepCalls(stub func(time.Duration)) { 38 fake.sleepMutex.Lock() 39 defer fake.sleepMutex.Unlock() 40 fake.SleepStub = stub 41 } 42 43 func (fake *Sleeper) SleepArgsForCall(i int) time.Duration { 44 fake.sleepMutex.RLock() 45 defer fake.sleepMutex.RUnlock() 46 argsForCall := fake.sleepArgsForCall[i] 47 return argsForCall.arg1 48 } 49 50 func (fake *Sleeper) Invocations() map[string][][]interface{} { 51 fake.invocationsMutex.RLock() 52 defer fake.invocationsMutex.RUnlock() 53 fake.sleepMutex.RLock() 54 defer fake.sleepMutex.RUnlock() 55 copiedInvocations := map[string][][]interface{}{} 56 for key, value := range fake.invocations { 57 copiedInvocations[key] = value 58 } 59 return copiedInvocations 60 } 61 62 func (fake *Sleeper) recordInvocation(key string, args []interface{}) { 63 fake.invocationsMutex.Lock() 64 defer fake.invocationsMutex.Unlock() 65 if fake.invocations == nil { 66 fake.invocations = map[string][][]interface{}{} 67 } 68 if fake.invocations[key] == nil { 69 fake.invocations[key] = [][]interface{}{} 70 } 71 fake.invocations[key] = append(fake.invocations[key], args) 72 }