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