Add fixture audit confirming no unused x402 test fixtures - #366
Merged
davedumto merged 1 commit intoAug 31, 2026
Merged
Conversation
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.
|
@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! 🚀 |
|
@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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #302
Summary
The issue asks to remove fixtures in
src/x402-test-fixtures.tsthat 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 insrc/x402-test-fixtures.tsis 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:
C_ADDRESSTOKENPAYTOSIM_SOURCECAIP2_TESTNETb64requirementsdecodedresponse402Counts exclude the import line, so every number is a genuine use in a test body.
PAYTOis worth calling out: onmainit genuinely was imported by nobody, which is likely where the issue's premise came from. Tests added todevsince 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:
requirementsandresponse402were imported but never used incontrib/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 NAMEgets this wrong three ways, which is worth guarding against given the issue's premise:contrib/x402-client-fallback.test.tscase above.PAYTOis independently declared insrc/x402-auth-entry.test.ts,packages/mcp-x402-payer/test/helpers.tsand elsewhere; grepping the repo returns 13 hits with nothing to do with the fixture module.auditFixtures()parses each consumer's import statement and counts whole-word references with the import line excluded.Guarding against regression
The final
describeblock runs the audit against the real repository files on everynpm 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.
Notes for the maintainer
The issue asks to note the cleanup in
CHANGELOG.md. That file is outsidecontrib/, 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(incontrib/examples/andsrc/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 ondevthat set is empty.