-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change-set removes the hardcoded ID of the local MSP and reads it from core.yaml instead. Additionally, the code that sets up the MSPs for the test chain has been cleaned up - the test setup is now only used in testing and the peer always sets up chain MSPs from the config block (whether it's the test chain or a chain it is asked to join). Change-Id: Ife55c9be831172e603b4495bdfa37982a571d3a9 Signed-off-by: Alessandro Sorniotti <[email protected]>
- Loading branch information
Showing
32 changed files
with
208 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
Copyright IBM Corp. 2017 All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package msptesttools | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/hyperledger/fabric/common/util" | ||
"github.com/hyperledger/fabric/msp" | ||
"github.com/hyperledger/fabric/msp/mgmt" | ||
mspprotos "github.com/hyperledger/fabric/protos/msp" | ||
) | ||
|
||
func getConfigPath(dir string) (string, error) { | ||
// Try to read the dir | ||
if _, err := os.Stat(dir); err != nil { | ||
cfg := os.Getenv("PEER_CFG_PATH") | ||
if cfg != "" { | ||
dir = filepath.Join(cfg, dir) | ||
} else { | ||
dir = filepath.Join(os.Getenv("GOPATH"), "/src/github.com/hyperledger/fabric/msp/sampleconfig/") | ||
} | ||
if _, err := os.Stat(dir); err != nil { | ||
return "", err | ||
} | ||
} | ||
return dir, nil | ||
} | ||
|
||
// LoadTestMSPSetup sets up the local MSP | ||
// and a chain MSP for the default chain | ||
func LoadMSPSetupForTesting(dir string) error { | ||
var err error | ||
if dir, err = getConfigPath(dir); err != nil { | ||
return err | ||
} | ||
conf, err := msp.GetLocalMspConfig(dir, "DEFAULT") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = mgmt.GetLocalMSP().Setup(conf) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fakeConfig := []*mspprotos.MSPConfig{conf} | ||
|
||
err = mgmt.GetManagerForChain(util.GetTestChainID()).Setup(fakeConfig) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.