mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 08:23:45 +00:00
fix: preserve assignment event revisions
This commit is contained in:
@@ -983,3 +983,19 @@ func TestAssignmentRecoveryIsPlayerScopedAndRejectsExpiredOrMismatchedViews(t *t
|
||||
t.Fatalf("expired assignment status=%d", status)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAssignmentEventUsesAuthoritativeRevisionWithoutChangingResponseShape(t *testing.T) {
|
||||
now := time.Unix(1000, 0).UTC()
|
||||
view := AssignmentView{MatchID: "match-1", ServerID: "server-1", PlayerID: "player-a", Revision: 7}
|
||||
event := assignmentChangedEvent(view, now)
|
||||
if event.Revision != 7 || event.ResourceID != "match-1" || event.PlayerID != "player-a" {
|
||||
t.Fatalf("assignment event = %+v", event)
|
||||
}
|
||||
payload, err := json.Marshal(view)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.Contains(string(payload), "revision") {
|
||||
t.Fatalf("assignment response leaked event revision: %s", payload)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user