github.com/true-sqn/fabric@v2.1.1+incompatible/orderer/consensus/etcdraft/mocks/mock_blockpuller.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/common"
     8  	"github.com/hyperledger/fabric/orderer/consensus/etcdraft"
     9  )
    10  
    11  type FakeBlockPuller struct {
    12  	CloseStub        func()
    13  	closeMutex       sync.RWMutex
    14  	closeArgsForCall []struct {
    15  	}
    16  	HeightsByEndpointsStub        func() (map[string]uint64, error)
    17  	heightsByEndpointsMutex       sync.RWMutex
    18  	heightsByEndpointsArgsForCall []struct {
    19  	}
    20  	heightsByEndpointsReturns struct {
    21  		result1 map[string]uint64
    22  		result2 error
    23  	}
    24  	heightsByEndpointsReturnsOnCall map[int]struct {
    25  		result1 map[string]uint64
    26  		result2 error
    27  	}
    28  	PullBlockStub        func(uint64) *common.Block
    29  	pullBlockMutex       sync.RWMutex
    30  	pullBlockArgsForCall []struct {
    31  		arg1 uint64
    32  	}
    33  	pullBlockReturns struct {
    34  		result1 *common.Block
    35  	}
    36  	pullBlockReturnsOnCall map[int]struct {
    37  		result1 *common.Block
    38  	}
    39  	invocations      map[string][][]interface{}
    40  	invocationsMutex sync.RWMutex
    41  }
    42  
    43  func (fake *FakeBlockPuller) Close() {
    44  	fake.closeMutex.Lock()
    45  	fake.closeArgsForCall = append(fake.closeArgsForCall, struct {
    46  	}{})
    47  	fake.recordInvocation("Close", []interface{}{})
    48  	fake.closeMutex.Unlock()
    49  	if fake.CloseStub != nil {
    50  		fake.CloseStub()
    51  	}
    52  }
    53  
    54  func (fake *FakeBlockPuller) CloseCallCount() int {
    55  	fake.closeMutex.RLock()
    56  	defer fake.closeMutex.RUnlock()
    57  	return len(fake.closeArgsForCall)
    58  }
    59  
    60  func (fake *FakeBlockPuller) CloseCalls(stub func()) {
    61  	fake.closeMutex.Lock()
    62  	defer fake.closeMutex.Unlock()
    63  	fake.CloseStub = stub
    64  }
    65  
    66  func (fake *FakeBlockPuller) HeightsByEndpoints() (map[string]uint64, error) {
    67  	fake.heightsByEndpointsMutex.Lock()
    68  	ret, specificReturn := fake.heightsByEndpointsReturnsOnCall[len(fake.heightsByEndpointsArgsForCall)]
    69  	fake.heightsByEndpointsArgsForCall = append(fake.heightsByEndpointsArgsForCall, struct {
    70  	}{})
    71  	fake.recordInvocation("HeightsByEndpoints", []interface{}{})
    72  	fake.heightsByEndpointsMutex.Unlock()
    73  	if fake.HeightsByEndpointsStub != nil {
    74  		return fake.HeightsByEndpointsStub()
    75  	}
    76  	if specificReturn {
    77  		return ret.result1, ret.result2
    78  	}
    79  	fakeReturns := fake.heightsByEndpointsReturns
    80  	return fakeReturns.result1, fakeReturns.result2
    81  }
    82  
    83  func (fake *FakeBlockPuller) HeightsByEndpointsCallCount() int {
    84  	fake.heightsByEndpointsMutex.RLock()
    85  	defer fake.heightsByEndpointsMutex.RUnlock()
    86  	return len(fake.heightsByEndpointsArgsForCall)
    87  }
    88  
    89  func (fake *FakeBlockPuller) HeightsByEndpointsCalls(stub func() (map[string]uint64, error)) {
    90  	fake.heightsByEndpointsMutex.Lock()
    91  	defer fake.heightsByEndpointsMutex.Unlock()
    92  	fake.HeightsByEndpointsStub = stub
    93  }
    94  
    95  func (fake *FakeBlockPuller) HeightsByEndpointsReturns(result1 map[string]uint64, result2 error) {
    96  	fake.heightsByEndpointsMutex.Lock()
    97  	defer fake.heightsByEndpointsMutex.Unlock()
    98  	fake.HeightsByEndpointsStub = nil
    99  	fake.heightsByEndpointsReturns = struct {
   100  		result1 map[string]uint64
   101  		result2 error
   102  	}{result1, result2}
   103  }
   104  
   105  func (fake *FakeBlockPuller) HeightsByEndpointsReturnsOnCall(i int, result1 map[string]uint64, result2 error) {
   106  	fake.heightsByEndpointsMutex.Lock()
   107  	defer fake.heightsByEndpointsMutex.Unlock()
   108  	fake.HeightsByEndpointsStub = nil
   109  	if fake.heightsByEndpointsReturnsOnCall == nil {
   110  		fake.heightsByEndpointsReturnsOnCall = make(map[int]struct {
   111  			result1 map[string]uint64
   112  			result2 error
   113  		})
   114  	}
   115  	fake.heightsByEndpointsReturnsOnCall[i] = struct {
   116  		result1 map[string]uint64
   117  		result2 error
   118  	}{result1, result2}
   119  }
   120  
   121  func (fake *FakeBlockPuller) PullBlock(arg1 uint64) *common.Block {
   122  	fake.pullBlockMutex.Lock()
   123  	ret, specificReturn := fake.pullBlockReturnsOnCall[len(fake.pullBlockArgsForCall)]
   124  	fake.pullBlockArgsForCall = append(fake.pullBlockArgsForCall, struct {
   125  		arg1 uint64
   126  	}{arg1})
   127  	fake.recordInvocation("PullBlock", []interface{}{arg1})
   128  	fake.pullBlockMutex.Unlock()
   129  	if fake.PullBlockStub != nil {
   130  		return fake.PullBlockStub(arg1)
   131  	}
   132  	if specificReturn {
   133  		return ret.result1
   134  	}
   135  	fakeReturns := fake.pullBlockReturns
   136  	return fakeReturns.result1
   137  }
   138  
   139  func (fake *FakeBlockPuller) PullBlockCallCount() int {
   140  	fake.pullBlockMutex.RLock()
   141  	defer fake.pullBlockMutex.RUnlock()
   142  	return len(fake.pullBlockArgsForCall)
   143  }
   144  
   145  func (fake *FakeBlockPuller) PullBlockCalls(stub func(uint64) *common.Block) {
   146  	fake.pullBlockMutex.Lock()
   147  	defer fake.pullBlockMutex.Unlock()
   148  	fake.PullBlockStub = stub
   149  }
   150  
   151  func (fake *FakeBlockPuller) PullBlockArgsForCall(i int) uint64 {
   152  	fake.pullBlockMutex.RLock()
   153  	defer fake.pullBlockMutex.RUnlock()
   154  	argsForCall := fake.pullBlockArgsForCall[i]
   155  	return argsForCall.arg1
   156  }
   157  
   158  func (fake *FakeBlockPuller) PullBlockReturns(result1 *common.Block) {
   159  	fake.pullBlockMutex.Lock()
   160  	defer fake.pullBlockMutex.Unlock()
   161  	fake.PullBlockStub = nil
   162  	fake.pullBlockReturns = struct {
   163  		result1 *common.Block
   164  	}{result1}
   165  }
   166  
   167  func (fake *FakeBlockPuller) PullBlockReturnsOnCall(i int, result1 *common.Block) {
   168  	fake.pullBlockMutex.Lock()
   169  	defer fake.pullBlockMutex.Unlock()
   170  	fake.PullBlockStub = nil
   171  	if fake.pullBlockReturnsOnCall == nil {
   172  		fake.pullBlockReturnsOnCall = make(map[int]struct {
   173  			result1 *common.Block
   174  		})
   175  	}
   176  	fake.pullBlockReturnsOnCall[i] = struct {
   177  		result1 *common.Block
   178  	}{result1}
   179  }
   180  
   181  func (fake *FakeBlockPuller) Invocations() map[string][][]interface{} {
   182  	fake.invocationsMutex.RLock()
   183  	defer fake.invocationsMutex.RUnlock()
   184  	fake.closeMutex.RLock()
   185  	defer fake.closeMutex.RUnlock()
   186  	fake.heightsByEndpointsMutex.RLock()
   187  	defer fake.heightsByEndpointsMutex.RUnlock()
   188  	fake.pullBlockMutex.RLock()
   189  	defer fake.pullBlockMutex.RUnlock()
   190  	copiedInvocations := map[string][][]interface{}{}
   191  	for key, value := range fake.invocations {
   192  		copiedInvocations[key] = value
   193  	}
   194  	return copiedInvocations
   195  }
   196  
   197  func (fake *FakeBlockPuller) recordInvocation(key string, args []interface{}) {
   198  	fake.invocationsMutex.Lock()
   199  	defer fake.invocationsMutex.Unlock()
   200  	if fake.invocations == nil {
   201  		fake.invocations = map[string][][]interface{}{}
   202  	}
   203  	if fake.invocations[key] == nil {
   204  		fake.invocations[key] = [][]interface{}{}
   205  	}
   206  	fake.invocations[key] = append(fake.invocations[key], args)
   207  }
   208  
   209  var _ etcdraft.BlockPuller = new(FakeBlockPuller)