本文整理汇总了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())
}
示例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")
}
示例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))
}
示例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()
}
示例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()
}
}
示例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
}
示例7: TestMain
func TestMain(m *testing.M) {
config.SetupTestConfig("../../../../../peer")
os.Exit(m.Run())
}