本文整理匯總了Golang中github.com/hyperledger/fabric/core/crypto/utils.NodeConfiguration.GetEnrollmentID方法的典型用法代碼示例。如果您正苦於以下問題:Golang NodeConfiguration.GetEnrollmentID方法的具體用法?Golang NodeConfiguration.GetEnrollmentID怎麽用?Golang NodeConfiguration.GetEnrollmentID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hyperledger/fabric/core/crypto/utils.NodeConfiguration
的用法示例。
在下文中一共展示了NodeConfiguration.GetEnrollmentID方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestParallelInitClose
func TestParallelInitClose(t *testing.T) {
// TODO: complete this
conf := utils.NodeConfiguration{Type: "client", Name: "userthread"}
RegisterClient(conf.Name, nil, conf.GetEnrollmentID(), conf.GetEnrollmentPWD())
done := make(chan bool)
n := 10
for i := 0; i < n; i++ {
go func() {
for i := 0; i < 5; i++ {
client, err := InitClient(conf.Name, nil)
if err != nil {
t.Log("Init failed")
}
cis := &obc.ChaincodeInvocationSpec{
ChaincodeSpec: &obc.ChaincodeSpec{
Type: obc.ChaincodeSpec_GOLANG,
ChaincodeID: &obc.ChaincodeID{Path: "Contract001"},
CtorMsg: nil,
ConfidentialityLevel: obc.ConfidentialityLevel_CONFIDENTIAL,
},
}
for i := 0; i < 20; i++ {
uuid := util.GenerateUUID()
client.NewChaincodeExecute(cis, uuid)
}
err = CloseClient(client)
if err != nil {
t.Log("Close failed")
}
}
done <- true
}()
}
for i := 0; i < n; i++ {
log.Info("Waiting")
<-done
log.Info("+1")
}
log.Info("Test Finished!")
//
}
示例2: initValidators
func initValidators() error {
// Register
conf := utils.NodeConfiguration{Type: "validator", Name: "validator"}
err := RegisterValidator(conf.Name, ksPwd, conf.GetEnrollmentID(), conf.GetEnrollmentPWD())
if err != nil {
return err
}
// Verify that a second call to Register fails
err = RegisterValidator(conf.Name, ksPwd, conf.GetEnrollmentID(), conf.GetEnrollmentPWD())
if err != nil {
return err
}
// Init
validator, err = InitValidator(conf.Name, ksPwd)
if err != nil {
return err
}
err = RegisterValidator(conf.Name, ksPwd, conf.GetEnrollmentID(), conf.GetEnrollmentPWD())
if err != nil {
return err
}
return err
}
示例3: initClients
func initClients() error {
// Deployer
deployerConf := utils.NodeConfiguration{Type: "client", Name: "user1"}
if err := RegisterClient(deployerConf.Name, ksPwd, deployerConf.GetEnrollmentID(), deployerConf.GetEnrollmentPWD()); err != nil {
return err
}
var err error
deployer, err = InitClient(deployerConf.Name, ksPwd)
if err != nil {
return err
}
// Invoker
invokerConf := utils.NodeConfiguration{Type: "client", Name: "user2"}
if err := RegisterClient(invokerConf.Name, ksPwd, invokerConf.GetEnrollmentID(), invokerConf.GetEnrollmentPWD()); err != nil {
return err
}
invoker, err = InitClient(invokerConf.Name, ksPwd)
if err != nil {
return err
}
return nil
}
示例4: TestRegistrationSameEnrollIDDifferentRole
func TestRegistrationSameEnrollIDDifferentRole(t *testing.T) {
conf := utils.NodeConfiguration{Type: "client", Name: "TestRegistrationSameEnrollIDDifferentRole"}
if err := RegisterClient(conf.Name, nil, conf.GetEnrollmentID(), conf.GetEnrollmentPWD()); err != nil {
t.Fatalf("Failed client registration [%s]", err)
}
if err := RegisterValidator(conf.Name, nil, conf.GetEnrollmentID(), conf.GetEnrollmentPWD()); err == nil {
t.Fatal("Reusing the same enrollment id must be forbidden", err)
}
if err := RegisterPeer(conf.Name, nil, conf.GetEnrollmentID(), conf.GetEnrollmentPWD()); err == nil {
t.Fatal("Reusing the same enrollment id must be forbidden", err)
}
}