github.com/sykesm/fabric@v1.1.0-preview.0.20200129034918-2aa12b1a0181/core/mocks/txvalidator/support.go (about) 1 /* 2 Copyright IBM Corp. 2017 All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package support 18 19 import ( 20 "sync" 21 22 "github.com/hyperledger/fabric-protos-go/common" 23 "github.com/hyperledger/fabric/common/channelconfig" 24 "github.com/hyperledger/fabric/core/ledger" 25 "github.com/hyperledger/fabric/msp" 26 ) 27 28 type Support struct { 29 LedgerVal ledger.PeerLedger 30 MSPManagerVal msp.MSPManager 31 ApplyVal error 32 ACVal channelconfig.ApplicationCapabilities 33 34 sync.Mutex 35 capabilitiesInvokeCount int 36 mspManagerInvokeCount int 37 } 38 39 func (ms *Support) Capabilities() channelconfig.ApplicationCapabilities { 40 ms.Lock() 41 defer ms.Unlock() 42 ms.capabilitiesInvokeCount++ 43 return ms.ACVal 44 } 45 46 // Ledger returns LedgerVal 47 func (ms *Support) Ledger() ledger.PeerLedger { 48 return ms.LedgerVal 49 } 50 51 // MSPManager returns MSPManagerVal 52 func (ms *Support) MSPManager() msp.MSPManager { 53 ms.Lock() 54 defer ms.Unlock() 55 ms.mspManagerInvokeCount++ 56 return ms.MSPManagerVal 57 } 58 59 // Apply returns ApplyVal 60 func (ms *Support) Apply(configtx *common.ConfigEnvelope) error { 61 return ms.ApplyVal 62 } 63 64 func (ms *Support) GetMSPIDs() []string { 65 return []string{"SampleOrg"} 66 } 67 68 func (ms *Support) CapabilitiesInvokeCount() int { 69 ms.Lock() 70 defer ms.Unlock() 71 return ms.capabilitiesInvokeCount 72 } 73 74 func (ms *Support) MSPManagerInvokeCount() int { 75 ms.Lock() 76 defer ms.Unlock() 77 return ms.mspManagerInvokeCount 78 }