github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/orderer/consensus/etcdraft/mocks/chain_manager.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package mocks 3 4 import ( 5 "sync" 6 7 "github.com/hechain20/hechain/orderer/common/types" 8 "github.com/hechain20/hechain/orderer/consensus" 9 "github.com/hechain20/hechain/orderer/consensus/etcdraft" 10 ) 11 12 type ChainManager struct { 13 CreateChainStub func(string) 14 createChainMutex sync.RWMutex 15 createChainArgsForCall []struct { 16 arg1 string 17 } 18 GetConsensusChainStub func(string) consensus.Chain 19 getConsensusChainMutex sync.RWMutex 20 getConsensusChainArgsForCall []struct { 21 arg1 string 22 } 23 getConsensusChainReturns struct { 24 result1 consensus.Chain 25 } 26 getConsensusChainReturnsOnCall map[int]struct { 27 result1 consensus.Chain 28 } 29 ReportConsensusRelationAndStatusMetricsStub func(string, types.ConsensusRelation, types.Status) 30 reportConsensusRelationAndStatusMetricsMutex sync.RWMutex 31 reportConsensusRelationAndStatusMetricsArgsForCall []struct { 32 arg1 string 33 arg2 types.ConsensusRelation 34 arg3 types.Status 35 } 36 SwitchChainToFollowerStub func(string) 37 switchChainToFollowerMutex sync.RWMutex 38 switchChainToFollowerArgsForCall []struct { 39 arg1 string 40 } 41 invocations map[string][][]interface{} 42 invocationsMutex sync.RWMutex 43 } 44 45 func (fake *ChainManager) CreateChain(arg1 string) { 46 fake.createChainMutex.Lock() 47 fake.createChainArgsForCall = append(fake.createChainArgsForCall, struct { 48 arg1 string 49 }{arg1}) 50 fake.recordInvocation("CreateChain", []interface{}{arg1}) 51 fake.createChainMutex.Unlock() 52 if fake.CreateChainStub != nil { 53 fake.CreateChainStub(arg1) 54 } 55 } 56 57 func (fake *ChainManager) CreateChainCallCount() int { 58 fake.createChainMutex.RLock() 59 defer fake.createChainMutex.RUnlock() 60 return len(fake.createChainArgsForCall) 61 } 62 63 func (fake *ChainManager) CreateChainCalls(stub func(string)) { 64 fake.createChainMutex.Lock() 65 defer fake.createChainMutex.Unlock() 66 fake.CreateChainStub = stub 67 } 68 69 func (fake *ChainManager) CreateChainArgsForCall(i int) string { 70 fake.createChainMutex.RLock() 71 defer fake.createChainMutex.RUnlock() 72 argsForCall := fake.createChainArgsForCall[i] 73 return argsForCall.arg1 74 } 75 76 func (fake *ChainManager) GetConsensusChain(arg1 string) consensus.Chain { 77 fake.getConsensusChainMutex.Lock() 78 ret, specificReturn := fake.getConsensusChainReturnsOnCall[len(fake.getConsensusChainArgsForCall)] 79 fake.getConsensusChainArgsForCall = append(fake.getConsensusChainArgsForCall, struct { 80 arg1 string 81 }{arg1}) 82 fake.recordInvocation("GetConsensusChain", []interface{}{arg1}) 83 fake.getConsensusChainMutex.Unlock() 84 if fake.GetConsensusChainStub != nil { 85 return fake.GetConsensusChainStub(arg1) 86 } 87 if specificReturn { 88 return ret.result1 89 } 90 fakeReturns := fake.getConsensusChainReturns 91 return fakeReturns.result1 92 } 93 94 func (fake *ChainManager) GetConsensusChainCallCount() int { 95 fake.getConsensusChainMutex.RLock() 96 defer fake.getConsensusChainMutex.RUnlock() 97 return len(fake.getConsensusChainArgsForCall) 98 } 99 100 func (fake *ChainManager) GetConsensusChainCalls(stub func(string) consensus.Chain) { 101 fake.getConsensusChainMutex.Lock() 102 defer fake.getConsensusChainMutex.Unlock() 103 fake.GetConsensusChainStub = stub 104 } 105 106 func (fake *ChainManager) GetConsensusChainArgsForCall(i int) string { 107 fake.getConsensusChainMutex.RLock() 108 defer fake.getConsensusChainMutex.RUnlock() 109 argsForCall := fake.getConsensusChainArgsForCall[i] 110 return argsForCall.arg1 111 } 112 113 func (fake *ChainManager) GetConsensusChainReturns(result1 consensus.Chain) { 114 fake.getConsensusChainMutex.Lock() 115 defer fake.getConsensusChainMutex.Unlock() 116 fake.GetConsensusChainStub = nil 117 fake.getConsensusChainReturns = struct { 118 result1 consensus.Chain 119 }{result1} 120 } 121 122 func (fake *ChainManager) GetConsensusChainReturnsOnCall(i int, result1 consensus.Chain) { 123 fake.getConsensusChainMutex.Lock() 124 defer fake.getConsensusChainMutex.Unlock() 125 fake.GetConsensusChainStub = nil 126 if fake.getConsensusChainReturnsOnCall == nil { 127 fake.getConsensusChainReturnsOnCall = make(map[int]struct { 128 result1 consensus.Chain 129 }) 130 } 131 fake.getConsensusChainReturnsOnCall[i] = struct { 132 result1 consensus.Chain 133 }{result1} 134 } 135 136 func (fake *ChainManager) ReportConsensusRelationAndStatusMetrics(arg1 string, arg2 types.ConsensusRelation, arg3 types.Status) { 137 fake.reportConsensusRelationAndStatusMetricsMutex.Lock() 138 fake.reportConsensusRelationAndStatusMetricsArgsForCall = append(fake.reportConsensusRelationAndStatusMetricsArgsForCall, struct { 139 arg1 string 140 arg2 types.ConsensusRelation 141 arg3 types.Status 142 }{arg1, arg2, arg3}) 143 fake.recordInvocation("ReportConsensusRelationAndStatusMetrics", []interface{}{arg1, arg2, arg3}) 144 fake.reportConsensusRelationAndStatusMetricsMutex.Unlock() 145 if fake.ReportConsensusRelationAndStatusMetricsStub != nil { 146 fake.ReportConsensusRelationAndStatusMetricsStub(arg1, arg2, arg3) 147 } 148 } 149 150 func (fake *ChainManager) ReportConsensusRelationAndStatusMetricsCallCount() int { 151 fake.reportConsensusRelationAndStatusMetricsMutex.RLock() 152 defer fake.reportConsensusRelationAndStatusMetricsMutex.RUnlock() 153 return len(fake.reportConsensusRelationAndStatusMetricsArgsForCall) 154 } 155 156 func (fake *ChainManager) ReportConsensusRelationAndStatusMetricsCalls(stub func(string, types.ConsensusRelation, types.Status)) { 157 fake.reportConsensusRelationAndStatusMetricsMutex.Lock() 158 defer fake.reportConsensusRelationAndStatusMetricsMutex.Unlock() 159 fake.ReportConsensusRelationAndStatusMetricsStub = stub 160 } 161 162 func (fake *ChainManager) ReportConsensusRelationAndStatusMetricsArgsForCall(i int) (string, types.ConsensusRelation, types.Status) { 163 fake.reportConsensusRelationAndStatusMetricsMutex.RLock() 164 defer fake.reportConsensusRelationAndStatusMetricsMutex.RUnlock() 165 argsForCall := fake.reportConsensusRelationAndStatusMetricsArgsForCall[i] 166 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 167 } 168 169 func (fake *ChainManager) SwitchChainToFollower(arg1 string) { 170 fake.switchChainToFollowerMutex.Lock() 171 fake.switchChainToFollowerArgsForCall = append(fake.switchChainToFollowerArgsForCall, struct { 172 arg1 string 173 }{arg1}) 174 fake.recordInvocation("SwitchChainToFollower", []interface{}{arg1}) 175 fake.switchChainToFollowerMutex.Unlock() 176 if fake.SwitchChainToFollowerStub != nil { 177 fake.SwitchChainToFollowerStub(arg1) 178 } 179 } 180 181 func (fake *ChainManager) SwitchChainToFollowerCallCount() int { 182 fake.switchChainToFollowerMutex.RLock() 183 defer fake.switchChainToFollowerMutex.RUnlock() 184 return len(fake.switchChainToFollowerArgsForCall) 185 } 186 187 func (fake *ChainManager) SwitchChainToFollowerCalls(stub func(string)) { 188 fake.switchChainToFollowerMutex.Lock() 189 defer fake.switchChainToFollowerMutex.Unlock() 190 fake.SwitchChainToFollowerStub = stub 191 } 192 193 func (fake *ChainManager) SwitchChainToFollowerArgsForCall(i int) string { 194 fake.switchChainToFollowerMutex.RLock() 195 defer fake.switchChainToFollowerMutex.RUnlock() 196 argsForCall := fake.switchChainToFollowerArgsForCall[i] 197 return argsForCall.arg1 198 } 199 200 func (fake *ChainManager) Invocations() map[string][][]interface{} { 201 fake.invocationsMutex.RLock() 202 defer fake.invocationsMutex.RUnlock() 203 fake.createChainMutex.RLock() 204 defer fake.createChainMutex.RUnlock() 205 fake.getConsensusChainMutex.RLock() 206 defer fake.getConsensusChainMutex.RUnlock() 207 fake.reportConsensusRelationAndStatusMetricsMutex.RLock() 208 defer fake.reportConsensusRelationAndStatusMetricsMutex.RUnlock() 209 fake.switchChainToFollowerMutex.RLock() 210 defer fake.switchChainToFollowerMutex.RUnlock() 211 copiedInvocations := map[string][][]interface{}{} 212 for key, value := range fake.invocations { 213 copiedInvocations[key] = value 214 } 215 return copiedInvocations 216 } 217 218 func (fake *ChainManager) recordInvocation(key string, args []interface{}) { 219 fake.invocationsMutex.Lock() 220 defer fake.invocationsMutex.Unlock() 221 if fake.invocations == nil { 222 fake.invocations = map[string][][]interface{}{} 223 } 224 if fake.invocations[key] == nil { 225 fake.invocations[key] = [][]interface{}{} 226 } 227 fake.invocations[key] = append(fake.invocations[key], args) 228 } 229 230 var _ etcdraft.ChainManager = new(ChainManager)