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