github.com/lzy4123/fabric@v2.1.1+incompatible/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/hyperledger/fabric/bccsp"
     8  	"github.com/hyperledger/fabric/bccsp/idemix/handlers"
     9  )
    10  
    11  type Credential struct {
    12  	SignStub        func(handlers.IssuerSecretKey, []byte, []bccsp.IdemixAttribute) ([]byte, error)
    13  	signMutex       sync.RWMutex
    14  	signArgsForCall []struct {
    15  		arg1 handlers.IssuerSecretKey
    16  		arg2 []byte
    17  		arg3 []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(handlers.Big, handlers.IssuerPublicKey, []byte, []bccsp.IdemixAttribute) error
    28  	verifyMutex       sync.RWMutex
    29  	verifyArgsForCall []struct {
    30  		arg1 handlers.Big
    31  		arg2 handlers.IssuerPublicKey
    32  		arg3 []byte
    33  		arg4 []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(arg1 handlers.IssuerSecretKey, arg2 []byte, arg3 []bccsp.IdemixAttribute) ([]byte, error) {
    46  	var arg2Copy []byte
    47  	if arg2 != nil {
    48  		arg2Copy = make([]byte, len(arg2))
    49  		copy(arg2Copy, arg2)
    50  	}
    51  	var arg3Copy []bccsp.IdemixAttribute
    52  	if arg3 != nil {
    53  		arg3Copy = make([]bccsp.IdemixAttribute, len(arg3))
    54  		copy(arg3Copy, arg3)
    55  	}
    56  	fake.signMutex.Lock()
    57  	ret, specificReturn := fake.signReturnsOnCall[len(fake.signArgsForCall)]
    58  	fake.signArgsForCall = append(fake.signArgsForCall, struct {
    59  		arg1 handlers.IssuerSecretKey
    60  		arg2 []byte
    61  		arg3 []bccsp.IdemixAttribute
    62  	}{arg1, arg2Copy, arg3Copy})
    63  	fake.recordInvocation("Sign", []interface{}{arg1, arg2Copy, arg3Copy})
    64  	fake.signMutex.Unlock()
    65  	if fake.SignStub != nil {
    66  		return fake.SignStub(arg1, arg2, arg3)
    67  	}
    68  	if specificReturn {
    69  		return ret.result1, ret.result2
    70  	}
    71  	fakeReturns := fake.signReturns
    72  	return fakeReturns.result1, fakeReturns.result2
    73  }
    74  
    75  func (fake *Credential) SignCallCount() int {
    76  	fake.signMutex.RLock()
    77  	defer fake.signMutex.RUnlock()
    78  	return len(fake.signArgsForCall)
    79  }
    80  
    81  func (fake *Credential) SignCalls(stub func(handlers.IssuerSecretKey, []byte, []bccsp.IdemixAttribute) ([]byte, error)) {
    82  	fake.signMutex.Lock()
    83  	defer fake.signMutex.Unlock()
    84  	fake.SignStub = stub
    85  }
    86  
    87  func (fake *Credential) SignArgsForCall(i int) (handlers.IssuerSecretKey, []byte, []bccsp.IdemixAttribute) {
    88  	fake.signMutex.RLock()
    89  	defer fake.signMutex.RUnlock()
    90  	argsForCall := fake.signArgsForCall[i]
    91  	return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
    92  }
    93  
    94  func (fake *Credential) SignReturns(result1 []byte, result2 error) {
    95  	fake.signMutex.Lock()
    96  	defer fake.signMutex.Unlock()
    97  	fake.SignStub = nil
    98  	fake.signReturns = struct {
    99  		result1 []byte
   100  		result2 error
   101  	}{result1, result2}
   102  }
   103  
   104  func (fake *Credential) SignReturnsOnCall(i int, result1 []byte, result2 error) {
   105  	fake.signMutex.Lock()
   106  	defer fake.signMutex.Unlock()
   107  	fake.SignStub = nil
   108  	if fake.signReturnsOnCall == nil {
   109  		fake.signReturnsOnCall = make(map[int]struct {
   110  			result1 []byte
   111  			result2 error
   112  		})
   113  	}
   114  	fake.signReturnsOnCall[i] = struct {
   115  		result1 []byte
   116  		result2 error
   117  	}{result1, result2}
   118  }
   119  
   120  func (fake *Credential) Verify(arg1 handlers.Big, arg2 handlers.IssuerPublicKey, arg3 []byte, arg4 []bccsp.IdemixAttribute) error {
   121  	var arg3Copy []byte
   122  	if arg3 != nil {
   123  		arg3Copy = make([]byte, len(arg3))
   124  		copy(arg3Copy, arg3)
   125  	}
   126  	var arg4Copy []bccsp.IdemixAttribute
   127  	if arg4 != nil {
   128  		arg4Copy = make([]bccsp.IdemixAttribute, len(arg4))
   129  		copy(arg4Copy, arg4)
   130  	}
   131  	fake.verifyMutex.Lock()
   132  	ret, specificReturn := fake.verifyReturnsOnCall[len(fake.verifyArgsForCall)]
   133  	fake.verifyArgsForCall = append(fake.verifyArgsForCall, struct {
   134  		arg1 handlers.Big
   135  		arg2 handlers.IssuerPublicKey
   136  		arg3 []byte
   137  		arg4 []bccsp.IdemixAttribute
   138  	}{arg1, arg2, arg3Copy, arg4Copy})
   139  	fake.recordInvocation("Verify", []interface{}{arg1, arg2, arg3Copy, arg4Copy})
   140  	fake.verifyMutex.Unlock()
   141  	if fake.VerifyStub != nil {
   142  		return fake.VerifyStub(arg1, arg2, arg3, arg4)
   143  	}
   144  	if specificReturn {
   145  		return ret.result1
   146  	}
   147  	fakeReturns := fake.verifyReturns
   148  	return fakeReturns.result1
   149  }
   150  
   151  func (fake *Credential) VerifyCallCount() int {
   152  	fake.verifyMutex.RLock()
   153  	defer fake.verifyMutex.RUnlock()
   154  	return len(fake.verifyArgsForCall)
   155  }
   156  
   157  func (fake *Credential) VerifyCalls(stub func(handlers.Big, handlers.IssuerPublicKey, []byte, []bccsp.IdemixAttribute) error) {
   158  	fake.verifyMutex.Lock()
   159  	defer fake.verifyMutex.Unlock()
   160  	fake.VerifyStub = stub
   161  }
   162  
   163  func (fake *Credential) VerifyArgsForCall(i int) (handlers.Big, handlers.IssuerPublicKey, []byte, []bccsp.IdemixAttribute) {
   164  	fake.verifyMutex.RLock()
   165  	defer fake.verifyMutex.RUnlock()
   166  	argsForCall := fake.verifyArgsForCall[i]
   167  	return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4
   168  }
   169  
   170  func (fake *Credential) VerifyReturns(result1 error) {
   171  	fake.verifyMutex.Lock()
   172  	defer fake.verifyMutex.Unlock()
   173  	fake.VerifyStub = nil
   174  	fake.verifyReturns = struct {
   175  		result1 error
   176  	}{result1}
   177  }
   178  
   179  func (fake *Credential) VerifyReturnsOnCall(i int, result1 error) {
   180  	fake.verifyMutex.Lock()
   181  	defer fake.verifyMutex.Unlock()
   182  	fake.VerifyStub = nil
   183  	if fake.verifyReturnsOnCall == nil {
   184  		fake.verifyReturnsOnCall = make(map[int]struct {
   185  			result1 error
   186  		})
   187  	}
   188  	fake.verifyReturnsOnCall[i] = struct {
   189  		result1 error
   190  	}{result1}
   191  }
   192  
   193  func (fake *Credential) Invocations() map[string][][]interface{} {
   194  	fake.invocationsMutex.RLock()
   195  	defer fake.invocationsMutex.RUnlock()
   196  	fake.signMutex.RLock()
   197  	defer fake.signMutex.RUnlock()
   198  	fake.verifyMutex.RLock()
   199  	defer fake.verifyMutex.RUnlock()
   200  	copiedInvocations := map[string][][]interface{}{}
   201  	for key, value := range fake.invocations {
   202  		copiedInvocations[key] = value
   203  	}
   204  	return copiedInvocations
   205  }
   206  
   207  func (fake *Credential) recordInvocation(key string, args []interface{}) {
   208  	fake.invocationsMutex.Lock()
   209  	defer fake.invocationsMutex.Unlock()
   210  	if fake.invocations == nil {
   211  		fake.invocations = map[string][][]interface{}{}
   212  	}
   213  	if fake.invocations[key] == nil {
   214  		fake.invocations[key] = [][]interface{}{}
   215  	}
   216  	fake.invocations[key] = append(fake.invocations[key], args)
   217  }
   218  
   219  var _ handlers.Credential = new(Credential)