mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 00:14:00 +00:00
fix(multiplayer): verify recovered arena annotations
This commit is contained in:
@@ -184,6 +184,18 @@ func TestRecoverAllocationRejectsMismatchedBinding(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecoverAllocationRejectsMissingRankedArenaAnnotation(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_, _ = w.Write([]byte(`{"items":[{"metadata":{"name":"gs-ranked","labels":{"cosmic-clash.io/region":"EU","cosmic-clash.io/build":"build-1","cosmic-clash.io/protocol":"1","cosmic-clash.io/transport":"enet"},"annotations":{"cosmic-clash.io/allocation-id":"allocation-1","cosmic-clash.io/match-id":"match-1"}},"status":{"state":"Allocated","address":"127.0.0.1","ports":[{"name":"default","port":31001}]}}]}`))
|
||||
}))
|
||||
defer server.Close()
|
||||
recoveryRequest := request()
|
||||
recoveryRequest.ArenaPath = "res://scenes/arena_01.tscn"
|
||||
if _, found, err := (Client{BaseURL: server.URL, Namespace: "games", HTTP: server.Client()}).RecoverAllocation(context.Background(), recoveryRequest, time.Unix(1000, 0)); err == nil || found {
|
||||
t.Fatalf("ranked recovery without arena annotation accepted: found=%t err=%v", found, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecoverAllocationRejectsDuplicateProviderMatches(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_, _ = w.Write([]byte(`{"items":[{"metadata":{"name":"gs-one","labels":{"cosmic-clash.io/region":"EU","cosmic-clash.io/build":"build-1","cosmic-clash.io/protocol":"1","cosmic-clash.io/transport":"enet"},"annotations":{"cosmic-clash.io/allocation-id":"allocation-1","cosmic-clash.io/match-id":"match-1"}},"status":{"state":"Allocated","address":"127.0.0.1","ports":[{"name":"default","port":31001}]}},{"metadata":{"name":"gs-two","labels":{"cosmic-clash.io/region":"EU","cosmic-clash.io/build":"build-1","cosmic-clash.io/protocol":"1","cosmic-clash.io/transport":"enet"},"annotations":{"cosmic-clash.io/allocation-id":"allocation-1","cosmic-clash.io/match-id":"match-1"}},"status":{"state":"Allocated","address":"127.0.0.1","ports":[{"name":"default","port":31002}]}}]}`))
|
||||
|
||||
Reference in New Issue
Block a user