mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
fix(multiplayer): fence recovered arena identity
This commit is contained in:
@@ -105,6 +105,18 @@ func TestWorkerRejectsRecoveredAllocationForDifferentCompatibility(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkerRejectsRecoveredAllocationForDifferentArena(t *testing.T) {
|
||||
request := domain.AllocationRequest{AllocationID: "allocation-1", MatchID: "match-1", ArenaPath: "res://scenes/arena_01.tscn", Region: "EU", Build: "build-1", Protocol: 1, Transport: "enet"}
|
||||
claims := &matchClaimSpy{request: request, found: true}
|
||||
provider := &recoverableProviderSpy{recovered: agones.AllocatedServer{Allocation: domain.Allocation{AllocationID: request.AllocationID, MatchID: request.MatchID, ServerID: "server-1", ArenaPath: "res://scenes/arena_02.tscn", Region: request.Region, Build: request.Build, Protocol: request.Protocol, Transport: request.Transport, State: domain.ServerAllocated}, Endpoint: "127.0.0.1:31001"}, found: true}
|
||||
durable := &durableSpy{}
|
||||
worker := Worker{Claims: claims, Service: Service{Provider: provider, Durable: durable, Now: func() time.Time { return time.Unix(1_000, 0) }}, Now: func() time.Time { return time.Unix(1_000, 0) }}
|
||||
processed, err := worker.RunOnce(context.Background())
|
||||
if err == nil || !processed || durable.calls != 0 || claims.bound != (domain.Allocation{}) {
|
||||
t.Fatalf("processed=%t err=%v durable_calls=%d bound=%+v", processed, err, durable.calls, claims.bound)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkerDoesNothingWhenNoDurableMatchIsAvailable(t *testing.T) {
|
||||
claims := &matchClaimSpy{}
|
||||
worker := Worker{Claims: claims, Now: func() time.Time { return time.Unix(1_000, 0) }}
|
||||
|
||||
Reference in New Issue
Block a user