當前位置: 首頁>>代碼示例>>Golang>>正文


Golang config.SetupTestConfig函數代碼示例

本文整理匯總了Golang中github.com/hyperledger/fabric/core/config.SetupTestConfig函數的典型用法代碼示例。如果您正苦於以下問題:Golang SetupTestConfig函數的具體用法?Golang SetupTestConfig怎麽用?Golang SetupTestConfig使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了SetupTestConfig函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestMain

func TestMain(m *testing.M) {
	config.SetupTestConfig("./../../peer")
	viper.Set("ledger.blockchain.deploy-system-chaincode", "false")

	tmpConn, err := NewPeerClientConnection()
	if err != nil {
		fmt.Printf("error connection to server at host:port = %s\n", viper.GetString("peer.address"))
		os.Exit(1)
	}
	peerClientConn = tmpConn
	os.Exit(m.Run())
}
開發者ID:Colearo,項目名稱:fabric,代碼行數:12,代碼來源:peer_test.go

示例2: TestHostConfig

func TestHostConfig(t *testing.T) {
	config.SetupTestConfig("./../../../peer")
	var hostConfig = new(docker.HostConfig)
	err := viper.UnmarshalKey("vm.docker.hostConfig", hostConfig)
	if err != nil {
		t.Fatalf("Load docker HostConfig wrong, error: %s", err.Error())
	}
	testutil.AssertNotEquals(t, hostConfig.LogConfig, nil)
	testutil.AssertEquals(t, hostConfig.LogConfig.Type, "json-file")
	testutil.AssertEquals(t, hostConfig.LogConfig.Config["max-size"], "50m")
	testutil.AssertEquals(t, hostConfig.LogConfig.Config["max-file"], "5")
}
開發者ID:celder628,項目名稱:fabric,代碼行數:12,代碼來源:dockercontroller_test.go

示例3: TestGetDockerHostConfig

func TestGetDockerHostConfig(t *testing.T) {
	os.Setenv("HYPERLEDGER_VM_DOCKER_HOSTCONFIG_NETWORKMODE", "overlay")
	os.Setenv("HYPERLEDGER_VM_DOCKER_HOSTCONFIG_CPUSHARES", fmt.Sprint(1024*1024*1024*2))
	config.SetupTestConfig("./../../../peer")
	hostConfig := getDockerHostConfig()
	testutil.AssertNotNil(t, hostConfig)
	testutil.AssertEquals(t, hostConfig.NetworkMode, "overlay")
	testutil.AssertEquals(t, hostConfig.LogConfig.Type, "json-file")
	testutil.AssertEquals(t, hostConfig.LogConfig.Config["max-size"], "50m")
	testutil.AssertEquals(t, hostConfig.LogConfig.Config["max-file"], "5")
	testutil.AssertEquals(t, hostConfig.Memory, int64(1024*1024*1024*2))
	testutil.AssertEquals(t, hostConfig.CPUShares, int64(1024*1024*1024*2))
}
開發者ID:celder628,項目名稱:fabric,代碼行數:13,代碼來源:dockercontroller_test.go

示例4: TestConnection_Correct

func TestConnection_Correct(t *testing.T) {
	config.SetupTestConfig("./../../peer")
	viper.Set("ledger.blockchain.deploy-system-chaincode", "false")
	var tmpConn *grpc.ClientConn
	var err error
	if TLSEnabled() {
		tmpConn, err = NewClientConnectionWithAddress(viper.GetString("peer.address"), true, true, InitTLSForPeer())
	}
	tmpConn, err = NewClientConnectionWithAddress(viper.GetString("peer.address"), true, false, nil)
	if err != nil {
		t.Fatalf("error connection to server at host:port = %s\n", viper.GetString("peer.address"))
	}

	tmpConn.Close()
}
開發者ID:C0rWin,項目名稱:fabric,代碼行數:15,代碼來源:connection_test.go

示例5: TestConnection_WrongAddress

func TestConnection_WrongAddress(t *testing.T) {
	config.SetupTestConfig("./../../peer")
	viper.Set("ledger.blockchain.deploy-system-chaincode", "false")
	viper.Set("peer.address", "0.0.0.0:30304")
	var tmpConn *grpc.ClientConn
	var err error
	if TLSEnabled() {
		tmpConn, err = NewClientConnectionWithAddress(viper.GetString("peer.address"), true, true, InitTLSForPeer())
	}
	tmpConn, err = NewClientConnectionWithAddress(viper.GetString("peer.address"), true, false, nil)
	if err == nil {
		fmt.Printf("error connection to server -  at host:port = %s\n", viper.GetString("peer.address"))
		t.Error("error connection to server - connection should fail")
		tmpConn.Close()
	}
}
開發者ID:C0rWin,項目名稱:fabric,代碼行數:16,代碼來源:connection_test.go

示例6: initPeerClient

func initPeerClient() (err error) {
	config.SetupTestConfig(".")
	viper.Set("ledger.blockchain.deploy-system-chaincode", "false")
	viper.Set("peer.validator.validity-period.verification", "false")

	peerClientConn, err = peer.NewPeerClientConnection()
	if err != nil {
		fmt.Printf("error connection to server at host:port = %s\n", viper.GetString("peer.address"))
		return
	}
	serverClient = pb.NewPeerClient(peerClientConn)

	// Logging
	var formatter = logging.MustStringFormatter(
		`%{color}[%{module}] %{shortfunc} [%{shortfile}] -> %{level:.4s} %{id:03x}%{color:reset} %{message}`,
	)
	logging.SetFormatter(formatter)

	return
}
開發者ID:yoshiharay,項目名稱:fabric,代碼行數:20,代碼來源:app_internal.go

示例7: TestMain

func TestMain(m *testing.M) {
	config.SetupTestConfig("../../../../../peer")
	os.Exit(m.Run())
}
開發者ID:yoshiharay,項目名稱:fabric,代碼行數:4,代碼來源:car_test.go


注:本文中的github.com/hyperledger/fabric/core/config.SetupTestConfig函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。