mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 00:14:00 +00:00
fix(multiplayer): make match promotion replay lifecycle-safe
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user