Repository navigation
test: add table-driven Cosmos account tests - #14
Merged
Merged
Conversation
npm test never reached CosmosValidator's success path; valid accounts were only checked by the separate differential suite. For each of the five chains, assert the public result for a 20-byte account, whether 32-byte accounts are accepted (not on Injective or Celestia), and that every other chain's prefix is rejected. Accounts are encoded with @scure/base. Also cover the constructor's unsupported-chain RangeError. cosmos.ts coverage: 81.8% -> 100% statements, 68.8% -> 100% branches. Closes Samarth208P#2
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.
Closes #2.
npm testnever reached the success path inCosmosValidator. This adds the table-driven test suggested in the issue. It changes no library code, so nothing changes for users.What's covered
tests/cosmos.test.tshas one table row per chain, with columns chain, account prefix, and whether 32-byte accounts are accepted.{ valid: true, blockchain, details: { format: 'bech32', checksum: true } }.INVALID_FORMATon Injective and Celestia.COSMOS_CHAINS, so adding a chain without a row fails.RangeError.Accounts are encoded with
@scure/base(already a dev dependency), so the expected values don't depend on the decoder being tested.Results
src/validators/cosmos.tscoverage: statements 81.8% → 100%, branches 68.8% → 100%.npm ci,npm run checkandnpm audit(0 vulnerabilities) on Node 22.23.5, 24.16.0 and 26.13.1, andnpm run test:coverageon Node 24.16.0. All passed.