github.com/anjalikarhana/fabric@v2.1.1+incompatible/orderer/common/multichannel/mocks/read_writer.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-protos-go/orderer"
     9  	"github.com/hyperledger/fabric/common/ledger/blockledger"
    10  )
    11  
    12  type ReadWriter struct {
    13  	AppendStub        func(*common.Block) error
    14  	appendMutex       sync.RWMutex
    15  	appendArgsForCall []struct {
    16  		arg1 *common.Block
    17  	}
    18  	appendReturns struct {
    19  		result1 error
    20  	}
    21  	appendReturnsOnCall map[int]struct {
    22  		result1 error
    23  	}
    24  	HeightStub        func() uint64
    25  	heightMutex       sync.RWMutex
    26  	heightArgsForCall []struct {
    27  	}
    28  	heightReturns struct {
    29  		result1 uint64
    30  	}
    31  	heightReturnsOnCall map[int]struct {
    32  		result1 uint64
    33  	}
    34  	IteratorStub        func(*orderer.SeekPosition) (blockledger.Iterator, uint64)
    35  	iteratorMutex       sync.RWMutex
    36  	iteratorArgsForCall []struct {
    37  		arg1 *orderer.SeekPosition
    38  	}
    39  	iteratorReturns struct {
    40  		result1 blockledger.Iterator
    41  		result2 uint64
    42  	}
    43  	iteratorReturnsOnCall map[int]struct {
    44  		result1 blockledger.Iterator
    45  		result2 uint64
    46  	}
    47  	invocations      map[string][][]interface{}
    48  	invocationsMutex sync.RWMutex
    49  }
    50  
    51  func (fake *ReadWriter) Append(arg1 *common.Block) error {
    52  	fake.appendMutex.Lock()
    53  	ret, specificReturn := fake.appendReturnsOnCall[len(fake.appendArgsForCall)]
    54  	fake.appendArgsForCall = append(fake.appendArgsForCall, struct {
    55  		arg1 *common.Block
    56  	}{arg1})
    57  	fake.recordInvocation("Append", []interface{}{arg1})
    58  	fake.appendMutex.Unlock()
    59  	if fake.AppendStub != nil {
    60  		return fake.AppendStub(arg1)
    61  	}
    62  	if specificReturn {
    63  		return ret.result1
    64  	}
    65  	fakeReturns := fake.appendReturns
    66  	return fakeReturns.result1
    67  }
    68  
    69  func (fake *ReadWriter) AppendCallCount() int {
    70  	fake.appendMutex.RLock()
    71  	defer fake.appendMutex.RUnlock()
    72  	return len(fake.appendArgsForCall)
    73  }
    74  
    75  func (fake *ReadWriter) AppendCalls(stub func(*common.Block) error) {
    76  	fake.appendMutex.Lock()
    77  	defer fake.appendMutex.Unlock()
    78  	fake.AppendStub = stub
    79  }
    80  
    81  func (fake *ReadWriter) AppendArgsForCall(i int) *common.Block {
    82  	fake.appendMutex.RLock()
    83  	defer fake.appendMutex.RUnlock()
    84  	argsForCall := fake.appendArgsForCall[i]
    85  	return argsForCall.arg1
    86  }
    87  
    88  func (fake *ReadWriter) AppendReturns(result1 error) {
    89  	fake.appendMutex.Lock()
    90  	defer fake.appendMutex.Unlock()
    91  	fake.AppendStub = nil
    92  	fake.appendReturns = struct {
    93  		result1 error
    94  	}{result1}
    95  }
    96  
    97  func (fake *ReadWriter) AppendReturnsOnCall(i int, result1 error) {
    98  	fake.appendMutex.Lock()
    99  	defer fake.appendMutex.Unlock()
   100  	fake.AppendStub = nil
   101  	if fake.appendReturnsOnCall == nil {
   102  		fake.appendReturnsOnCall = make(map[int]struct {
   103  			result1 error
   104  		})
   105  	}
   106  	fake.appendReturnsOnCall[i] = struct {
   107  		result1 error
   108  	}{result1}
   109  }
   110  
   111  func (fake *ReadWriter) Height() uint64 {
   112  	fake.heightMutex.Lock()
   113  	ret, specificReturn := fake.heightReturnsOnCall[len(fake.heightArgsForCall)]
   114  	fake.heightArgsForCall = append(fake.heightArgsForCall, struct {
   115  	}{})
   116  	fake.recordInvocation("Height", []interface{}{})
   117  	fake.heightMutex.Unlock()
   118  	if fake.HeightStub != nil {
   119  		return fake.HeightStub()
   120  	}
   121  	if specificReturn {
   122  		return ret.result1
   123  	}
   124  	fakeReturns := fake.heightReturns
   125  	return fakeReturns.result1
   126  }
   127  
   128  func (fake *ReadWriter) HeightCallCount() int {
   129  	fake.heightMutex.RLock()
   130  	defer fake.heightMutex.RUnlock()
   131  	return len(fake.heightArgsForCall)
   132  }
   133  
   134  func (fake *ReadWriter) HeightCalls(stub func() uint64) {
   135  	fake.heightMutex.Lock()
   136  	defer fake.heightMutex.Unlock()
   137  	fake.HeightStub = stub
   138  }
   139  
   140  func (fake *ReadWriter) HeightReturns(result1 uint64) {
   141  	fake.heightMutex.Lock()
   142  	defer fake.heightMutex.Unlock()
   143  	fake.HeightStub = nil
   144  	fake.heightReturns = struct {
   145  		result1 uint64
   146  	}{result1}
   147  }
   148  
   149  func (fake *ReadWriter) HeightReturnsOnCall(i int, result1 uint64) {
   150  	fake.heightMutex.Lock()
   151  	defer fake.heightMutex.Unlock()
   152  	fake.HeightStub = nil
   153  	if fake.heightReturnsOnCall == nil {
   154  		fake.heightReturnsOnCall = make(map[int]struct {
   155  			result1 uint64
   156  		})
   157  	}
   158  	fake.heightReturnsOnCall[i] = struct {
   159  		result1 uint64
   160  	}{result1}
   161  }
   162  
   163  func (fake *ReadWriter) Iterator(arg1 *orderer.SeekPosition) (blockledger.Iterator, uint64) {
   164  	fake.iteratorMutex.Lock()
   165  	ret, specificReturn := fake.iteratorReturnsOnCall[len(fake.iteratorArgsForCall)]
   166  	fake.iteratorArgsForCall = append(fake.iteratorArgsForCall, struct {
   167  		arg1 *orderer.SeekPosition
   168  	}{arg1})
   169  	fake.recordInvocation("Iterator", []interface{}{arg1})
   170  	fake.iteratorMutex.Unlock()
   171  	if fake.IteratorStub != nil {
   172  		return fake.IteratorStub(arg1)
   173  	}
   174  	if specificReturn {
   175  		return ret.result1, ret.result2
   176  	}
   177  	fakeReturns := fake.iteratorReturns
   178  	return fakeReturns.result1, fakeReturns.result2
   179  }
   180  
   181  func (fake *ReadWriter) IteratorCallCount() int {
   182  	fake.iteratorMutex.RLock()
   183  	defer fake.iteratorMutex.RUnlock()
   184  	return len(fake.iteratorArgsForCall)
   185  }
   186  
   187  func (fake *ReadWriter) IteratorCalls(stub func(*orderer.SeekPosition) (blockledger.Iterator, uint64)) {
   188  	fake.iteratorMutex.Lock()
   189  	defer fake.iteratorMutex.Unlock()
   190  	fake.IteratorStub = stub
   191  }
   192  
   193  func (fake *ReadWriter) IteratorArgsForCall(i int) *orderer.SeekPosition {
   194  	fake.iteratorMutex.RLock()
   195  	defer fake.iteratorMutex.RUnlock()
   196  	argsForCall := fake.iteratorArgsForCall[i]
   197  	return argsForCall.arg1
   198  }
   199  
   200  func (fake *ReadWriter) IteratorReturns(result1 blockledger.Iterator, result2 uint64) {
   201  	fake.iteratorMutex.Lock()
   202  	defer fake.iteratorMutex.Unlock()
   203  	fake.IteratorStub = nil
   204  	fake.iteratorReturns = struct {
   205  		result1 blockledger.Iterator
   206  		result2 uint64
   207  	}{result1, result2}
   208  }
   209  
   210  func (fake *ReadWriter) IteratorReturnsOnCall(i int, result1 blockledger.Iterator, result2 uint64) {
   211  	fake.iteratorMutex.Lock()
   212  	defer fake.iteratorMutex.Unlock()
   213  	fake.IteratorStub = nil
   214  	if fake.iteratorReturnsOnCall == nil {
   215  		fake.iteratorReturnsOnCall = make(map[int]struct {
   216  			result1 blockledger.Iterator
   217  			result2 uint64
   218  		})
   219  	}
   220  	fake.iteratorReturnsOnCall[i] = struct {
   221  		result1 blockledger.Iterator
   222  		result2 uint64
   223  	}{result1, result2}
   224  }
   225  
   226  func (fake *ReadWriter) Invocations() map[string][][]interface{} {
   227  	fake.invocationsMutex.RLock()
   228  	defer fake.invocationsMutex.RUnlock()
   229  	fake.appendMutex.RLock()
   230  	defer fake.appendMutex.RUnlock()
   231  	fake.heightMutex.RLock()
   232  	defer fake.heightMutex.RUnlock()
   233  	fake.iteratorMutex.RLock()
   234  	defer fake.iteratorMutex.RUnlock()
   235  	copiedInvocations := map[string][][]interface{}{}
   236  	for key, value := range fake.invocations {
   237  		copiedInvocations[key] = value
   238  	}
   239  	return copiedInvocations
   240  }
   241  
   242  func (fake *ReadWriter) recordInvocation(key string, args []interface{}) {
   243  	fake.invocationsMutex.Lock()
   244  	defer fake.invocationsMutex.Unlock()
   245  	if fake.invocations == nil {
   246  		fake.invocations = map[string][][]interface{}{}
   247  	}
   248  	if fake.invocations[key] == nil {
   249  		fake.invocations[key] = [][]interface{}{}
   250  	}
   251  	fake.invocations[key] = append(fake.invocations[key], args)
   252  }