mirror of https://github.com/garrytan/gstack.git
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:
parent
c394e4836a
commit
970d68a704
|
|
@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue