pre cw with probe and a bunch script to read game behavior
This commit is contained in:
1 parent
5120219ae2
commit
da8a32f60d
310 files changed
+219693
-872
No files matched your search
@@ -10,17 +10,17 @@ import (
|
||||
// deployment defaults. These tests must never bind sockets or start servers.
|
||||
func TestRuntimeConfigOverrides(t *testing.T) {
|
||||
t.Chdir(t.TempDir())
|
||||
for _, name := range []string{"GAC_CONFIG", "GAC_CLIENT_VERSION", "GAC_GAME_HOST", "GAC_GAME_PORT", "GAC_SDK_HOST", "GAC_SDK_PORT", "GAC_PUBLIC_GAME_HOST", "GAC_PUBLIC_SDK_URL"} {
|
||||
for _, name := range []string{"GAC_CONFIG", "GAC_ACCOUNT_NAME", "GAC_PLAYER_UID", "GAC_ACTIVITY_BEGIN_TIME", "GAC_ACTIVITY_END_TIME", "GAC_CLIENT_VERSION", "GAC_GAME_HOST", "GAC_GAME_PORT", "GAC_SDK_HOST", "GAC_SDK_PORT", "GAC_PUBLIC_GAME_HOST", "GAC_PUBLIC_SDK_URL", "GAC_LIVE_BATTLE_STALE_SECONDS"} {
|
||||
t.Setenv(name, "")
|
||||
if err := os.Unsetenv(name); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
base := `{"client_version":"fixture","game_host":"localhost","game_port":32101,"sdk_host":"localhost","sdk_port":32102,"public_game_host":"example.invalid","public_sdk_url":"https://example.invalid/base/"}`
|
||||
base := `{"account_name":"base-player","player_uid":10001,"activity_schedule":{"begin_time":0,"end_time":100},"srtool":{"lease_file":"fixture-session.json","lease_seconds":30},"battle_diagnostics":{"live_report_stale_seconds":10},"client_version":"fixture","game_host":"localhost","game_port":32101,"sdk_host":"localhost","sdk_port":32102,"public_game_host":"example.invalid","public_sdk_url":"https://example.invalid/base/"}`
|
||||
if err := os.WriteFile("server.json", []byte(base), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
local := append([]byte{0xef, 0xbb, 0xbf}, []byte(`{"game_port":32201,"launcher":{"client_path":"fixture"}}`)...)
|
||||
local := append([]byte{0xef, 0xbb, 0xbf}, []byte(`{"account_name":"local-player","player_uid":10002,"game_port":32201,"launcher":{"client_path":"fixture"}}`)...)
|
||||
if err := os.WriteFile("server.local.json", local, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -28,18 +28,33 @@ func TestRuntimeConfigOverrides(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.GamePort != 32201 || cfg.SDKPort != 32102 || cfg.PublicSDKURL != "https://example.invalid/base" {
|
||||
if cfg.AccountName != "local-player" || cfg.PlayerUID != 10002 || cfg.GamePort != 32201 || cfg.SDKPort != 32102 || cfg.PublicSDKURL != "https://example.invalid/base" || cfg.BattleDiagnostics.LiveReportStaleSeconds != 10 {
|
||||
t.Fatalf("merge failed: %+v", cfg)
|
||||
}
|
||||
t.Setenv("GAC_GAME_PORT", "32301")
|
||||
t.Setenv("GAC_ACCOUNT_NAME", "environment-player")
|
||||
t.Setenv("GAC_PLAYER_UID", "10003")
|
||||
t.Setenv("GAC_PUBLIC_GAME_HOST", "gateway.example.invalid")
|
||||
t.Setenv("GAC_LIVE_BATTLE_STALE_SECONDS", "15")
|
||||
cfg, err = LoadRuntimeConfig()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.GamePort != 32301 || cfg.PublicGameHost != "gateway.example.invalid" {
|
||||
if cfg.AccountName != "environment-player" || cfg.PlayerUID != 10003 || cfg.GamePort != 32301 || cfg.PublicGameHost != "gateway.example.invalid" || cfg.BattleDiagnostics.LiveReportStaleSeconds != 15 {
|
||||
t.Fatalf("environment override failed: %+v", cfg)
|
||||
}
|
||||
for _, value := range []string{"0", "-1", "4294967296", "invalid", ""} {
|
||||
t.Setenv("GAC_PLAYER_UID", value)
|
||||
if _, err := LoadRuntimeConfig(); err == nil {
|
||||
t.Fatalf("invalid UID %q accepted", value)
|
||||
}
|
||||
}
|
||||
t.Setenv("GAC_PLAYER_UID", "10003")
|
||||
t.Setenv("GAC_ACCOUNT_NAME", " ")
|
||||
if _, err := LoadRuntimeConfig(); err == nil {
|
||||
t.Fatal("blank account name accepted")
|
||||
}
|
||||
t.Setenv("GAC_ACCOUNT_NAME", "environment-player")
|
||||
t.Setenv("GAC_GAME_PORT", "65536")
|
||||
if _, err := LoadRuntimeConfig(); err == nil {
|
||||
t.Fatal("out-of-range port accepted")
|
||||
@@ -48,6 +63,13 @@ func TestRuntimeConfigOverrides(t *testing.T) {
|
||||
if _, err := LoadRuntimeConfig(); err == nil {
|
||||
t.Fatal("zero port accepted")
|
||||
}
|
||||
t.Setenv("GAC_GAME_PORT", "32301")
|
||||
for _, value := range []string{"0", "-1", "65536", "invalid"} {
|
||||
t.Setenv("GAC_LIVE_BATTLE_STALE_SECONDS", value)
|
||||
if _, err := LoadRuntimeConfig(); err == nil {
|
||||
t.Fatalf("invalid live battle stale interval %q accepted", value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeConfigRequiresFile(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user