fix(multiplayer): make match promotion replay lifecycle-safe

This commit is contained in:
Josh Creek
2026-09-03 00:10:57 +01:00
parent f8af212e3f
commit eaf7ea8748
4 changed files with 28 additions and 7 deletions
+7
View File
@@ -12,6 +12,7 @@ func TestAcceptedMatchSQLPreservesAtomicProposalToMatchBoundary(t *testing.T) {
AcceptedProposalLockSQL: {"FOR UPDATE", "proposal_id = $1"},
AcceptedProposalParticipantsSQL: {"response", "ORDER BY player_id", "FOR UPDATE"},
AcceptedMatchInsertSQL: {"'ALLOCATING'", "ON CONFLICT (match_id) DO NOTHING"},
AcceptedMatchSelectSQL: {"playlist", "region", "protocol_version", "arena_path", "FOR UPDATE"},
AcceptedTicketSQL: {"state = 'ACCEPTED'", "state = 'PROPOSED'", "revision = revision + 1"},
AcceptedMatchParticipantInsertSQL: {"match_participants", "slot", "team"},
}
@@ -24,6 +25,12 @@ func TestAcceptedMatchSQLPreservesAtomicProposalToMatchBoundary(t *testing.T) {
}
}
func TestAcceptedMatchReplayDoesNotDependOnMutableLifecycleFields(t *testing.T) {
if contains(AcceptedMatchSelectSQL, "state") || contains(AcceptedMatchSelectSQL, "server_id") {
t.Fatalf("accepted promotion replay is coupled to mutable lifecycle fields: %s", AcceptedMatchSelectSQL)
}
}
func TestAcceptedMatchPlanRejectsInvalidPlansBeforeDatabaseUse(t *testing.T) {
valid := AcceptedMatchPlan{
MatchID: "match-1", ProposalID: "proposal-1", Region: "EU", Protocol: 1,