Skip to content

test(e2e): pre-authenticated session harness to stay under the nonce rate limit - #104

Open
douglance wants to merge 1 commit into
siwe/act-as-uifrom
siwe/e2e-harness
Open

test(e2e): pre-authenticated session harness to stay under the nonce rate limit#104
douglance wants to merge 1 commit into
siwe/act-as-uifrom
siwe/e2e-harness

Conversation

@douglance

Copy link
Copy Markdown
Contributor

Stacked on #103. Third of four.

The problem this fixes is measured, not theoretical

POST /api/auth/nonce is rate-limited to 10/min per IP, and every Playwright test shares one IP. Signing in per test does not scale — a six-test suite already failed on back-to-back runs while every test passed in isolation:

 1: 201   5: 201
 2: 201   6: 201
 3: 201   7: 201
 4: 201   8: 429  <- and sustained 429 after

So the ~30-test target was unreachable before this.

Fix, in two parts

The first part alone was not enough, which is worth knowing:

  1. A setup project signs each dev wallet in once through the real UI (still exercising nonce → verify → cookie) and saves its session cookie. Nonce spend becomes a function of wallet count, not test count — adding tests is now free.
  2. Reuse a still-valid saved session. With only (1), a run still cost 5 setup + 1 from profile.spec = 6 nonces, so two runs inside a minute still tripped the limit. Sessions last 7 days, so setup now probes /api/me and re-authenticates only on 401. Repeat runs cost zero nonces.

Result — three consecutive runs, no pause:

=== run 1 ===  11 passed (11.5s)
=== run 2 ===  11 passed (10.9s)
=== run 3 ===  11 passed (11.4s)

A useful side effect: the 401 probe makes the harness self-healing. When reset:siwe truncated sessions out from under it, setup noticed and re-authenticated on its own.

Also here

A dev-wallet allocation per spec. The SIWE tables live in one shared app schema that is not namespaced by PONDER_SCHEMA, so two specs sharing a key collide on the same owned_profile/draft rows. Key #9 is called out specifically: it has delegated all its ARB away, making it the only key that can exercise the avatar gate's 403 not_delegate branch.

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tally-zero Ready Ready Preview Aug 27, 2026 6:10pm

Request Review

…rate limit

POST /api/auth/nonce is rate-limited to 10 per minute per IP, and every
Playwright test shares one IP. Signing in per test does not scale: a
six-test suite already failed on back-to-back runs (measured 7x 201 then
sustained 429) while each test passed in isolation, so the ~30-test target
was unreachable.

Add a 'setup' project that signs each dev wallet in once through the real UI
and saves its session cookie; specs replay that state via signedInPage().
Nonce spend is now bounded by the number of wallets (5) rather than the
number of tests, so adding tests costs nothing.

Also allocates a dev wallet per spec. The SIWE tables live in a single
shared 'app' schema that is NOT namespaced by PONDER_SCHEMA, so two specs
sharing a key would collide on the same owned_profile/draft rows. Key #9 is
called out specifically: it has delegated all its ARB away, so it is the
only key that can exercise the avatar gate's 403 not_delegate branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants