mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-16 20:12:03 +00:00
test(multiplayer): cover cooldown response boundary
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmic-clash/cosmic-clash/server/domain"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCooldownDomainErrorIsRetryableButNotAConflict(t *testing.T) {
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
writeDomainError(recorder, domain.ErrPlayerCooldown)
|
||||||
|
if recorder.Code != http.StatusTooManyRequests {
|
||||||
|
t.Fatalf("cooldown status = %d, want 429", recorder.Code)
|
||||||
|
}
|
||||||
|
if !strings.Contains(recorder.Body.String(), "matchmaking_cooldown") {
|
||||||
|
t.Fatalf("cooldown response = %q", recorder.Body.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -116,15 +116,10 @@ SET state = 'DECLINED', revision = revision + 1
|
|||||||
WHERE proposal_id = $1 AND state = 'OPEN'`
|
WHERE proposal_id = $1 AND state = 'OPEN'`
|
||||||
|
|
||||||
// ProposalDeclineRequeueSQL requeues every participant's ticket, including
|
// ProposalDeclineRequeueSQL requeues every participant's ticket, including
|
||||||
// the decliner's own: nothing yet enforces the decline cooldown §8.17
|
// the decliner's own. The durable decline penalty separately prevents that
|
||||||
// documents as a separate, not-yet-built feature, so leaving any ticket
|
// player from immediately creating a replacement ticket; leaving this ticket
|
||||||
// behind at PROPOSED here isn't "cooldown behaviour", it's just a stranded
|
// at PROPOSED would not implement a cooldown, it would strand the player and
|
||||||
// ticket -- invisible to the matcher (which only ever reads state='QUEUED'),
|
// hide the ticket from the matcher.
|
||||||
// still counted as this player's one active ticket (blocking a fresh
|
|
||||||
// queue_create), and renewable forever by an ordinary heartbeat, so a player
|
|
||||||
// left in this state has no path back into matchmaking without realising
|
|
||||||
// they need to cancel and start over. Once §8.17's cooldown exists, it can
|
|
||||||
// exempt the decliner from this immediate requeue; today nothing does.
|
|
||||||
const ProposalDeclineRequeueSQL = `UPDATE queue_tickets q
|
const ProposalDeclineRequeueSQL = `UPDATE queue_tickets q
|
||||||
SET state = 'QUEUED', expires_at = $2, revision = revision + 1
|
SET state = 'QUEUED', expires_at = $2, revision = revision + 1
|
||||||
FROM proposal_participants pp
|
FROM proposal_participants pp
|
||||||
|
|||||||
Reference in New Issue
Block a user