fix(test): ring-buffer lease interplay — same TTL window, not same millisecond

Two back-to-back mintLease() calls each stamp Date.now() + TTL; when they
straddle a millisecond boundary the exact-equality assertion flakes
(observed in CI: expiries of ...525 vs ...526). Assert the expiries are
within a 50 ms window instead — the invariant under test is that leases
share a TTL policy, not that they mint in the same clock tick.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan 2026-08-15 09:19:26 -07:00
parent c394e4836a
commit 970d68a704
No known key found for this signature in database
GPG Key ID: C1F69E85C74EFE1D
1 changed files with 4 additions and 1 deletions

View File

@ -148,7 +148,10 @@ describe('lease lifecycle interplay (via pty-session-lease)', () => {
const vb = validateLease(b.sessionId); const vb = validateLease(b.sessionId);
expect(va.ok && vb.ok).toBe(true); expect(va.ok && vb.ok).toBe(true);
if (va.ok && vb.ok) { if (va.ok && vb.ok) {
expect(va.expiresAt).toBe(vb.expiresAt); // Same TTL window, not same millisecond: each mint stamps
// Date.now() + TTL, and back-to-back calls can straddle a ms boundary
// (observed in CI: ...525 vs ...526). Exact equality is a timing flake.
expect(Math.abs(va.expiresAt - vb.expiresAt)).toBeLessThanOrEqual(50);
} }
}); });
}); });