当前位置: 首页>>代码示例>>Golang>>正文


Golang NodeConfiguration.GetEnrollmentID方法代码示例

本文整理汇总了Golang中github.com/openblockchain/obc-peer/openchain/crypto/utils.NodeConfiguration.GetEnrollmentID方法的典型用法代码示例。如果您正苦于以下问题:Golang NodeConfiguration.GetEnrollmentID方法的具体用法?Golang NodeConfiguration.GetEnrollmentID怎么用?Golang NodeConfiguration.GetEnrollmentID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/openblockchain/obc-peer/openchain/crypto/utils.NodeConfiguration的用法示例。


在下文中一共展示了NodeConfiguration.GetEnrollmentID方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)

	go func() {
		for i := 0; i < 5; i++ {
			client, err := InitClient(conf.Name, nil)
			if err != nil {
				t.Log("Init failed")
			}
			time.Sleep(1 * time.Second)
			err = CloseClient(client)
			if err != nil {
				t.Log("Close failed")
			}
		}
		done <- true

	}()
	go func() {
		for i := 0; i < 5; i++ {
			client, err := InitClient(conf.Name, nil)
			if err != nil {
				t.Log("Init failed")
			}
			time.Sleep(2 * time.Second)
			err = CloseClient(client)
			if err != nil {
				t.Log("Close failed")
			}
		}
		done <- true

	}()
	go func() {
		for i := 0; i < 5; i++ {
			client, err := InitClient(conf.Name, nil)
			if err != nil {
				t.Log("Init failed")
			}
			time.Sleep(1 * time.Second)
			err = CloseClient(client)
			if err != nil {
				t.Log("Close failed")
			}
		}
		done <- true

	}()

	for i := 0; i < 3; i++ {
		t.Log("Waiting")
		<-done
		t.Log("+1")
	}
	//
}
开发者ID:butine,项目名称:research,代码行数:60,代码来源:crypto_test.go

示例2: 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!")
	//
}
开发者ID:yhjohn163,项目名称:obc-peer,代码行数:46,代码来源:crypto_test.go

示例3: 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
}
开发者ID:tenc,项目名称:obc-peer-pre-public,代码行数:27,代码来源:crypto_test.go

示例4: initPeers

func initPeers() error {
	// Register
	conf := utils.NodeConfiguration{Type: "peer", Name: "peer"}
	err := RegisterPeer(conf.Name, nil, conf.GetEnrollmentID(), conf.GetEnrollmentPWD())
	if err != nil {
		return err
	}

	// Verify that a second call to Register fails
	err = RegisterPeer(conf.Name, nil, conf.GetEnrollmentID(), conf.GetEnrollmentPWD())
	if err != nil {
		return err
	}

	// Init
	peer, err = InitPeer(conf.Name, nil)
	if err != nil {
		return err
	}

	err = RegisterPeer(conf.Name, nil, conf.GetEnrollmentID(), conf.GetEnrollmentPWD())
	if err != nil {
		return err
	}

	return err
}
开发者ID:masterDev1985,项目名称:obc-peer,代码行数:27,代码来源:crypto_test.go

示例5: 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
}
开发者ID:tenc,项目名称:obc-peer-pre-public,代码行数:24,代码来源:crypto_test.go

示例6: 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.Fatalf("Reusing the same enrollment id must be forbidden", err)
	}

	if err := RegisterPeer(conf.Name, nil, conf.GetEnrollmentID(), conf.GetEnrollmentPWD()); err == nil {
		t.Fatalf("Reusing the same enrollment id must be forbidden", err)
	}
}
开发者ID:tenc,项目名称:obc-peer-pre-public,代码行数:14,代码来源:crypto_test.go


注:本文中的github.com/openblockchain/obc-peer/openchain/crypto/utils.NodeConfiguration.GetEnrollmentID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。