Skip to content

Add fixture audit confirming no unused x402 test fixtures - #366

Merged
davedumto merged 1 commit into
Vellar-Wallet:devfrom
Y33t-dev:contrib/issue-302-unused-x402-fixtures
Aug 31, 2026
Merged

Add fixture audit confirming no unused x402 test fixtures#366
davedumto merged 1 commit into
Vellar-Wallet:devfrom
Y33t-dev:contrib/issue-302-unused-x402-fixtures

Conversation

@Y33t-dev

Copy link
Copy Markdown

closes #302

Summary

The issue asks to remove fixtures in src/x402-test-fixtures.ts that are no longer referenced by any test, and its first requirement is to confirm each fixture has no remaining references.

That confirmation comes back negative: on dev, every export in src/x402-test-fixtures.ts is still referenced by a live test. There is nothing to delete, so this PR deletes no fixtures. Removing any of them would break the suite.

The evidence

Produced by the tool added here, run against the real files:

Export Kind References Used by
C_ADDRESS const 2 src/x402-client.test.ts, contrib/x402-client-fallback.test.ts
TOKEN const 13 src/x402-client.test.ts, src/x402-guards.test.ts, contrib/x402-guards-boundary.test.ts
PAYTO const 4 src/x402-client.test.ts
SIM_SOURCE const 13 src/x402-client.test.ts, contrib/x402-client-fallback.test.ts
CAIP2_TESTNET const 31 src/x402-guards.test.ts, contrib/x402-guards-boundary.test.ts
b64 function 11 src/x402-guards.test.ts, contrib/x402-guards-boundary.test.ts
requirements function 56 all four consumers
decoded function 34 src/x402-guards.test.ts, contrib/x402-guards-boundary.test.ts
response402 function 13 all four consumers

Counts exclude the import line, so every number is a genuine use in a test body.

PAYTO is worth calling out: on main it genuinely was imported by nobody, which is likely where the issue's premise came from. Tests added to dev since then use it. That is exactly why the answer is worth computing rather than trusting.

What the audit did find

One real cleanup, applied here: requirements and response402 were imported but never used in contrib/x402-client-fallback.test.ts. That is a dead import, not an unused export — the fixtures themselves are used elsewhere — so the fix is to shorten the import, not delete the fixtures.

Why a tool rather than a grep

A bare grep -c NAME gets this wrong three ways, which is worth guarding against given the issue's premise:

  1. It counts the import line, so an imported-but-unused fixture looks used. This is precisely the contrib/x402-client-fallback.test.ts case above.
  2. It counts unrelated local declarations. PAYTO is independently declared in src/x402-auth-entry.test.ts, packages/mcp-x402-payer/test/helpers.ts and elsewhere; grepping the repo returns 13 hits with nothing to do with the fixture module.
  3. It cannot distinguish an unused export from a dead import, and the two have different fixes. Conflating them leads to deleting a fixture another file still needs.

auditFixtures() parses each consumer's import statement and counts whole-word references with the import line excluded.

Guarding against regression

The final describe block runs the audit against the real repository files on every npm test. If a future change orphans a fixture, the suite fails and names it — turning "is this still used?" into a standing check, and flagging the moment the removal this issue asked for actually becomes correct.

Tests

21 tests covering export parsing, import parsing (including aliases and a regression guard for a multi-line import block appearing earlier in the file), reference counting, and the live audit.

npx vitest run contrib/examples/issue-302-unused-fixture-audit

Notes for the maintainer

The issue asks to note the cleanup in CHANGELOG.md. That file is outside contrib/, which contributor PRs may not touch, so the finding is documented in the example's README instead — happy to add the changelog entry if you widen the scope.

Since no fixtures were removed, "verify the full test suite still passes" holds trivially; the suite is unchanged apart from the two dead imports and the new tests. The 18 failures on dev (in contrib/examples/ and src/session.test.ts) are pre-existing and untouched.

If the intent was to remove fixtures unused as of main, please say so on the issue and I will retarget — but on dev that set is empty.

Issue Vellar-Wallet#302 asks to remove fixtures in src/x402-test-fixtures.ts that are
no longer referenced by any test. Its first requirement is to confirm each
fixture has no remaining references. That confirmation comes back negative:
on this branch every export is still referenced by a live test, so there is
nothing to delete.

Adds contrib/examples/issue-302-unused-fixture-audit, a dependency-free
analyzer that answers the question reproducibly. A bare grep gets it wrong
three ways: it counts the import line (so an imported-but-unused fixture
looks used), it counts unrelated local declarations sharing the name (PAYTO
is declared independently in three other test files), and it cannot tell an
unused export from a dead import. The analyzer parses each consumer's import
statement and counts whole-word references with the import line excluded.

The audit did surface one real cleanup: requirements and response402 were
imported but never used in contrib/x402-client-fallback.test.ts. Removed.

A live-audit test runs against the real repository files on every npm test,
so an orphaned fixture fails the suite and is named, rather than going
unnoticed until someone greps again.
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@Y33t-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Aug 30, 2026

Copy link
Copy Markdown

@Y33t-dev is attempting to deploy a commit to the david's projects Team on Vercel.

A member of the Team first needs to authorize it.

@davedumto
davedumto merged commit c7f58c7 into Vellar-Wallet:dev Aug 31, 2026
1 of 2 checks passed
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