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 -1
View File
@@ -252,10 +252,16 @@ func TestPostgreSQLAcceptedProposalPromotesOneAtomicAllocatingMatch(t *testing.T
if err := CreateMatchFromAcceptedProposal(ctx, db, plan, now.Add(time.Second)); err != nil {
t.Fatalf("identical match promotion replay: %v", err)
}
if _, err := db.ExecContext(ctx, `UPDATE matches SET state = 'LIVE' WHERE match_id = 'promote-match'`); err != nil {
t.Fatal(err)
}
if err := CreateMatchFromAcceptedProposal(ctx, db, plan, now.Add(2*time.Second)); err != nil {
t.Fatalf("promotion replay after match lifecycle advanced: %v", err)
}
conflict := plan
conflict.Players = append([]MatchPlayer(nil), plan.Players...)
conflict.Players[1].Slot = 4
if err := CreateMatchFromAcceptedProposal(ctx, db, conflict, now.Add(2*time.Second)); err == nil {
if err := CreateMatchFromAcceptedProposal(ctx, db, conflict, now.Add(3*time.Second)); err == nil {
t.Fatal("conflicting match promotion replay was accepted")
}
}