Skip to content

test: #698 — behavioral parity tests for argon2 + ethers integrations#760

Merged
proggeramlug merged 1 commit into
mainfrom
test/stdlib-integrations-behavioral-parity
May 14, 2026
Merged

test: #698 — behavioral parity tests for argon2 + ethers integrations#760
proggeramlug merged 1 commit into
mainfrom
test/stdlib-integrations-behavioral-parity

Conversation

@TheHypnoo
Copy link
Copy Markdown
Contributor

Summary

Follow-up to #694, addressing #698. Converts deterministic entries from test_ffi_surface_stdlib_integrations.ts into focused behavioral parity fixtures.

Changes

  • test_parity_argon2.ts + expected output — round-trip argon2.hash / argon2.verify with random-salt shape assertions. Only the async path is wired in Perry's NativeModSig table, so this covers the two FFI entries that are reachable end-to-end (js_argon2_hash, js_argon2_verify).
  • test_parity_ethers.ts + expected output — deterministic numeric/address helpers: getAddress (EIP-55 checksum), parseEther/formatEther, parseUnits/formatUnits at 6- and 9-decimal positions. Covers the five js_ethers_* helpers that are pure functions of their inputs.
  • test_parity_crypto.ts — adds a @covers block declaring the crypto/webcrypto/crypto_e2e FFI surface it already exercises via node:crypto and crypto.subtle (digest, hash, pbkdf2/hkdf, subtle.sign/verify).
  • Regenerated test-coverage/COVERAGE.md and test_ffi_surface_* inventory files.

Both new fixtures use the test-parity/expected/ mechanism: Perry routes the npm-style imports to its bundled perry-ext-* wrappers, but Node can't load the same names without node_modules, so they fall through to the stored expected-output comparison.

Scope notes

I drafted fixtures for jsonwebtoken, bcrypt, and cheerio as well, but each exposed pre-existing bugs in the dispatch layer that are out of scope here:

  • jsonwebtoken.signNativeModSig passes payload / secret as NA_F64 (NaN-boxed) but js_jwt_sign reads them as *const StringHeader, producing a garbage token (calling-convention mismatch — same shape as the argon2.hash(password) receives null StringHeader at the FFI boundary #591 argon2 fix that landed earlier).
  • bcrypt.hash — return value is reported as typeof === "object" in user code (compare round-trips correctly, but .startsWith(...) on the hash fails).
  • cheerio$.select(...) returns a bare-number handle, so .length() / .first() etc. fail with (number).method is not a function at the prototype check.

These should each get their own follow-up issue. For now they stay listed in test_ffi_surface_stdlib_integrations.ts. Service-backed integrations (MongoDB, MySQL, PG, ioredis, Nodemailer, Sharp) also remain in the inventory pending the local-container / opt-in test setup described in #698.

Inventory delta

  • test_ffi_surface_stdlib_integrations.ts: 156 → 138 unique FFI names (-18).
  • ./test-coverage/audit.sh --markdown: still 100% TS FFI surface coverage.

Test plan

  • ./test-coverage/regen_ts_surface_inventory.py
  • ./test-coverage/audit.sh --markdown reports 100% TS coverage
  • ./run_parity_tests.sh --filter test_parity_argon2 → PASS (expected-output)
  • ./run_parity_tests.sh --filter test_parity_ethers → PASS (expected-output)
  • ./run_parity_tests.sh --filter test_ffi_surface → 5/5 PASS

Checklist

  • I have NOT bumped the workspace version or edited CLAUDE.md / CHANGELOG.md
  • My commit follows the loose conventional prefix style used in the log
  • I've read CONTRIBUTING.md and agree to the Code of Conduct

Converts deterministic entries from `test_ffi_surface_stdlib_integrations.ts`
into focused behavioral parity fixtures, per the follow-up to #694.

- `test_parity_argon2.ts` + expected output: round-trip `argon2.hash` /
  `argon2.verify` (async path — the only one wired in the dispatch
  table) with random-salt shape assertions.
- `test_parity_ethers.ts` + expected output: deterministic helpers
  `getAddress`, `parseEther`/`formatEther`, `parseUnits`/`formatUnits`.
- Adds `@covers` block to `test_parity_crypto.ts` for the
  crypto/webcrypto/crypto_e2e FFI surface it already exercises (digest,
  hash, hmac-via-pbkdf2/hkdf, subtle.sign/verify).

Both new fixtures use the `test-parity/expected/` mechanism: Perry routes
the npm-style imports to its bundled `perry-ext-*` wrappers, but Node
can't load the same names without `node_modules`, so they fall through
to the stored expected-output comparison.

After `./test-coverage/regen_ts_surface_inventory.py`:
- stdlib integrations inventory: 156 → 138 unique FFI names.
- `./test-coverage/audit.sh --markdown` still reports 100% TS FFI coverage.
@proggeramlug proggeramlug force-pushed the test/stdlib-integrations-behavioral-parity branch from b26f337 to 6a796e3 Compare May 14, 2026 05:43
@proggeramlug proggeramlug merged commit 2f3a82c into main May 14, 2026
9 checks passed
@proggeramlug proggeramlug deleted the test/stdlib-integrations-behavioral-parity branch May 14, 2026 05:44
proggeramlug added a commit to Lebei2046/perry that referenced this pull request May 14, 2026
…docs (v0.5.909)

Maintainer fold-in on top of @Lebei2046's libDirs feature:

- link.rs: emit /LIBPATH:<dir> on is_windows (MSVC link.exe) instead of
  -L<dir>, mirroring the existing libs loop's MSVC/Unix split.
- resolve.rs: anchor relative libDirs entries to package_dir via
  package_dir.join(p), matching swift_sources / metal_sources. Field
  type is now Vec<PathBuf>.
- compile.rs: doc-comment on the new field.
- manifest-v1.md: row added for libDirs.
- resolve.rs: two new tests in manifest_parse_tests covering
  package_dir anchoring + empty-by-default behavior.
- Cargo.toml / Cargo.lock / CLAUDE.md / CHANGELOG.md: 0.5.908 → 0.5.909
  (renumbered to follow PerryTS#760 which took 0.5.908 mid-review).
proggeramlug added a commit that referenced this pull request May 14, 2026
* feat: add libDirs support

Add support for specifying library search paths in native library
target configurations via the new `libDirs` field in package.json.

Changes:
- Add `lib_dirs` field to TargetNativeConfig
- Parse `libDirs` from package.json
- Add `-L` flags for libDirs before linking

* chore(libDirs): MSVC /LIBPATH branch + package_dir anchoring + tests/docs (v0.5.909)

Maintainer fold-in on top of @Lebei2046's libDirs feature:

- link.rs: emit /LIBPATH:<dir> on is_windows (MSVC link.exe) instead of
  -L<dir>, mirroring the existing libs loop's MSVC/Unix split.
- resolve.rs: anchor relative libDirs entries to package_dir via
  package_dir.join(p), matching swift_sources / metal_sources. Field
  type is now Vec<PathBuf>.
- compile.rs: doc-comment on the new field.
- manifest-v1.md: row added for libDirs.
- resolve.rs: two new tests in manifest_parse_tests covering
  package_dir anchoring + empty-by-default behavior.
- Cargo.toml / Cargo.lock / CLAUDE.md / CHANGELOG.md: 0.5.908 → 0.5.909
  (renumbered to follow #760 which took 0.5.908 mid-review).

---------

Co-authored-by: Ralph Küpper <ralph.kuepper@skelpo.com>
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.

2 participants