mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
fix(multiplayer): fence provider allocation results
This commit is contained in:
@@ -93,6 +93,21 @@ func TestWorkerRecoversProviderAllocationBeforeIssuingSecondAllocation(t *testin
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkerBindsCanonicalRecordedRecovery(t *testing.T) {
|
||||
now := time.Unix(1_000, 0)
|
||||
request := domain.AllocationRequest{AllocationID: "allocation-1", MatchID: "match-1", Region: "EU", Build: "build-1", Protocol: 1, Transport: "enet"}
|
||||
providerAllocation := domain.Allocation{AllocationID: request.AllocationID, MatchID: request.MatchID, ServerID: "server-recovered", Region: request.Region, Build: request.Build, Protocol: request.Protocol, Transport: request.Transport, State: domain.ServerAllocated}
|
||||
canonical := providerAllocation
|
||||
canonical.AllocatedAt = now
|
||||
claims := &matchClaimSpy{request: request, found: true}
|
||||
provider := &recoverableProviderSpy{recovered: agones.AllocatedServer{Allocation: providerAllocation, Endpoint: "127.0.0.1:31001"}, found: true}
|
||||
worker := Worker{Claims: claims, Service: Service{Provider: provider, Durable: &durableSpy{result: canonical}, Now: func() time.Time { return now }}, Now: func() time.Time { return now }}
|
||||
processed, err := worker.RunOnce(context.Background())
|
||||
if err != nil || !processed || claims.bound != canonical {
|
||||
t.Fatalf("processed=%t err=%v bound=%+v, want %+v", processed, err, claims.bound, canonical)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkerRejectsRecoveredAllocationForDifferentCompatibility(t *testing.T) {
|
||||
request := domain.AllocationRequest{AllocationID: "allocation-1", MatchID: "match-1", Region: "EU", Build: "build-1", Protocol: 1, Transport: "enet"}
|
||||
claims := &matchClaimSpy{request: request, found: true}
|
||||
|
||||
Reference in New Issue
Block a user