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()) }
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") }
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)) }
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() }
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() } }
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 }
func TestMain(m *testing.M) { config.SetupTestConfig("../../../../../peer") os.Exit(m.Run()) }