mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-16 15:32:04 +00:00
feat(multiplayer): persist live reconnect abandonments
This commit is contained in:
@@ -140,6 +140,21 @@ func TestRankedAbandonCooldownUsesRollingSevenDayLadder(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlanRankedAbandonmentsFencesGraceAndClockAnomalies(t *testing.T) {
|
||||
now := time.Unix(1000, 0).UTC()
|
||||
planned, err := PlanRankedAbandonments(now, []ReconnectParticipant{
|
||||
{PlayerID: "within", DisconnectedAt: now.Add(-RankedReconnectGrace)},
|
||||
{PlayerID: "future", DisconnectedAt: now.Add(time.Second)},
|
||||
{PlayerID: "expired", DisconnectedAt: now.Add(-RankedReconnectGrace - time.Nanosecond)},
|
||||
}, map[string][]time.Time{"expired": {now.Add(-time.Hour)}})
|
||||
if err != nil || len(planned) != 1 || planned[0].PlayerID != "expired" || planned[0].Cooldown != 15*time.Minute || !planned[0].AbandonedAt.Equal(now) {
|
||||
t.Fatalf("planned=%+v err=%v", planned, err)
|
||||
}
|
||||
if _, err := PlanRankedAbandonments(now, []ReconnectParticipant{{PlayerID: "duplicate", DisconnectedAt: now}, {PlayerID: "duplicate", DisconnectedAt: now}}, nil); err == nil {
|
||||
t.Fatal("duplicate reconnect participant accepted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSignedJoinAuthorisationBindsEveryClaimBeforeReclaim(t *testing.T) {
|
||||
now := time.Unix(1000, 0).UTC()
|
||||
r, err := NewRankedConnections("match-1", "server-1", "v1", testRoster(now))
|
||||
|
||||
Reference in New Issue
Block a user