github.com/true-sqn/fabric@v2.1.1+incompatible/msp/mgmt/testtools/config.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package msptesttools 8 9 import ( 10 "github.com/hyperledger/fabric/bccsp/factory" 11 "github.com/hyperledger/fabric/core/config/configtest" 12 "github.com/hyperledger/fabric/msp" 13 "github.com/hyperledger/fabric/msp/mgmt" 14 ) 15 16 // LoadTestMSPSetup sets up the local MSP 17 // and a chain MSP for the default chain 18 func LoadMSPSetupForTesting() error { 19 dir := configtest.GetDevMspDir() 20 conf, err := msp.GetLocalMspConfig(dir, nil, "SampleOrg") 21 if err != nil { 22 return err 23 } 24 25 err = mgmt.GetLocalMSP(factory.GetDefault()).Setup(conf) 26 if err != nil { 27 return err 28 } 29 30 err = mgmt.GetManagerForChain("testchannelid").Setup([]msp.MSP{mgmt.GetLocalMSP(factory.GetDefault())}) 31 if err != nil { 32 return err 33 } 34 35 return nil 36 } 37 38 // Loads the development local MSP for use in testing. Not valid for production/runtime context 39 func LoadDevMsp() error { 40 mspDir := configtest.GetDevMspDir() 41 return mgmt.LoadLocalMsp(mspDir, nil, "SampleOrg") 42 }