Public: anyone can read this; the crew can change it.
Fast test/surfaces-adversarial.test.ts: chop and rewrite under the budget (1 s a test, 10 s a file) #12064
Check · Review · Land · Live done — Landed and live in production.
`test/surfaces-adversarial.test.ts` is now under the budget: its slowest test went from about 1.0 s to 0.47 s here, and the other N+1 tests dropped from about 0.7 s to 0.27–0.38 s. All 13 tests pass and `bun x tsc --noEmit` is clean. `bun scripts/gate.ts` printed nothing. I did not read `scripts/test-times.json` after the change, so the gate's file total is not confirmed.
shipped production is serving it deploy 2a250d0
test/surfaces-adversarial.test.ts is now under the budget: its slowest test went from about 1.0 s to 0.47 s here, and the other N+1 tests dropped from about 0.7 s to 0.27–0.38 s. All 13 tests pass and bun x tsc --noEmit is clean. bun scripts/gate.ts printed nothing. I did not read scripts/test-times.json after the change, so the gate's file total is not confirmed.
- Where the time went: each N+1 test hashed passwords with argon2 for the users it created and again when signing them in. The
statementshelper then measured five times per count, waiting for quiet each time. - What changed: the N+1 tests now create passwordless seeded users and sign them in with a session row via
createSession, so nothing is hashed. They measure twice per count instead of five times. The helper itself is untouched. Two runs still catch a real N+1, because that costs more in every run. - Invariant lines: each of the five N+1 tests now has its invariant written as a one-line comment at the top.
- Removed: the unused
signUpandloginAshelpers, and the straysignUpcall that was only there to reuse a cookie shape. - Not done: no test was deleted, since each proves a different listing's query count. I did not split the file or move anything to
NIGHTLY. The issue says the file has aSLOWentry inscripts/gate.ts, but none exists on this branch, so there was nothing to remove. I did not change the gate. - To try:
bun test test/surfaces-adversarial.test.ts.
Test-only change, within the direction (#1242 time budget per test and file). Passwordless users plus createSession rows remove the argon2 cost, the statements helper accepts the runs argument (verified in test/helpers/statements.ts), and a real N+1 still shows in 2 runs. No dependency, no README change, no src/web touched. Two things to do next: (1) confirm the file total in scripts/test-times.json is under 10 s, which the pull did not check. (2) Tidy the double blank line left where loginAs was removed, and the repeated "Users here are passwordless..." sentence in five invariant comments; say it once at sessionFor.
test/surfaces-adversarial.test.tsis now under the budget: its slowest test went from about 1.0 s to 0.47 s here, and the other N+1 tests dropped from about 0.7 s to 0.27–0.38 s. All 13 tests pass andbun x tsc --noEmitis clean.bun scripts/gate.tsprinted nothing. I did not readscripts/test-times.jsonafter the change, so the gate's file total is not confirmed.statementshelper then measured five times per count, waiting for quiet each time.createSession, so nothing is hashed. They measure twice per count instead of five times. The helper itself is untouched. Two runs still catch a real N+1, because that costs more in every run.signUpandloginAshelpers, and the straysignUpcall that was only there to reuse a cookie shape.NIGHTLY. The issue says the file has aSLOWentry inscripts/gate.ts, but none exists on this branch, so there was nothing to remove. I did not change the gate.bun test test/surfaces-adversarial.test.ts.Closes #1338