Skip to content

test: assert Cardano reserved network tags and mismatch details - #15

Merged
Samarth208P merged 1 commit into
Samarth208P:mainfrom
Dhananjay-alt:test/cardano-network-assertions
Nov 21, 2026
Merged

Samarth208P merged 1 commit into
Samarth208P:mainfrom
Dhananjay-alt:test/cardano-network-assertions

Conversation

@Dhananjay-alt

Copy link
Copy Markdown
Contributor

Closes #3.

This adds only the assertions the issue says are missing. The 20 CIP-19 positive vectors already in tests/regressions.test.ts are not duplicated. It changes no library code, so nothing changes for users.

What's covered

New tests in tests/cardano.test.ts:

  • Reserved network tags: a Shelley header with network tag 2, 3, 7, 14 or 15 is rejected with INVALID_FORMAT. The tag is changed by re-encoding a published fixture with @scure/base. As a valid control, the same vector re-encoded with its original header still passes.
  • NETWORK_MISMATCH details: the exact public result keeps the decoded network and format. This is checked for a Shelley testnet address with network: 'mainnet', a Shelley mainnet address with network: 'testnet', and the existing Byron testnet example with network: 'mainnet'.
  • Explicit network: 'auto': accepts the Shelley mainnet, Shelley testnet and Byron fixtures.

Results

  • 253 tests.
  • Overall coverage: statements 96.5%, branches 92.3%, functions 100%, lines 99.4%.
  • Locally on Linux, I ran a clean npm ci, npm run check and npm audit (0 vulnerabilities) on Node 22.23.5, 24.16.0 and 26.13.1, and npm run test:coverage on Node 24.16.0. All passed.
  • This repository's CI workflow ran on my fork for this exact commit (5ee7a55), and all 7 jobs passed: package on Ubuntu and Windows with Node 22, 24 and 26 (Chrome stable), plus coverage. Run: https://github.com/Dhananjay-alt/validator0x/actions/runs/44905427588
  • Locally, the packed worker test ran in Playwright's Chromium because Chrome stable isn't installed on that machine. The fork CI run above used Chrome stable.

Add the assertions that were missing from the existing CIP-19 and
differential coverage:
- Shelley headers with a reserved network tag (2, 3, 7, 14, 15) are
  rejected; a re-encoded vector with its original header is the control
- NETWORK_MISMATCH keeps the decoded network and format for Shelley
  mainnet/testnet and Byron
- an explicit network: 'auto' accepts mainnet, testnet and Byron

Vectors are re-encoded from the published fixtures with @scure/base.

Closes Samarth208P#3
Copilot AI balanced review requested due to automatic review settings November 21, 2026 12:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Samarth208P
Samarth208P merged commit 2a57fe6 into Samarth208P:main Nov 21, 2026
7 checks passed
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.

test: Cardano Shelley pointer addresses, header/prefix mismatches and network-policy options are untested

3 participants