test: add comprehensive test coverage for untested modules#103
Draft
test: add comprehensive test coverage for untested modules#103
Conversation
Agent-Logs-Url: https://github.com/TrustSignal-dev/TrustSignal/sessions/1e4618f6-e04a-4fde-b598-98d78a88783c Co-authored-by: chrismaz11 <24700273+chrismaz11@users.noreply.github.com>
Agent-Logs-Url: https://github.com/TrustSignal-dev/TrustSignal/sessions/1e4618f6-e04a-4fde-b598-98d78a88783c Co-authored-by: chrismaz11 <24700273+chrismaz11@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Copilot created this pull request from a session on behalf of
chrismaz11
April 6, 2026 03:38
View session
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
Analyzed the test coverage of the codebase, identified modules with missing or insufficient tests, and added comprehensive test cases to improve coverage.
Changes
New Test Files (9 files, ~1,400 lines of tests)
tests/adapters/il-dmv.test.ts– Illinois DMV adapter (14 cases): API key not configured, VERIFIED/NOT_FOUND/REVIEW paths, HTTP error handling (404, 500, network error), score clamping, customIDSCAN_BASE_URL, stable license number hashing, nullresponse.datafallbacktests/services/polygonMumbaiAnchor.test.ts– Polygon Mumbai anchor service (7 cases): missing env vars, chain ID mismatch, success path, deterministic nullifier hashing; ethers mocked viavi.mocktests/verifiers/zkmlVerifier.test.ts– ZKML verifier (8 cases): invalid feature vector length, wrong element count, non-finite values (NaN, Infinity, -Infinity); coversZkmlVerificationErrorclasstests/verifiers/halo2Bridge.test.ts– Halo2 bridge (11 cases):--tampered/--revokedflag passing, JSON output parsing, non-zero exit, missing JSON output, malformed JSON, last-line selection, spawn error propagation; child_process mockedtests/verifiers/revocationVerifier.test.ts– Revocation verifier (9 cases): empty bundle hash,ok=true/false, flag passing, Error/non-Error wrapping,RevocationVerificationErrorclasstests/verifiers/zkProofVerifier.test.ts– ZK proof verifier (9 cases): same pattern,ZkProofVerificationErrorclasspackages/core/src/receipt.test.ts– Receipt building (17 cases):computeInputsCommitment,computeReceiptHash,buildReceiptwith all extensions (fraudRisk, zkpAttestation, signing_key_id),toUnsignedReceiptPayload, canonical key orderingpackages/core/src/attom/normalize.test.ts– Normalization utilities (48 cases):normalizePin,normalizeAddress,addressSimilarity,normalizeName,tokenOverlap,nameOverlapScore,canonicalDeedHash,redact— including edge cases for null/undefined/falsy inputspackages/core/src/anchor/portable.test.ts–PortableAnchorManager(7 cases): anchor via active provider, verify active/historical proofs, chain switching, history accumulation across multiple switches, unknown chain errorExtended Existing Tests
tests/api/routes.test.ts– Added 5 cases:notary_present: falsecovers the0branch intoFeatureVectorString(error)brancherror.messagebranchis_admin: trueJWT claim tests thepayload.is_adminbranch inhasAdminClaimbuildApiServerwithoutLOG_LEVELset covers the?? 'info'fallback inapp.tsUpdated
vitest.config.tsExpanded coverage reporting to include newly tested source files:
src/verifiers/revocationVerifier.ts,src/verifiers/zkProofVerifier.tssrc/services/**/*.ts,src/adapters/**/*.tspackages/core/src/receipt.ts,packages/core/src/attom/normalize.ts,packages/core/src/anchor/portable.tsCoverage Results
File-level highlights (branch coverage)
src/routes/verify.tssrc/routes/status.tssrc/routes/app.tssrc/adapters/registries/il-dmv.tssrc/services/polygonMumbaiAnchor.tssrc/verifiers/revocationVerifier.tssrc/verifiers/zkProofVerifier.tspackages/core/src/receipt.tspackages/core/src/attom/normalize.tspackages/core/src/anchor/portable.tsRemaining Uncovered Branches (all are dead/unreachable code)
normalize.ts:57–union === 0intokenOverlapis unreachable; the early-return guard on empty arrays fires firstlogger.ts:54–?? Date.now()fallback requiresonRequesthook not to run (impossible in practice)rateLimit.ts:21–DEFAULT_RETRY_AFTER_SECONDSrequires@fastify/rate-limitto emit a non-finitecontext.aftervaluerevoke.ts:17-18–!payloadguard requires JWT middleware to setrequest.user = undefined(unreachable via HTTP)Validation