tests: raise combined coverage toward 85% (mocked-client + offline encoders)#907
tests: raise combined coverage toward 85% (mocked-client + offline encoders)#907gregnazario wants to merge 8 commits into
Conversation
… encoding Co-authored-by: Greg Nazario <greg@gnazar.io>
Co-authored-by: Greg Nazario <greg@gnazar.io>
Bundle ReportBundle size has no change ✅ |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #907 +/- ##
==========================================
+ Coverage 62.35% 71.53% +9.17%
==========================================
Files 122 122
Lines 6538 6538
Branches 1188 1188
==========================================
+ Hits 4077 4677 +600
+ Misses 2172 1597 -575
+ Partials 289 264 -25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ure) Co-authored-by: Greg Nazario <greg@gnazar.io>
Co-authored-by: Greg Nazario <greg@gnazar.io>
…imitives/errors Co-authored-by: Greg Nazario <greg@gnazar.io>
…guards Co-authored-by: Greg Nazario <greg@gnazar.io>
…iative Co-authored-by: Greg Nazario <greg@gnazar.io>
Co-authored-by: Greg Nazario <greg@gnazar.io>
There was a problem hiding this comment.
Pull request overview
This PR is part of the “coverage-to-85” initiative, adding targeted unit tests for previously under-covered transaction builder, ANS, and crypto utilities, and raising the global Vitest coverage thresholds to enforce the improved baseline.
Changes:
- Added offline/mock-driven unit tests covering remaining branches in
remoteAbi.tsasync conversion + ABI fetchers, andstructEnumParser.tsstruct/enum/Option/vector encoding. - Added unit tests for ANS internal query/registration logic + API delegation, and for crypto/account utility edge branches.
- Raised
vitest.config.tscoverage thresholds from 80% → 85% and added atest:coveragenpm script.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Raises global coverage thresholds to 85% across all metrics. |
| package.json | Adds test:coverage convenience script for the combined run. |
| CHANGELOG.md | Documents the coverage initiative completion and test additions. |
| tests/unit/transactions/structEnumParser-primitives.test.ts | Adds primitive-width + edge-case encoding tests for StructEnumArgumentParser. |
| tests/unit/transactions/structEnumParser-encode.test.ts | Adds comprehensive offline struct/enum encoding and error-branch tests for structEnumParser.ts. |
| tests/unit/transactions/remoteAbiStructAsync.test.ts | Adds async struct/enum ABI-fetch encoding tests and sync struct branch coverage for remoteAbi.ts. |
| tests/unit/transactions/remoteAbiAsync.test.ts | Adds broad async conversion parity/branch tests and mocked fullnode ABI fetcher tests. |
| tests/unit/multiKey-verify.test.ts | Covers remaining MultiKey verify/getIndex branches. |
| tests/unit/internal/ans-queries.test.ts | Adds view/indexer query + registerName branch tests for internal/ans.ts. |
| tests/unit/core/crypto/deserializationUtils.test.ts | Adds tests for deserializePublicKey / deserializeSignature branch behavior. |
| tests/unit/api/ans.test.ts | Verifies ANS API delegates to internal/ans.ts with bound config. |
| tests/unit/accountUtils-errors.test.ts | Adds tests for AccountUtils error/guard branches and toHexStringWithoutPrefix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const GRACE_SECONDS = 30 * 24 * 60 * 60; | ||
| // 30 minutes in the future, in seconds (the contract works in epoch seconds for get_expiration). | ||
| const FUTURE_EXPIRATION_SECONDS = Math.round((Date.now() + 1000 * 60 * 60 * 24 * 365) / 1000); |
| expect(result.bcsToBytes()).toEqual(expected.toUint8Array()); | ||
| }); | ||
|
|
||
| it("throws on a non-boolean for a bool field and an unsupported type", async () => { |
| await expect(fetchViewFunctionAbi(ADDR, "mod_e", "do_thing", mock.config)).rejects.toThrow( | ||
| "is not an view function", | ||
| ); |
Summary
Completes the "coverage-to-85" initiative (
docs/superpowers/specs/2026-05-20-coverage-to-85-design.md). Branches were the gating metric. This PR adds focused, meaningful-assertion unit tests for the highest-uncovered-branch modules and raises thevitest.config.tsthresholds to 85.Combined
unit + e2ecoverageVerified locally with
vitest run --coverageagainst the Docker localnet: 120 test files pass (3 skipped) and the run exits 0 with the new 85 thresholds enforced.What's covered (all new tests are unit-level, no new localnet dependency)
transactions/transactionBuilder/remoteAbi.ts(largest gap, ~252 uncovered branches): the async conversion mirror (checkOrConvertArgumentWithABI/parseArgAsync),checkTypefor every BCS arg type, theconvertArgument/convertArgumentWithABIwrappers,standardizeTypeTags, the ABI fetchers (fetchModuleAbi,fetchFunctionAbi,fetchEntryFunctionAbi,fetchViewFunctionAbi,fetchMoveFunctionAbi,fetchModuleAbiWithStructs) driven by a recording mock client, and the struct/enum async encoding path.transactions/transactionBuilder/structEnumParser.ts:StructEnumArgumentParserstruct/enum/Option/vector/generic encoding viapreloadModules(offline), every validation-error branch, allencodeValueByTypeprimitive widths, andMoveStructArgument/MoveEnumArgumentserialization.internal/ans.ts: view-backed reads, indexer GraphQL queries (assertingwhere_condition+ parsed result), andregisterNamedomain/subdomain branches incl. validation errors;api/ans.tsdelegation.core/crypto/deserializationUtils.ts(deserializePublicKey/deserializeSignature),core/crypto/multiKey.tsverify/getIndexbranches, andaccount/AccountUtils.tstyped-fromHexguards.Enforcement
vitest.config.tsthresholds raised from 80 → 85 (all four metrics).test:coveragescript (combinedvitest run --coverage) so the gate is runnable.All new tests follow the meaningful-assertion rules: HTTP-mocked tests assert both the outgoing request shape and the parsed result; error paths assert the specific message; BCS values are compared against independently-constructed bytes.