Skip to content

test: shared golden vectors for the canonical anchor-name encoding - #7

Merged
JamesCarnley merged 1 commit into
mainfrom
test/anchor-name-vectors
Oct 27, 2026
Merged

JamesCarnley merged 1 commit into
mainfrom
test/anchor-name-vectors

Conversation

@JamesCarnley

Copy link
Copy Markdown
Member

Summary

Adds packages/sdk/test/fixtures/anchor-names.vectors.json and a test (names-vectors.test.ts) that checks encodeName / decodeName / asCanonicalName against it. Test-only; no published code changes (empty changeset).

Why

efs-project/contracts#55 implements contracts #34 item 1: the router re-encodes each decoded web3:// path segment into EFSIndexer's canonical form, so generic clients can open names like my notes.txt. That only works if the router produces exactly the bytes the SDK's encodeName writes. The TS and Solidity sides have drifted before (media-type validation, twice). This file is the single artifact both suites run, so drift fails a test on whichever side moved. The contracts PR vendors a copy.

What's in the file

  • accept (157): every single ASCII byte (except a lone .), dot names that aren't dot-segments, reserved bytes inside names, literal % cases, non-ASCII UTF-8 (stays literal, never %C3%A9), and NFC inputs. Each one records input, canonical, and decodedUrlReachable.
  • reject (18): rejected by both EFSIndexer and the SDK: empty, dot-segments, bare reserved bytes, malformed/lowercase escapes, over-escapes (including encodeURIComponent output).
  • sdkOnlyReject (2): not-NFC names. The SDK rejects them, but the contract can't check NFC and accepts them, so don't assert an on-chain revert for these.

decodedUrlReachable: false marks the known ambiguity: a human name that literally contains a canonical escape (%2F, 50%20off, 100%25) can't be reached by its percent-decoded URL, only by the canonical form.

The vectors were written from an independent restatement of specs/02, not generated by encodeName, so the test checks the codec rather than snapshotting it. The file is ASCII-only (non-ASCII and DEL are \u-escaped) so an NFC-normalizing editor can't silently rewrite the not-NFC vectors.

Test plan

  • pnpm typecheck
  • pnpm lint (biome ci)
  • pnpm --filter @efs/sdk test: 1030 passed, including the 177 new vector cases
  • pnpm changeset status --since=origin/main

Agents involved

Claude Opus 5.5 (SDK dev session) wrote the vectors and test, at the request of the contracts-issues agent working on #55.

🤖 Generated with Claude Code

The router fix for contracts #34 item 1 (efs-project/contracts#55)
re-encodes decoded web3:// path segments into EFSIndexer's canonical
form. That only works if it produces exactly the bytes the SDK's
encodeName produces; the TS and Solidity sides have drifted before
(media types, twice). One shared vector file, run by both suites,
turns that drift into a test failure on whichever side moved.

The vectors are written from an independent restatement of specs/02
(not generated by encodeName), so this test checks the codec rather
than snapshotting it. 157 accept vectors (every ASCII byte, literal
`%` cases, UTF-8, NFC), 18 rejects both sides enforce, and 2
SDK-only rejects (not-NFC, which the contract cannot check). Each
accept vector also records whether the name stays reachable through
a generic client that percent-decodes the path: `%2F`, `50%20off`
and `100%25` do not. The file is ASCII-only so an NFC-normalizing
editor cannot rewrite the not-NFC vectors.

Verified: pnpm typecheck, lint (biome ci), full test suite
(1030 passed), changeset status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T22:19:05.819001Z 78551f8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@JamesCarnley
JamesCarnley merged commit 1a4de32 into main Oct 27, 2026
3 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.

1 participant