Exemplo n.º 1
0
func TestGetMSPManagerFromBlock(t *testing.T) {
	conf, err := msp.GetLocalMspConfig("../../../msp/sampleconfig/")
	if err != nil {
		t.Fatalf("GetLocalMspConfig failed, err %s", err)
	}

	block, err := msptestutils.GetTestBlockFromMspConfig(conf)
	if err != nil {
		t.Fatalf("getTestBlockFromMspConfig failed, err %s", err)
	}

	mgr, err := GetMSPManagerFromBlock(block)
	if err != nil {
		t.Fatalf("GetMSPManagerFromBlock failed, err %s", err)
	} else if mgr == nil {
		t.Fatalf("Returned nil manager")
	}

	msps, err := mgr.GetMSPs()
	if err != nil {
		t.Fatalf("EnlistedMSPs failed, err %s", err)
	}

	if msps == nil || len(msps) == 0 {
		t.Fatalf("There are no MSPS in the manager for chain %s", util.GetTestChainID())
	}
}
Exemplo n.º 2
0
func LoadLocalMsp(dir string) error {
	conf, err := msp.GetLocalMspConfig(dir)
	if err != nil {
		return err
	}

	return GetLocalMSP().Setup(conf)
}
Exemplo n.º 3
0
// FIXME: this is required for now because we need a local MSP
// and also the MSP mgr for the test chain; as soon as the code
// to setup chains is ready, the chain should be setup using
// the method below and this method should disappear
func LoadFakeSetupWithLocalMspAndTestChainMsp(dir string) error {
	conf, err := msp.GetLocalMspConfig(dir)
	if err != nil {
		return err
	}

	err = GetLocalMSP().Setup(conf)
	if err != nil {
		return err
	}

	fakeConfig := []*mspprotos.MSPConfig{conf}

	err = GetManagerForChain(util.GetTestChainID()).Setup(fakeConfig)
	if err != nil {
		return err
	}

	return nil
}