fix(multiplayer): centralize arena path validation

This commit is contained in:
Josh Creek
2026-09-01 21:18:48 +01:00
parent bfeb822279
commit 701d7a9a2e
4 changed files with 16 additions and 3 deletions
+13
View File
@@ -53,6 +53,19 @@ func TestAllocatorRejectsInvalidServerAndNoCompatibleCapacity(t *testing.T) {
}
}
func TestAllocatorRejectsUnregisteredArenaPath(t *testing.T) {
a, err := NewAllocator([]ReadyServer{{ServerID: "server-1", Region: "EU", Build: "build-1", Protocol: 1, Transport: "enet", State: ServerReady}})
if err != nil {
t.Fatal(err)
}
for _, path := range []string{"res://scenes/arena_01_elevated.tscn", "res://forged.tscn"} {
request := AllocationRequest{AllocationID: "allocation-" + path, MatchID: "match-1", Region: "EU", Build: "build-1", Protocol: 1, ArenaPath: path, Transport: "enet"}
if _, err := a.Allocate(request, time.Unix(1000, 0)); !errors.Is(err, ErrAllocationInput) {
t.Fatalf("arena path %q returned %v, want ErrAllocationInput", path, err)
}
}
}
func TestAllocatorConcurrentClaimsCannotDoubleAllocateOneServer(t *testing.T) {
a, _ := NewAllocator([]ReadyServer{{ServerID: "server-1", Region: "EU", Build: "build-1", Protocol: 1, Transport: "enet", State: ServerReady}})
requests := []AllocationRequest{