Skip to content

tests: raise combined coverage toward 85% (mocked-client + offline encoders)#907

Draft
gregnazario wants to merge 8 commits into
mainfrom
cursor/raise-coverage-to-85-8c4a
Draft

tests: raise combined coverage toward 85% (mocked-client + offline encoders)#907
gregnazario wants to merge 8 commits into
mainfrom
cursor/raise-coverage-to-85-8c4a

Conversation

@gregnazario

@gregnazario gregnazario commented May 29, 2026

Copy link
Copy Markdown
Collaborator

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 the vitest.config.ts thresholds to 85.

Combined unit + e2e coverage

Metric Baseline After
Statements 83.19% 90.89%
Branches 72.49% 85.20%
Functions 90.44% 93.82%
Lines 83.19% 90.91%

Verified locally with vitest run --coverage against 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), checkType for every BCS arg type, the convertArgument / convertArgumentWithABI wrappers, 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: StructEnumArgumentParser struct/enum/Option/vector/generic encoding via preloadModules (offline), every validation-error branch, all encodeValueByType primitive widths, and MoveStructArgument / MoveEnumArgument serialization.
  • internal/ans.ts: view-backed reads, indexer GraphQL queries (asserting where_condition + parsed result), and registerName domain/subdomain branches incl. validation errors; api/ans.ts delegation.
  • core/crypto/deserializationUtils.ts (deserializePublicKey / deserializeSignature), core/crypto/multiKey.ts verify/getIndex branches, and account/AccountUtils.ts typed-fromHex guards.

Enforcement

  • vitest.config.ts thresholds raised from 80 → 85 (all four metrics).
  • Added a test:coverage script (combined vitest 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.

Open in Web Open in Cursor 

cursoragent and others added 2 commits May 29, 2026 02:21
… encoding

Co-authored-by: Greg Nazario <greg@gnazar.io>
@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.53%. Comparing base (cf1fa45) to head (bb2ce12).

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     
Flag Coverage Δ
unit 71.53% <ø> (+9.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

cursoragent and others added 6 commits May 29, 2026 02:30
…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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts async conversion + ABI fetchers, and structEnumParser.ts struct/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.ts coverage thresholds from 80% → 85% and added a test:coverage npm 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.

Comment on lines +53 to +55
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 () => {
Comment on lines +449 to +451
await expect(fetchViewFunctionAbi(ADDR, "mod_e", "do_thing", mock.config)).rejects.toThrow(
"is not an view function",
);
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.

3 participants