本文整理匯總了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())
}