mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-14 02:02:04 +00:00
fix: bind queue idempotency to compatibility
This commit is contained in:
@@ -218,5 +218,5 @@ func createPayload(playerID, ticketID string, candidate Candidate) string {
|
||||
for _, region := range regions {
|
||||
rtts = append(rtts, fmt.Sprintf("%s=%.9f", region, candidate.PredictedRTT[region]))
|
||||
}
|
||||
return strings.Join([]string{playerID, ticketID, candidate.PlayerID, candidate.TicketID, fmt.Sprintf("%.9f", candidate.Rating), candidate.EnqueuedAt.UTC().Format(time.RFC3339Nano), strings.Join(rtts, ",")}, "\x00")
|
||||
return strings.Join([]string{playerID, ticketID, candidate.PlayerID, candidate.TicketID, string(candidate.Playlist), candidate.ClientBuild, fmt.Sprintf("%d", candidate.ProtocolVersion), fmt.Sprintf("%.9f", candidate.Rating), candidate.EnqueuedAt.UTC().Format(time.RFC3339Nano), strings.Join(rtts, ",")}, "\x00")
|
||||
}
|
||||
|
||||
@@ -77,6 +77,21 @@ func TestQueueCreateIdempotencyIncludesCandidatePayload(t *testing.T) {
|
||||
if _, err := q.Create("player-a", "ticket-a", "create-key-123456", changed, now); !errors.Is(err, ErrConflict) {
|
||||
t.Fatalf("changed create payload error = %v", err)
|
||||
}
|
||||
changed = base
|
||||
changed.Playlist = Ranked
|
||||
if _, err := q.Create("player-a", "ticket-a", "create-key-123456", changed, now); !errors.Is(err, ErrConflict) {
|
||||
t.Fatalf("changed playlist payload error = %v", err)
|
||||
}
|
||||
changed = base
|
||||
changed.ClientBuild = "build-2"
|
||||
if _, err := q.Create("player-a", "ticket-a", "create-key-123456", changed, now); !errors.Is(err, ErrConflict) {
|
||||
t.Fatalf("changed build payload error = %v", err)
|
||||
}
|
||||
changed = base
|
||||
changed.ProtocolVersion = 2
|
||||
if _, err := q.Create("player-a", "ticket-a", "create-key-123456", changed, now); !errors.Is(err, ErrConflict) {
|
||||
t.Fatalf("changed protocol payload error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestQueueCreateRejectsCandidateOwnedByAnotherPlayer(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user