github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/orderer/consensus/etcdraft/mocks/mock_rpc.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package mocks
     3  
     4  import (
     5  	"sync"
     6  
     7  	"github.com/hyperledger/fabric-protos-go/orderer"
     8  	"github.com/hechain20/hechain/orderer/consensus/etcdraft"
     9  )
    10  
    11  type FakeRPC struct {
    12  	SendConsensusStub        func(uint64, *orderer.ConsensusRequest) error
    13  	sendConsensusMutex       sync.RWMutex
    14  	sendConsensusArgsForCall []struct {
    15  		arg1 uint64
    16  		arg2 *orderer.ConsensusRequest
    17  	}
    18  	sendConsensusReturns struct {
    19  		result1 error
    20  	}
    21  	sendConsensusReturnsOnCall map[int]struct {
    22  		result1 error
    23  	}
    24  	SendSubmitStub        func(uint64, *orderer.SubmitRequest, func(err error)) error
    25  	sendSubmitMutex       sync.RWMutex
    26  	sendSubmitArgsForCall []struct {
    27  		arg1 uint64
    28  		arg2 *orderer.SubmitRequest
    29  		arg3 func(err error)
    30  	}
    31  	sendSubmitReturns struct {
    32  		result1 error
    33  	}
    34  	sendSubmitReturnsOnCall map[int]struct {
    35  		result1 error
    36  	}
    37  	invocations      map[string][][]interface{}
    38  	invocationsMutex sync.RWMutex
    39  }
    40  
    41  func (fake *FakeRPC) SendConsensus(arg1 uint64, arg2 *orderer.ConsensusRequest) error {
    42  	fake.sendConsensusMutex.Lock()
    43  	ret, specificReturn := fake.sendConsensusReturnsOnCall[len(fake.sendConsensusArgsForCall)]
    44  	fake.sendConsensusArgsForCall = append(fake.sendConsensusArgsForCall, struct {
    45  		arg1 uint64
    46  		arg2 *orderer.ConsensusRequest
    47  	}{arg1, arg2})
    48  	fake.recordInvocation("SendConsensus", []interface{}{arg1, arg2})
    49  	fake.sendConsensusMutex.Unlock()
    50  	if fake.SendConsensusStub != nil {
    51  		return fake.SendConsensusStub(arg1, arg2)
    52  	}
    53  	if specificReturn {
    54  		return ret.result1
    55  	}
    56  	fakeReturns := fake.sendConsensusReturns
    57  	return fakeReturns.result1
    58  }
    59  
    60  func (fake *FakeRPC) SendConsensusCallCount() int {
    61  	fake.sendConsensusMutex.RLock()
    62  	defer fake.sendConsensusMutex.RUnlock()
    63  	return len(fake.sendConsensusArgsForCall)
    64  }
    65  
    66  func (fake *FakeRPC) SendConsensusCalls(stub func(uint64, *orderer.ConsensusRequest) error) {
    67  	fake.sendConsensusMutex.Lock()
    68  	defer fake.sendConsensusMutex.Unlock()
    69  	fake.SendConsensusStub = stub
    70  }
    71  
    72  func (fake *FakeRPC) SendConsensusArgsForCall(i int) (uint64, *orderer.ConsensusRequest) {
    73  	fake.sendConsensusMutex.RLock()
    74  	defer fake.sendConsensusMutex.RUnlock()
    75  	argsForCall := fake.sendConsensusArgsForCall[i]
    76  	return argsForCall.arg1, argsForCall.arg2
    77  }
    78  
    79  func (fake *FakeRPC) SendConsensusReturns(result1 error) {
    80  	fake.sendConsensusMutex.Lock()
    81  	defer fake.sendConsensusMutex.Unlock()
    82  	fake.SendConsensusStub = nil
    83  	fake.sendConsensusReturns = struct {
    84  		result1 error
    85  	}{result1}
    86  }
    87  
    88  func (fake *FakeRPC) SendConsensusReturnsOnCall(i int, result1 error) {
    89  	fake.sendConsensusMutex.Lock()
    90  	defer fake.sendConsensusMutex.Unlock()
    91  	fake.SendConsensusStub = nil
    92  	if fake.sendConsensusReturnsOnCall == nil {
    93  		fake.sendConsensusReturnsOnCall = make(map[int]struct {
    94  			result1 error
    95  		})
    96  	}
    97  	fake.sendConsensusReturnsOnCall[i] = struct {
    98  		result1 error
    99  	}{result1}
   100  }
   101  
   102  func (fake *FakeRPC) SendSubmit(arg1 uint64, arg2 *orderer.SubmitRequest, arg3 func(err error)) error {
   103  	fake.sendSubmitMutex.Lock()
   104  	ret, specificReturn := fake.sendSubmitReturnsOnCall[len(fake.sendSubmitArgsForCall)]
   105  	fake.sendSubmitArgsForCall = append(fake.sendSubmitArgsForCall, struct {
   106  		arg1 uint64
   107  		arg2 *orderer.SubmitRequest
   108  		arg3 func(err error)
   109  	}{arg1, arg2, arg3})
   110  	fake.recordInvocation("SendSubmit", []interface{}{arg1, arg2, arg3})
   111  	fake.sendSubmitMutex.Unlock()
   112  	if fake.SendSubmitStub != nil {
   113  		return fake.SendSubmitStub(arg1, arg2, arg3)
   114  	}
   115  	if specificReturn {
   116  		return ret.result1
   117  	}
   118  	fakeReturns := fake.sendSubmitReturns
   119  	return fakeReturns.result1
   120  }
   121  
   122  func (fake *FakeRPC) SendSubmitCallCount() int {
   123  	fake.sendSubmitMutex.RLock()
   124  	defer fake.sendSubmitMutex.RUnlock()
   125  	return len(fake.sendSubmitArgsForCall)
   126  }
   127  
   128  func (fake *FakeRPC) SendSubmitCalls(stub func(uint64, *orderer.SubmitRequest, func(err error)) error) {
   129  	fake.sendSubmitMutex.Lock()
   130  	defer fake.sendSubmitMutex.Unlock()
   131  	fake.SendSubmitStub = stub
   132  }
   133  
   134  func (fake *FakeRPC) SendSubmitArgsForCall(i int) (uint64, *orderer.SubmitRequest, func(err error)) {
   135  	fake.sendSubmitMutex.RLock()
   136  	defer fake.sendSubmitMutex.RUnlock()
   137  	argsForCall := fake.sendSubmitArgsForCall[i]
   138  	return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
   139  }
   140  
   141  func (fake *FakeRPC) SendSubmitReturns(result1 error) {
   142  	fake.sendSubmitMutex.Lock()
   143  	defer fake.sendSubmitMutex.Unlock()
   144  	fake.SendSubmitStub = nil
   145  	fake.sendSubmitReturns = struct {
   146  		result1 error
   147  	}{result1}
   148  }
   149  
   150  func (fake *FakeRPC) SendSubmitReturnsOnCall(i int, result1 error) {
   151  	fake.sendSubmitMutex.Lock()
   152  	defer fake.sendSubmitMutex.Unlock()
   153  	fake.SendSubmitStub = nil
   154  	if fake.sendSubmitReturnsOnCall == nil {
   155  		fake.sendSubmitReturnsOnCall = make(map[int]struct {
   156  			result1 error
   157  		})
   158  	}
   159  	fake.sendSubmitReturnsOnCall[i] = struct {
   160  		result1 error
   161  	}{result1}
   162  }
   163  
   164  func (fake *FakeRPC) Invocations() map[string][][]interface{} {
   165  	fake.invocationsMutex.RLock()
   166  	defer fake.invocationsMutex.RUnlock()
   167  	fake.sendConsensusMutex.RLock()
   168  	defer fake.sendConsensusMutex.RUnlock()
   169  	fake.sendSubmitMutex.RLock()
   170  	defer fake.sendSubmitMutex.RUnlock()
   171  	copiedInvocations := map[string][][]interface{}{}
   172  	for key, value := range fake.invocations {
   173  		copiedInvocations[key] = value
   174  	}
   175  	return copiedInvocations
   176  }
   177  
   178  func (fake *FakeRPC) recordInvocation(key string, args []interface{}) {
   179  	fake.invocationsMutex.Lock()
   180  	defer fake.invocationsMutex.Unlock()
   181  	if fake.invocations == nil {
   182  		fake.invocations = map[string][][]interface{}{}
   183  	}
   184  	if fake.invocations[key] == nil {
   185  		fake.invocations[key] = [][]interface{}{}
   186  	}
   187  	fake.invocations[key] = append(fake.invocations[key], args)
   188  }
   189  
   190  var _ etcdraft.RPC = new(FakeRPC)