github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/msp/mgmt/testtools/config.go (about)

     1  /*
     2  Copyright hechain. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package msptesttools
     8  
     9  import (
    10  	"github.com/hechain20/hechain/bccsp/factory"
    11  	"github.com/hechain20/hechain/core/config/configtest"
    12  	"github.com/hechain20/hechain/msp"
    13  	"github.com/hechain20/hechain/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  }