fix(multiplayer): reconcile authoritative initial connections

This commit is contained in:
Josh Creek
2026-09-03 00:02:04 +01:00
parent 781cbc35aa
commit aa446cfbfe
40 changed files with 809 additions and 87 deletions
+10 -1
View File
@@ -11,7 +11,7 @@ import (
func testRoster(now time.Time) []JoinAuthorisation {
roster := make([]JoinAuthorisation, 6)
for i := range roster {
roster[i] = JoinAuthorisation{MatchID: "match-1", ServerID: "server-1", Protocol: "v1", PlayerID: string(rune('a' + i)), SteamID: string(rune('A' + i)), Slot: i, Team: i % 2, Generation: 1, ExpiresAt: now.Add(time.Hour)}
roster[i] = JoinAuthorisation{MatchID: "match-1", ServerID: "server-1", Protocol: "v1", PlayerID: string(rune('a' + i)), SteamID: string(rune('A' + i)), Slot: i, Team: i / 3, Generation: 1, ExpiresAt: now.Add(time.Hour)}
}
return roster
}
@@ -76,6 +76,15 @@ func TestRankedRosterRejectsDuplicateSlots(t *testing.T) {
}
}
func TestRankedRosterRejectsTeamSlotMismatch(t *testing.T) {
now := time.Unix(1000, 0)
roster := testRoster(now)
roster[3].Team = 0
if _, err := NewRankedConnections("match-1", "server-1", "v1", roster); !errors.Is(err, ErrJoinAuthorisation) {
t.Fatalf("team/slot mismatch accepted: %v", err)
}
}
func TestRankedAbandonCooldownUsesRollingSevenDayLadder(t *testing.T) {
now := time.Unix(1000, 0)
r, err := NewRankedConnections("match-1", "server-1", "v1", testRoster(now))