github.com/ewagmig/fabric@v2.1.1+incompatible/common/deliver/mock/block_reader.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package mock
     3  
     4  import (
     5  	"sync"
     6  
     7  	"github.com/hyperledger/fabric-protos-go/orderer"
     8  	"github.com/hyperledger/fabric/common/ledger/blockledger"
     9  )
    10  
    11  type BlockReader struct {
    12  	HeightStub        func() uint64
    13  	heightMutex       sync.RWMutex
    14  	heightArgsForCall []struct {
    15  	}
    16  	heightReturns struct {
    17  		result1 uint64
    18  	}
    19  	heightReturnsOnCall map[int]struct {
    20  		result1 uint64
    21  	}
    22  	IteratorStub        func(*orderer.SeekPosition) (blockledger.Iterator, uint64)
    23  	iteratorMutex       sync.RWMutex
    24  	iteratorArgsForCall []struct {
    25  		arg1 *orderer.SeekPosition
    26  	}
    27  	iteratorReturns struct {
    28  		result1 blockledger.Iterator
    29  		result2 uint64
    30  	}
    31  	iteratorReturnsOnCall map[int]struct {
    32  		result1 blockledger.Iterator
    33  		result2 uint64
    34  	}
    35  	invocations      map[string][][]interface{}
    36  	invocationsMutex sync.RWMutex
    37  }
    38  
    39  func (fake *BlockReader) Height() uint64 {
    40  	fake.heightMutex.Lock()
    41  	ret, specificReturn := fake.heightReturnsOnCall[len(fake.heightArgsForCall)]
    42  	fake.heightArgsForCall = append(fake.heightArgsForCall, struct {
    43  	}{})
    44  	fake.recordInvocation("Height", []interface{}{})
    45  	fake.heightMutex.Unlock()
    46  	if fake.HeightStub != nil {
    47  		return fake.HeightStub()
    48  	}
    49  	if specificReturn {
    50  		return ret.result1
    51  	}
    52  	fakeReturns := fake.heightReturns
    53  	return fakeReturns.result1
    54  }
    55  
    56  func (fake *BlockReader) HeightCallCount() int {
    57  	fake.heightMutex.RLock()
    58  	defer fake.heightMutex.RUnlock()
    59  	return len(fake.heightArgsForCall)
    60  }
    61  
    62  func (fake *BlockReader) HeightCalls(stub func() uint64) {
    63  	fake.heightMutex.Lock()
    64  	defer fake.heightMutex.Unlock()
    65  	fake.HeightStub = stub
    66  }
    67  
    68  func (fake *BlockReader) HeightReturns(result1 uint64) {
    69  	fake.heightMutex.Lock()
    70  	defer fake.heightMutex.Unlock()
    71  	fake.HeightStub = nil
    72  	fake.heightReturns = struct {
    73  		result1 uint64
    74  	}{result1}
    75  }
    76  
    77  func (fake *BlockReader) HeightReturnsOnCall(i int, result1 uint64) {
    78  	fake.heightMutex.Lock()
    79  	defer fake.heightMutex.Unlock()
    80  	fake.HeightStub = nil
    81  	if fake.heightReturnsOnCall == nil {
    82  		fake.heightReturnsOnCall = make(map[int]struct {
    83  			result1 uint64
    84  		})
    85  	}
    86  	fake.heightReturnsOnCall[i] = struct {
    87  		result1 uint64
    88  	}{result1}
    89  }
    90  
    91  func (fake *BlockReader) Iterator(arg1 *orderer.SeekPosition) (blockledger.Iterator, uint64) {
    92  	fake.iteratorMutex.Lock()
    93  	ret, specificReturn := fake.iteratorReturnsOnCall[len(fake.iteratorArgsForCall)]
    94  	fake.iteratorArgsForCall = append(fake.iteratorArgsForCall, struct {
    95  		arg1 *orderer.SeekPosition
    96  	}{arg1})
    97  	fake.recordInvocation("Iterator", []interface{}{arg1})
    98  	fake.iteratorMutex.Unlock()
    99  	if fake.IteratorStub != nil {
   100  		return fake.IteratorStub(arg1)
   101  	}
   102  	if specificReturn {
   103  		return ret.result1, ret.result2
   104  	}
   105  	fakeReturns := fake.iteratorReturns
   106  	return fakeReturns.result1, fakeReturns.result2
   107  }
   108  
   109  func (fake *BlockReader) IteratorCallCount() int {
   110  	fake.iteratorMutex.RLock()
   111  	defer fake.iteratorMutex.RUnlock()
   112  	return len(fake.iteratorArgsForCall)
   113  }
   114  
   115  func (fake *BlockReader) IteratorCalls(stub func(*orderer.SeekPosition) (blockledger.Iterator, uint64)) {
   116  	fake.iteratorMutex.Lock()
   117  	defer fake.iteratorMutex.Unlock()
   118  	fake.IteratorStub = stub
   119  }
   120  
   121  func (fake *BlockReader) IteratorArgsForCall(i int) *orderer.SeekPosition {
   122  	fake.iteratorMutex.RLock()
   123  	defer fake.iteratorMutex.RUnlock()
   124  	argsForCall := fake.iteratorArgsForCall[i]
   125  	return argsForCall.arg1
   126  }
   127  
   128  func (fake *BlockReader) IteratorReturns(result1 blockledger.Iterator, result2 uint64) {
   129  	fake.iteratorMutex.Lock()
   130  	defer fake.iteratorMutex.Unlock()
   131  	fake.IteratorStub = nil
   132  	fake.iteratorReturns = struct {
   133  		result1 blockledger.Iterator
   134  		result2 uint64
   135  	}{result1, result2}
   136  }
   137  
   138  func (fake *BlockReader) IteratorReturnsOnCall(i int, result1 blockledger.Iterator, result2 uint64) {
   139  	fake.iteratorMutex.Lock()
   140  	defer fake.iteratorMutex.Unlock()
   141  	fake.IteratorStub = nil
   142  	if fake.iteratorReturnsOnCall == nil {
   143  		fake.iteratorReturnsOnCall = make(map[int]struct {
   144  			result1 blockledger.Iterator
   145  			result2 uint64
   146  		})
   147  	}
   148  	fake.iteratorReturnsOnCall[i] = struct {
   149  		result1 blockledger.Iterator
   150  		result2 uint64
   151  	}{result1, result2}
   152  }
   153  
   154  func (fake *BlockReader) Invocations() map[string][][]interface{} {
   155  	fake.invocationsMutex.RLock()
   156  	defer fake.invocationsMutex.RUnlock()
   157  	fake.heightMutex.RLock()
   158  	defer fake.heightMutex.RUnlock()
   159  	fake.iteratorMutex.RLock()
   160  	defer fake.iteratorMutex.RUnlock()
   161  	copiedInvocations := map[string][][]interface{}{}
   162  	for key, value := range fake.invocations {
   163  		copiedInvocations[key] = value
   164  	}
   165  	return copiedInvocations
   166  }
   167  
   168  func (fake *BlockReader) recordInvocation(key string, args []interface{}) {
   169  	fake.invocationsMutex.Lock()
   170  	defer fake.invocationsMutex.Unlock()
   171  	if fake.invocations == nil {
   172  		fake.invocations = map[string][][]interface{}{}
   173  	}
   174  	if fake.invocations[key] == nil {
   175  		fake.invocations[key] = [][]interface{}{}
   176  	}
   177  	fake.invocations[key] = append(fake.invocations[key], args)
   178  }