From ae9ad3c07048d46ddd7799b17c4968dca3cae382 Mon Sep 17 00:00:00 2001 From: kiranvk2011 Date: Wed, 18 Mar 2026 18:44:50 +0000 Subject: [PATCH] test: update markAuthProfileFailure tests for stepped 30s/1m/5m cooldown ladder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the auth-profiles.markauthprofilefailure test suite to match the new stepped cooldown formula (30s → 1m → 5m cap) introduced in the first commit. The test was still asserting the old exponential backoff values (1m → 5m → 25m → 1h cap). Changes: - calculateAuthProfileCooldownMs assertions: 60s→30s, 5m→1m, 25m→5m, 1h→5m cap - 'resets error count when previous cooldown has expired' test: upper bound adjusted from 120s to 60s to match 30s base cooldown - Comments updated to reflect the stepped ladder Resolves merge-blocker review from @altaywtf. --- ...uth-profiles.markauthprofilefailure.test.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/agents/auth-profiles.markauthprofilefailure.test.ts b/src/agents/auth-profiles.markauthprofilefailure.test.ts index 5c4d73197b3..af828e1ee52 100644 --- a/src/agents/auth-profiles.markauthprofilefailure.test.ts +++ b/src/agents/auth-profiles.markauthprofilefailure.test.ts @@ -230,12 +230,12 @@ describe("markAuthProfileFailure", () => { const stats = store.usageStats?.["anthropic:default"]; // Error count should reset to 1 (not escalate to 4) because the - // previous cooldown expired. Cooldown should be ~1 min, not ~60 min. + // previous cooldown expired. Cooldown should be ~30s, not ~5 min. expect(stats?.errorCount).toBe(1); expect(stats?.failureCounts?.rate_limit).toBe(1); const cooldownMs = (stats?.cooldownUntil ?? 0) - now; - // calculateAuthProfileCooldownMs(1) = 60_000 (1 minute) - expect(cooldownMs).toBeLessThan(120_000); + // calculateAuthProfileCooldownMs(1) = 30_000 (stepped: 30s → 1m → 5m) + expect(cooldownMs).toBeLessThan(60_000); expect(cooldownMs).toBeGreaterThan(0); } finally { fs.rmSync(agentDir, { recursive: true, force: true }); @@ -267,11 +267,11 @@ describe("markAuthProfileFailure", () => { }); describe("calculateAuthProfileCooldownMs", () => { - it("applies exponential backoff with a 1h cap", () => { - expect(calculateAuthProfileCooldownMs(1)).toBe(60_000); - expect(calculateAuthProfileCooldownMs(2)).toBe(5 * 60_000); - expect(calculateAuthProfileCooldownMs(3)).toBe(25 * 60_000); - expect(calculateAuthProfileCooldownMs(4)).toBe(60 * 60_000); - expect(calculateAuthProfileCooldownMs(5)).toBe(60 * 60_000); + it("applies stepped backoff with a 5-min cap", () => { + expect(calculateAuthProfileCooldownMs(1)).toBe(30_000); // 30 seconds + expect(calculateAuthProfileCooldownMs(2)).toBe(60_000); // 1 minute + expect(calculateAuthProfileCooldownMs(3)).toBe(5 * 60_000); // 5 minutes + expect(calculateAuthProfileCooldownMs(4)).toBe(5 * 60_000); // 5 minutes (cap) + expect(calculateAuthProfileCooldownMs(5)).toBe(5 * 60_000); // 5 minutes (cap) }); });