github.com/hellobchain/third_party@v0.0.0-20230331131523-deb0478a2e52/hyperledger/fabric/bccsp/idemix/handlers/mock/credential.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package mock 3 4 import ( 5 "sync" 6 7 "github.com/hellobchain/third_party/hyperledger/fabric/bccsp" 8 "github.com/hellobchain/third_party/hyperledger/fabric/bccsp/idemix/handlers" 9 ) 10 11 type Credential struct { 12 SignStub func(key handlers.IssuerSecretKey, credentialRequest []byte, attributes []bccsp.IdemixAttribute) ([]byte, error) 13 signMutex sync.RWMutex 14 signArgsForCall []struct { 15 key handlers.IssuerSecretKey 16 credentialRequest []byte 17 attributes []bccsp.IdemixAttribute 18 } 19 signReturns struct { 20 result1 []byte 21 result2 error 22 } 23 signReturnsOnCall map[int]struct { 24 result1 []byte 25 result2 error 26 } 27 VerifyStub func(sk handlers.Big, ipk handlers.IssuerPublicKey, credential []byte, attributes []bccsp.IdemixAttribute) error 28 verifyMutex sync.RWMutex 29 verifyArgsForCall []struct { 30 sk handlers.Big 31 ipk handlers.IssuerPublicKey 32 credential []byte 33 attributes []bccsp.IdemixAttribute 34 } 35 verifyReturns struct { 36 result1 error 37 } 38 verifyReturnsOnCall map[int]struct { 39 result1 error 40 } 41 invocations map[string][][]interface{} 42 invocationsMutex sync.RWMutex 43 } 44 45 func (fake *Credential) Sign(key handlers.IssuerSecretKey, credentialRequest []byte, attributes []bccsp.IdemixAttribute) ([]byte, error) { 46 var credentialRequestCopy []byte 47 if credentialRequest != nil { 48 credentialRequestCopy = make([]byte, len(credentialRequest)) 49 copy(credentialRequestCopy, credentialRequest) 50 } 51 var attributesCopy []bccsp.IdemixAttribute 52 if attributes != nil { 53 attributesCopy = make([]bccsp.IdemixAttribute, len(attributes)) 54 copy(attributesCopy, attributes) 55 } 56 fake.signMutex.Lock() 57 ret, specificReturn := fake.signReturnsOnCall[len(fake.signArgsForCall)] 58 fake.signArgsForCall = append(fake.signArgsForCall, struct { 59 key handlers.IssuerSecretKey 60 credentialRequest []byte 61 attributes []bccsp.IdemixAttribute 62 }{key, credentialRequestCopy, attributesCopy}) 63 fake.recordInvocation("Sign", []interface{}{key, credentialRequestCopy, attributesCopy}) 64 fake.signMutex.Unlock() 65 if fake.SignStub != nil { 66 return fake.SignStub(key, credentialRequest, attributes) 67 } 68 if specificReturn { 69 return ret.result1, ret.result2 70 } 71 return fake.signReturns.result1, fake.signReturns.result2 72 } 73 74 func (fake *Credential) SignCallCount() int { 75 fake.signMutex.RLock() 76 defer fake.signMutex.RUnlock() 77 return len(fake.signArgsForCall) 78 } 79 80 func (fake *Credential) SignArgsForCall(i int) (handlers.IssuerSecretKey, []byte, []bccsp.IdemixAttribute) { 81 fake.signMutex.RLock() 82 defer fake.signMutex.RUnlock() 83 return fake.signArgsForCall[i].key, fake.signArgsForCall[i].credentialRequest, fake.signArgsForCall[i].attributes 84 } 85 86 func (fake *Credential) SignReturns(result1 []byte, result2 error) { 87 fake.SignStub = nil 88 fake.signReturns = struct { 89 result1 []byte 90 result2 error 91 }{result1, result2} 92 } 93 94 func (fake *Credential) SignReturnsOnCall(i int, result1 []byte, result2 error) { 95 fake.SignStub = nil 96 if fake.signReturnsOnCall == nil { 97 fake.signReturnsOnCall = make(map[int]struct { 98 result1 []byte 99 result2 error 100 }) 101 } 102 fake.signReturnsOnCall[i] = struct { 103 result1 []byte 104 result2 error 105 }{result1, result2} 106 } 107 108 func (fake *Credential) Verify(sk handlers.Big, ipk handlers.IssuerPublicKey, credential []byte, attributes []bccsp.IdemixAttribute) error { 109 var credentialCopy []byte 110 if credential != nil { 111 credentialCopy = make([]byte, len(credential)) 112 copy(credentialCopy, credential) 113 } 114 var attributesCopy []bccsp.IdemixAttribute 115 if attributes != nil { 116 attributesCopy = make([]bccsp.IdemixAttribute, len(attributes)) 117 copy(attributesCopy, attributes) 118 } 119 fake.verifyMutex.Lock() 120 ret, specificReturn := fake.verifyReturnsOnCall[len(fake.verifyArgsForCall)] 121 fake.verifyArgsForCall = append(fake.verifyArgsForCall, struct { 122 sk handlers.Big 123 ipk handlers.IssuerPublicKey 124 credential []byte 125 attributes []bccsp.IdemixAttribute 126 }{sk, ipk, credentialCopy, attributesCopy}) 127 fake.recordInvocation("Verify", []interface{}{sk, ipk, credentialCopy, attributesCopy}) 128 fake.verifyMutex.Unlock() 129 if fake.VerifyStub != nil { 130 return fake.VerifyStub(sk, ipk, credential, attributes) 131 } 132 if specificReturn { 133 return ret.result1 134 } 135 return fake.verifyReturns.result1 136 } 137 138 func (fake *Credential) VerifyCallCount() int { 139 fake.verifyMutex.RLock() 140 defer fake.verifyMutex.RUnlock() 141 return len(fake.verifyArgsForCall) 142 } 143 144 func (fake *Credential) VerifyArgsForCall(i int) (handlers.Big, handlers.IssuerPublicKey, []byte, []bccsp.IdemixAttribute) { 145 fake.verifyMutex.RLock() 146 defer fake.verifyMutex.RUnlock() 147 return fake.verifyArgsForCall[i].sk, fake.verifyArgsForCall[i].ipk, fake.verifyArgsForCall[i].credential, fake.verifyArgsForCall[i].attributes 148 } 149 150 func (fake *Credential) VerifyReturns(result1 error) { 151 fake.VerifyStub = nil 152 fake.verifyReturns = struct { 153 result1 error 154 }{result1} 155 } 156 157 func (fake *Credential) VerifyReturnsOnCall(i int, result1 error) { 158 fake.VerifyStub = nil 159 if fake.verifyReturnsOnCall == nil { 160 fake.verifyReturnsOnCall = make(map[int]struct { 161 result1 error 162 }) 163 } 164 fake.verifyReturnsOnCall[i] = struct { 165 result1 error 166 }{result1} 167 } 168 169 func (fake *Credential) Invocations() map[string][][]interface{} { 170 fake.invocationsMutex.RLock() 171 defer fake.invocationsMutex.RUnlock() 172 fake.signMutex.RLock() 173 defer fake.signMutex.RUnlock() 174 fake.verifyMutex.RLock() 175 defer fake.verifyMutex.RUnlock() 176 copiedInvocations := map[string][][]interface{}{} 177 for key, value := range fake.invocations { 178 copiedInvocations[key] = value 179 } 180 return copiedInvocations 181 } 182 183 func (fake *Credential) recordInvocation(key string, args []interface{}) { 184 fake.invocationsMutex.Lock() 185 defer fake.invocationsMutex.Unlock() 186 if fake.invocations == nil { 187 fake.invocations = map[string][][]interface{}{} 188 } 189 if fake.invocations[key] == nil { 190 fake.invocations[key] = [][]interface{}{} 191 } 192 fake.invocations[key] = append(fake.invocations[key], args) 193 } 194 195 var _ handlers.Credential = new(Credential)