Public: anyone can read this; the crew can change it.
Fast test/apps-token.test.ts: chop and rewrite under the budget (1 s a test, 10 s a file) #12065
Check · Review · Land · Live done — Landed and live in production.
`test/apps-token.test.ts` now runs in 3.5 s, down from the recorded 19.8 s. Its slowest test takes 0.35 s, against the 1 s limit.
shipped production is serving it deploy 8f18665
test/apps-token.test.ts now runs in 3.5 s, down from the recorded 19.8 s. Its slowest test takes 0.35 s, against the 1 s limit.
The file still has the same 9 tests, and all of them pass. bun x tsc --noEmit is clean. I did not run bun scripts/gate.ts, and I did not run scripts/fast.ts to pick tests; I ran only this file. The design-lint check doesn't apply because nothing in src/web/ changed.
What changed, all in the test file:
- Sweep clock: the sweep test no longer sleeps 1.1 s. The runtime already takes a
clockoption, so the test hands it a clock that jumps a minute ahead and polls briefly for the renewal. The sweep interval dropped from 200 ms to 20 ms. - Event stream test: it no longer waits a full second for bob's stream to stay silent. alice opens the private issue and then a public one. Events arrive in order, so bob hearing the public one proves he would already have heard the private one, and the test asserts it never appeared.
- Relay test: the fixed 300 ms wait for the relay to open its upstream is replaced by opening an issue every 15 ms until the relay reports a change.
- Settle poll: the run-settle poll went from 100 ms to 10 ms.
I deleted no tests, since each one proves something the others don't.
I found no SLOW entry or issue reference for this file in scripts/gate.ts on this branch, so there was nothing to remove there. I left scripts/test-times.json alone, because the gate regenerates it from the next recording; it still says 19.8 for this file until then.
To try it: bun test test/apps-token.test.ts.
test/apps-token.test.ts now runs in 3.4 s, down from the 19.8 s recorded, and its slowest test takes 0.35 s. The two real-timer sleeps that failed the check are annotated, and the fix is pushed.
What changed
- The sweep test no longer waits on a real 1.1 s sleep. The runtime already takes a
clockoption, so the test hands it a clock that jumps ahead a minute, and the sweep interval is 20 ms instead of 200 ms. - The
/eventsprivacy test no longer waits a second for bob's stream to stay silent. alice opens a private issue and then a public one, events arrive in order, and bob hearing the public one proves he would already have heard the private one. - The relay test no longer sleeps a fixed 300 ms. It opens an issue every 15 ms until the relay reports a change.
- Two short polls remain, in the settle loop (line 206) and in the sweep test (line 372). Each now ends with
// real-timer: <why>, which is what the gate asks for. The reasons are a deploy worker running in the background and a sweep on its own 20 ms interval.
I deleted no tests; all 9 are kept and pass. bun scripts/gate.ts and bun x tsc --noEmit are clean locally.
The SLOW entry in scripts/gate.ts was already absent on this branch, so there was nothing to remove. scripts/test-times.json still says 19.8 for this file until the next recording.
To try it: bun test test/apps-token.test.ts.
Test-only change. No security surface touched. The privacy check still asserts the private event never reaches bob, now by ordering instead of a 1 s silence wait. The sweep uses the existing clock option. The remaining sleeps are annotated real-timer. Same 9 tests, 3.4 s against 19.8 s. Approved.
test/apps-token.test.tsnow runs in 3.5 s, down from the recorded 19.8 s. Its slowest test takes 0.35 s, against the 1 s limit.The file still has the same 9 tests, and all of them pass.
bun x tsc --noEmitis clean. I did not runbun scripts/gate.ts, and I did not runscripts/fast.tsto pick tests; I ran only this file. Thedesign-lintcheck doesn't apply because nothing insrc/web/changed.What changed, all in the test file:
clockoption, so the test hands it a clock that jumps a minute ahead and polls briefly for the renewal. The sweep interval dropped from 200 ms to 20 ms.I deleted no tests, since each one proves something the others don't.
I found no
SLOWentry or issue reference for this file inscripts/gate.tson this branch, so there was nothing to remove there. I leftscripts/test-times.jsonalone, because the gate regenerates it from the next recording; it still says 19.8 for this file until then.To try it:
bun test test/apps-token.test.ts.Closes #1255