test: add unit tests for frontend bignumber and utilities helpers - #13
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
test: add unit tests for frontend bignumber and utilities helpers#13devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Visit the preview URL for this PR (updated for commit 391419e): https://decentralized-dall-e--pr13-devin-1784700452-fro-cu73ngb3.web.app (expires Wed, 29 Jul 2026 06:10:51 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 9f3ca659ce42113c1a9d85a3ba19a54f05478557 |
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
Coverage analysis: the repo had effectively no meaningful unit tests. Blockchain has only the default Hardhat
test/Lock.ts(which references a non-existentLockcontract), backend has none, and frontend has only the default CRAApp.test.tsx. Measuring the frontendsrc/helpers/src/constantsmodules confirmed 0% coverage across the board.The two largest, least-covered pure-logic modules are
frontend/src/helpers/bignumber.ts(204 lines) andfrontend/src/helpers/utilities.ts(220 lines) — ideal for unit testing since they don't require network/web3 mocks. This PR adds Jest tests (run via the existingreact-app-rewired test) for them.Coverage for the two files after this PR:
utilities.tsis partially covered because most of it is async network/API calls (apiGet*,formatTestTransaction); the tests cover the pure functions:isObject,sanitizeHex,convertStringToHex,convertNumberToString,getChainData(known chain, unknown-chain fallback, and Infura%API_KEY%substitution branch), andhashPersonalMessage(deterministic EIP-191 hash).bignumber.tstests cover all exported predicates, conversions, comparisons, arithmetic (incl. big-integer precision), raw-number conversion round-trips, and the formatting helpers.Notes:
recoverPublicKeywas intentionally not tested — itssecp256k1path rejects jsdom's browserifiedBufferpolyfill (Expected private key to be an Uint8Array), so it isn't reliably unit-testable in the CRA jsdom environment.tsc --noEmitis clean.Test plan
Link to Devin session: https://app.devin.ai/sessions/0fee9282ef36488383c821a634211ba4
Requested by: @walnutwaldo
Devin Review