From ffad432e5b7092a4f3930540d149c715571bec21 Mon Sep 17 00:00:00 2001 From: Dorian Date: Fri, 13 Mar 2026 10:10:15 +0000 Subject: [PATCH] =?UTF-8?q?test:=2010-round=20double=20timeout=20simulatio?= =?UTF-8?q?n=20=E2=80=94=20draw,=20equal=20HP,=20no=20loops?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simulates both bots timing out every round for 10 rounds. Verifies zero damage per round, HP unchanged at 200, draw outcome. Co-Authored-By: Claude Opus 4.6 --- server/src/engine/edge-cases.test.ts | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/server/src/engine/edge-cases.test.ts b/server/src/engine/edge-cases.test.ts index cd924f1..194d1e7 100644 --- a/server/src/engine/edge-cases.test.ts +++ b/server/src/engine/edge-cases.test.ts @@ -242,3 +242,36 @@ describe('challenge type rotation', () => { expect(usedTypes.has(remaining.type)).toBe(false) }) }) + +describe('10-round double timeout simulation', () => { + it('both bots timeout every round: fight ends as draw, equal HP, no infinite loop', () => { + const STARTING_HP = 200 + const MAX_ROUNDS = 10 + let hpA = STARTING_HP + let hpB = STARTING_HP + let winnerId: string | null = null + + for (let round = 1; round <= MAX_ROUNDS; round++) { + const ch = makeChallenge() + const result = scoreRound( + ch, botA, botB, + resp(null, 8000, { timedOut: true }), + resp(null, 8000, { timedOut: true }), + null, 0, 0, + ) + // Both timeout → zero damage, zero scores, no winner + expect(result.winnerId).toBeNull() + expect(result.botADamage).toBe(0) + expect(result.botBDamage).toBe(0) + hpA -= result.botBDamage // damage TO A = B's damage output + hpB -= result.botADamage // damage TO B = A's damage output + } + + // After 10 rounds of double timeout: HP unchanged, draw + expect(hpA).toBe(STARTING_HP) + expect(hpB).toBe(STARTING_HP) + // Determine winner: equal HP → null (draw) + winnerId = hpA > hpB ? 'a1' : hpB > hpA ? 'b1' : null + expect(winnerId).toBeNull() + }) +})