github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/internal/pkg/gateway/mocks/ledger.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/hechain20/hechain/common/ledger"
     9  )
    10  
    11  type Ledger struct {
    12  	CloseStub        func()
    13  	closeMutex       sync.RWMutex
    14  	closeArgsForCall []struct {
    15  	}
    16  	GetBlockByNumberStub        func(uint64) (*common.Block, error)
    17  	getBlockByNumberMutex       sync.RWMutex
    18  	getBlockByNumberArgsForCall []struct {
    19  		arg1 uint64
    20  	}
    21  	getBlockByNumberReturns struct {
    22  		result1 *common.Block
    23  		result2 error
    24  	}
    25  	getBlockByNumberReturnsOnCall map[int]struct {
    26  		result1 *common.Block
    27  		result2 error
    28  	}
    29  	GetBlockchainInfoStub        func() (*common.BlockchainInfo, error)
    30  	getBlockchainInfoMutex       sync.RWMutex
    31  	getBlockchainInfoArgsForCall []struct {
    32  	}
    33  	getBlockchainInfoReturns struct {
    34  		result1 *common.BlockchainInfo
    35  		result2 error
    36  	}
    37  	getBlockchainInfoReturnsOnCall map[int]struct {
    38  		result1 *common.BlockchainInfo
    39  		result2 error
    40  	}
    41  	GetBlocksIteratorStub        func(uint64) (ledger.ResultsIterator, error)
    42  	getBlocksIteratorMutex       sync.RWMutex
    43  	getBlocksIteratorArgsForCall []struct {
    44  		arg1 uint64
    45  	}
    46  	getBlocksIteratorReturns struct {
    47  		result1 ledger.ResultsIterator
    48  		result2 error
    49  	}
    50  	getBlocksIteratorReturnsOnCall map[int]struct {
    51  		result1 ledger.ResultsIterator
    52  		result2 error
    53  	}
    54  	invocations      map[string][][]interface{}
    55  	invocationsMutex sync.RWMutex
    56  }
    57  
    58  func (fake *Ledger) Close() {
    59  	fake.closeMutex.Lock()
    60  	fake.closeArgsForCall = append(fake.closeArgsForCall, struct {
    61  	}{})
    62  	stub := fake.CloseStub
    63  	fake.recordInvocation("Close", []interface{}{})
    64  	fake.closeMutex.Unlock()
    65  	if stub != nil {
    66  		fake.CloseStub()
    67  	}
    68  }
    69  
    70  func (fake *Ledger) CloseCallCount() int {
    71  	fake.closeMutex.RLock()
    72  	defer fake.closeMutex.RUnlock()
    73  	return len(fake.closeArgsForCall)
    74  }
    75  
    76  func (fake *Ledger) CloseCalls(stub func()) {
    77  	fake.closeMutex.Lock()
    78  	defer fake.closeMutex.Unlock()
    79  	fake.CloseStub = stub
    80  }
    81  
    82  func (fake *Ledger) GetBlockByNumber(arg1 uint64) (*common.Block, error) {
    83  	fake.getBlockByNumberMutex.Lock()
    84  	ret, specificReturn := fake.getBlockByNumberReturnsOnCall[len(fake.getBlockByNumberArgsForCall)]
    85  	fake.getBlockByNumberArgsForCall = append(fake.getBlockByNumberArgsForCall, struct {
    86  		arg1 uint64
    87  	}{arg1})
    88  	stub := fake.GetBlockByNumberStub
    89  	fakeReturns := fake.getBlockByNumberReturns
    90  	fake.recordInvocation("GetBlockByNumber", []interface{}{arg1})
    91  	fake.getBlockByNumberMutex.Unlock()
    92  	if stub != nil {
    93  		return stub(arg1)
    94  	}
    95  	if specificReturn {
    96  		return ret.result1, ret.result2
    97  	}
    98  	return fakeReturns.result1, fakeReturns.result2
    99  }
   100  
   101  func (fake *Ledger) GetBlockByNumberCallCount() int {
   102  	fake.getBlockByNumberMutex.RLock()
   103  	defer fake.getBlockByNumberMutex.RUnlock()
   104  	return len(fake.getBlockByNumberArgsForCall)
   105  }
   106  
   107  func (fake *Ledger) GetBlockByNumberCalls(stub func(uint64) (*common.Block, error)) {
   108  	fake.getBlockByNumberMutex.Lock()
   109  	defer fake.getBlockByNumberMutex.Unlock()
   110  	fake.GetBlockByNumberStub = stub
   111  }
   112  
   113  func (fake *Ledger) GetBlockByNumberArgsForCall(i int) uint64 {
   114  	fake.getBlockByNumberMutex.RLock()
   115  	defer fake.getBlockByNumberMutex.RUnlock()
   116  	argsForCall := fake.getBlockByNumberArgsForCall[i]
   117  	return argsForCall.arg1
   118  }
   119  
   120  func (fake *Ledger) GetBlockByNumberReturns(result1 *common.Block, result2 error) {
   121  	fake.getBlockByNumberMutex.Lock()
   122  	defer fake.getBlockByNumberMutex.Unlock()
   123  	fake.GetBlockByNumberStub = nil
   124  	fake.getBlockByNumberReturns = struct {
   125  		result1 *common.Block
   126  		result2 error
   127  	}{result1, result2}
   128  }
   129  
   130  func (fake *Ledger) GetBlockByNumberReturnsOnCall(i int, result1 *common.Block, result2 error) {
   131  	fake.getBlockByNumberMutex.Lock()
   132  	defer fake.getBlockByNumberMutex.Unlock()
   133  	fake.GetBlockByNumberStub = nil
   134  	if fake.getBlockByNumberReturnsOnCall == nil {
   135  		fake.getBlockByNumberReturnsOnCall = make(map[int]struct {
   136  			result1 *common.Block
   137  			result2 error
   138  		})
   139  	}
   140  	fake.getBlockByNumberReturnsOnCall[i] = struct {
   141  		result1 *common.Block
   142  		result2 error
   143  	}{result1, result2}
   144  }
   145  
   146  func (fake *Ledger) GetBlockchainInfo() (*common.BlockchainInfo, error) {
   147  	fake.getBlockchainInfoMutex.Lock()
   148  	ret, specificReturn := fake.getBlockchainInfoReturnsOnCall[len(fake.getBlockchainInfoArgsForCall)]
   149  	fake.getBlockchainInfoArgsForCall = append(fake.getBlockchainInfoArgsForCall, struct {
   150  	}{})
   151  	stub := fake.GetBlockchainInfoStub
   152  	fakeReturns := fake.getBlockchainInfoReturns
   153  	fake.recordInvocation("GetBlockchainInfo", []interface{}{})
   154  	fake.getBlockchainInfoMutex.Unlock()
   155  	if stub != nil {
   156  		return stub()
   157  	}
   158  	if specificReturn {
   159  		return ret.result1, ret.result2
   160  	}
   161  	return fakeReturns.result1, fakeReturns.result2
   162  }
   163  
   164  func (fake *Ledger) GetBlockchainInfoCallCount() int {
   165  	fake.getBlockchainInfoMutex.RLock()
   166  	defer fake.getBlockchainInfoMutex.RUnlock()
   167  	return len(fake.getBlockchainInfoArgsForCall)
   168  }
   169  
   170  func (fake *Ledger) GetBlockchainInfoCalls(stub func() (*common.BlockchainInfo, error)) {
   171  	fake.getBlockchainInfoMutex.Lock()
   172  	defer fake.getBlockchainInfoMutex.Unlock()
   173  	fake.GetBlockchainInfoStub = stub
   174  }
   175  
   176  func (fake *Ledger) GetBlockchainInfoReturns(result1 *common.BlockchainInfo, result2 error) {
   177  	fake.getBlockchainInfoMutex.Lock()
   178  	defer fake.getBlockchainInfoMutex.Unlock()
   179  	fake.GetBlockchainInfoStub = nil
   180  	fake.getBlockchainInfoReturns = struct {
   181  		result1 *common.BlockchainInfo
   182  		result2 error
   183  	}{result1, result2}
   184  }
   185  
   186  func (fake *Ledger) GetBlockchainInfoReturnsOnCall(i int, result1 *common.BlockchainInfo, result2 error) {
   187  	fake.getBlockchainInfoMutex.Lock()
   188  	defer fake.getBlockchainInfoMutex.Unlock()
   189  	fake.GetBlockchainInfoStub = nil
   190  	if fake.getBlockchainInfoReturnsOnCall == nil {
   191  		fake.getBlockchainInfoReturnsOnCall = make(map[int]struct {
   192  			result1 *common.BlockchainInfo
   193  			result2 error
   194  		})
   195  	}
   196  	fake.getBlockchainInfoReturnsOnCall[i] = struct {
   197  		result1 *common.BlockchainInfo
   198  		result2 error
   199  	}{result1, result2}
   200  }
   201  
   202  func (fake *Ledger) GetBlocksIterator(arg1 uint64) (ledger.ResultsIterator, error) {
   203  	fake.getBlocksIteratorMutex.Lock()
   204  	ret, specificReturn := fake.getBlocksIteratorReturnsOnCall[len(fake.getBlocksIteratorArgsForCall)]
   205  	fake.getBlocksIteratorArgsForCall = append(fake.getBlocksIteratorArgsForCall, struct {
   206  		arg1 uint64
   207  	}{arg1})
   208  	stub := fake.GetBlocksIteratorStub
   209  	fakeReturns := fake.getBlocksIteratorReturns
   210  	fake.recordInvocation("GetBlocksIterator", []interface{}{arg1})
   211  	fake.getBlocksIteratorMutex.Unlock()
   212  	if stub != nil {
   213  		return stub(arg1)
   214  	}
   215  	if specificReturn {
   216  		return ret.result1, ret.result2
   217  	}
   218  	return fakeReturns.result1, fakeReturns.result2
   219  }
   220  
   221  func (fake *Ledger) GetBlocksIteratorCallCount() int {
   222  	fake.getBlocksIteratorMutex.RLock()
   223  	defer fake.getBlocksIteratorMutex.RUnlock()
   224  	return len(fake.getBlocksIteratorArgsForCall)
   225  }
   226  
   227  func (fake *Ledger) GetBlocksIteratorCalls(stub func(uint64) (ledger.ResultsIterator, error)) {
   228  	fake.getBlocksIteratorMutex.Lock()
   229  	defer fake.getBlocksIteratorMutex.Unlock()
   230  	fake.GetBlocksIteratorStub = stub
   231  }
   232  
   233  func (fake *Ledger) GetBlocksIteratorArgsForCall(i int) uint64 {
   234  	fake.getBlocksIteratorMutex.RLock()
   235  	defer fake.getBlocksIteratorMutex.RUnlock()
   236  	argsForCall := fake.getBlocksIteratorArgsForCall[i]
   237  	return argsForCall.arg1
   238  }
   239  
   240  func (fake *Ledger) GetBlocksIteratorReturns(result1 ledger.ResultsIterator, result2 error) {
   241  	fake.getBlocksIteratorMutex.Lock()
   242  	defer fake.getBlocksIteratorMutex.Unlock()
   243  	fake.GetBlocksIteratorStub = nil
   244  	fake.getBlocksIteratorReturns = struct {
   245  		result1 ledger.ResultsIterator
   246  		result2 error
   247  	}{result1, result2}
   248  }
   249  
   250  func (fake *Ledger) GetBlocksIteratorReturnsOnCall(i int, result1 ledger.ResultsIterator, result2 error) {
   251  	fake.getBlocksIteratorMutex.Lock()
   252  	defer fake.getBlocksIteratorMutex.Unlock()
   253  	fake.GetBlocksIteratorStub = nil
   254  	if fake.getBlocksIteratorReturnsOnCall == nil {
   255  		fake.getBlocksIteratorReturnsOnCall = make(map[int]struct {
   256  			result1 ledger.ResultsIterator
   257  			result2 error
   258  		})
   259  	}
   260  	fake.getBlocksIteratorReturnsOnCall[i] = struct {
   261  		result1 ledger.ResultsIterator
   262  		result2 error
   263  	}{result1, result2}
   264  }
   265  
   266  func (fake *Ledger) Invocations() map[string][][]interface{} {
   267  	fake.invocationsMutex.RLock()
   268  	defer fake.invocationsMutex.RUnlock()
   269  	fake.closeMutex.RLock()
   270  	defer fake.closeMutex.RUnlock()
   271  	fake.getBlockByNumberMutex.RLock()
   272  	defer fake.getBlockByNumberMutex.RUnlock()
   273  	fake.getBlockchainInfoMutex.RLock()
   274  	defer fake.getBlockchainInfoMutex.RUnlock()
   275  	fake.getBlocksIteratorMutex.RLock()
   276  	defer fake.getBlocksIteratorMutex.RUnlock()
   277  	copiedInvocations := map[string][][]interface{}{}
   278  	for key, value := range fake.invocations {
   279  		copiedInvocations[key] = value
   280  	}
   281  	return copiedInvocations
   282  }
   283  
   284  func (fake *Ledger) recordInvocation(key string, args []interface{}) {
   285  	fake.invocationsMutex.Lock()
   286  	defer fake.invocationsMutex.Unlock()
   287  	if fake.invocations == nil {
   288  		fake.invocations = map[string][][]interface{}{}
   289  	}
   290  	if fake.invocations[key] == nil {
   291  		fake.invocations[key] = [][]interface{}{}
   292  	}
   293  	fake.invocations[key] = append(fake.invocations[key], args)
   294  }