test: add coverage for fetchTokenList('default') bundled token path#447
Open
gabitoesmiapodo wants to merge 4 commits intodevelopfrom
Open
test: add coverage for fetchTokenList('default') bundled token path#447gabitoesmiapodo wants to merge 4 commits intodevelopfrom
gabitoesmiapodo wants to merge 4 commits intodevelopfrom
Conversation
Test that the bundled @uniswap/default-token-list returns a non-empty tokens array and that all EVM-addressable entries conform to tokenSchema. The v18 list also includes Solana tokens (base58 addresses) which are expected to fail the EVM address regex and are filtered out downstream by useTokenLists via safeParse. Closes #438
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds test coverage for the previously-uncovered fetchTokenList('default') path that returns the bundled @uniswap/default-token-list, helping ensure the app’s default-token boot path is validated against expected shape/contents.
Changes:
- Import
tokenSchemaintosrc/hooks/useTokenLists.test.tsfor schema validation. - Add a test asserting the bundled default list returns a non-empty
tokensarray. - Add a test validating all EVM-addressable entries from the bundled list conform to
tokenSchema.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds a comment explaining that tokenSchema's EVM address format drops Solana and other non-EVM tokens from the bundled list, and that adding non-EVM support requires broader changes. Also renames the related test for clarity.
- Remove redundant Array.isArray assertion (length check is sufficient) - Assert mockFetch was not called to make the contract of the 'default' path explicit and guard against future regressions
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
fetchTokenList('default')-- the code path returning the bundled@uniswap/default-token-list-- had zero test coverage. A major version bump (v13 to v18 in #434) could silently break the data shape with no automated detection.Closes #438
Changes
tokenSchemato the imports insrc/hooks/useTokenLists.test.ts'default' bundled token listdescribe block with two tests forfetchTokenList('default')useTokenLists.tsat thesafeParsefilter explaining why non-EVM tokens (e.g. Solana) are dropped and that supporting them requires broader changesAcceptance criteria
fetchTokenList('default')is called in a test without mocking@uniswap/default-token-listawaytokensarray and that entries conform totokenSchemaTest plan
Note: the v18 bundled list includes 173 Solana tokens with base58 addresses that fail the EVM address regex. The schema test filters to
^0x[a-fA-F0-9]{40}$addresses before callingtokenSchema.parse(), mirroring howuseTokenListsfilters them out downstream viasafeParse.Checklist