github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/msp/mgmt/peermsp_test.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 mgmt 18 19 import ( 20 "io/ioutil" 21 "os" 22 "testing" 23 ) 24 25 // getTestMSPConfigPath returns the path to sampleconfig for unit tests 26 func getTestMSPConfigPath() string { 27 cfgPath := os.Getenv("PEER_CFG_PATH") + "/msp/sampleconfig/" 28 if _, err := ioutil.ReadDir(cfgPath); err != nil { 29 cfgPath = os.Getenv("GOPATH") + "/src/github.com/hyperledger/fabric/msp/sampleconfig/" 30 } 31 return cfgPath 32 } 33 34 func TestLocalMSP(t *testing.T) { 35 testMSPConfigPath := getTestMSPConfigPath() 36 err := LoadLocalMsp(testMSPConfigPath, nil, "DEFAULT") 37 38 if err != nil { 39 t.Fatalf("LoadLocalMsp failed, err %s", err) 40 } 41 42 _, err = GetLocalMSP().GetDefaultSigningIdentity() 43 if err != nil { 44 t.Fatalf("GetDefaultSigningIdentity failed, err %s", err) 45 } 46 }