github.com/lzy4123/fabric@v2.1.1+incompatible/core/chaincode/mock/invoker.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package mock 3 4 import ( 5 "sync" 6 7 "github.com/hyperledger/fabric-protos-go/peer" 8 "github.com/hyperledger/fabric/core/common/ccprovider" 9 ) 10 11 type Invoker struct { 12 InvokeStub func(*ccprovider.TransactionParams, string, *peer.ChaincodeInput) (*peer.ChaincodeMessage, error) 13 invokeMutex sync.RWMutex 14 invokeArgsForCall []struct { 15 arg1 *ccprovider.TransactionParams 16 arg2 string 17 arg3 *peer.ChaincodeInput 18 } 19 invokeReturns struct { 20 result1 *peer.ChaincodeMessage 21 result2 error 22 } 23 invokeReturnsOnCall map[int]struct { 24 result1 *peer.ChaincodeMessage 25 result2 error 26 } 27 invocations map[string][][]interface{} 28 invocationsMutex sync.RWMutex 29 } 30 31 func (fake *Invoker) Invoke(arg1 *ccprovider.TransactionParams, arg2 string, arg3 *peer.ChaincodeInput) (*peer.ChaincodeMessage, error) { 32 fake.invokeMutex.Lock() 33 ret, specificReturn := fake.invokeReturnsOnCall[len(fake.invokeArgsForCall)] 34 fake.invokeArgsForCall = append(fake.invokeArgsForCall, struct { 35 arg1 *ccprovider.TransactionParams 36 arg2 string 37 arg3 *peer.ChaincodeInput 38 }{arg1, arg2, arg3}) 39 fake.recordInvocation("Invoke", []interface{}{arg1, arg2, arg3}) 40 fake.invokeMutex.Unlock() 41 if fake.InvokeStub != nil { 42 return fake.InvokeStub(arg1, arg2, arg3) 43 } 44 if specificReturn { 45 return ret.result1, ret.result2 46 } 47 fakeReturns := fake.invokeReturns 48 return fakeReturns.result1, fakeReturns.result2 49 } 50 51 func (fake *Invoker) InvokeCallCount() int { 52 fake.invokeMutex.RLock() 53 defer fake.invokeMutex.RUnlock() 54 return len(fake.invokeArgsForCall) 55 } 56 57 func (fake *Invoker) InvokeCalls(stub func(*ccprovider.TransactionParams, string, *peer.ChaincodeInput) (*peer.ChaincodeMessage, error)) { 58 fake.invokeMutex.Lock() 59 defer fake.invokeMutex.Unlock() 60 fake.InvokeStub = stub 61 } 62 63 func (fake *Invoker) InvokeArgsForCall(i int) (*ccprovider.TransactionParams, string, *peer.ChaincodeInput) { 64 fake.invokeMutex.RLock() 65 defer fake.invokeMutex.RUnlock() 66 argsForCall := fake.invokeArgsForCall[i] 67 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 68 } 69 70 func (fake *Invoker) InvokeReturns(result1 *peer.ChaincodeMessage, result2 error) { 71 fake.invokeMutex.Lock() 72 defer fake.invokeMutex.Unlock() 73 fake.InvokeStub = nil 74 fake.invokeReturns = struct { 75 result1 *peer.ChaincodeMessage 76 result2 error 77 }{result1, result2} 78 } 79 80 func (fake *Invoker) InvokeReturnsOnCall(i int, result1 *peer.ChaincodeMessage, result2 error) { 81 fake.invokeMutex.Lock() 82 defer fake.invokeMutex.Unlock() 83 fake.InvokeStub = nil 84 if fake.invokeReturnsOnCall == nil { 85 fake.invokeReturnsOnCall = make(map[int]struct { 86 result1 *peer.ChaincodeMessage 87 result2 error 88 }) 89 } 90 fake.invokeReturnsOnCall[i] = struct { 91 result1 *peer.ChaincodeMessage 92 result2 error 93 }{result1, result2} 94 } 95 96 func (fake *Invoker) Invocations() map[string][][]interface{} { 97 fake.invocationsMutex.RLock() 98 defer fake.invocationsMutex.RUnlock() 99 fake.invokeMutex.RLock() 100 defer fake.invokeMutex.RUnlock() 101 copiedInvocations := map[string][][]interface{}{} 102 for key, value := range fake.invocations { 103 copiedInvocations[key] = value 104 } 105 return copiedInvocations 106 } 107 108 func (fake *Invoker) recordInvocation(key string, args []interface{}) { 109 fake.invocationsMutex.Lock() 110 defer fake.invocationsMutex.Unlock() 111 if fake.invocations == nil { 112 fake.invocations = map[string][][]interface{}{} 113 } 114 if fake.invocations[key] == nil { 115 fake.invocations[key] = [][]interface{}{} 116 } 117 fake.invocations[key] = append(fake.invocations[key], args) 118 }