Skip to content

Commit 2f3a82c

Browse files
authored
test: #698 — behavioral parity tests for argon2 + ethers integrations (#760)
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.
1 parent 1a7ce21 commit 2f3a82c

11 files changed

Lines changed: 181 additions & 91 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Detailed changelog for Perry. See CLAUDE.md for concise summaries.
44

5+
## v0.5.908 — test: #698 — behavioral parity tests for argon2 + ethers integrations (#760). Follow-up to #694, addressing #698. Adds two new parity fixtures and a `@covers` block on `test_parity_crypto.ts`, moving 18 FFI entries out of `test_ffi_surface_stdlib_integrations.ts` (156 → 138 unique names) into behavioral coverage. **`test_parity_argon2.ts`** — round-trips `argon2.hash` / `argon2.verify` against the `perry-ext-argon2` wrapper; non-deterministic salt is handled by shape-checking the `$argon2id$` prefix and asserting verify round-trips against a freshly produced hash. Only the async path is in `NativeModSig`, so this covers the two FFI entries (`js_argon2_hash`, `js_argon2_verify`) reachable end-to-end. **`test_parity_ethers.ts`** — pure deterministic helpers from `perry-ext-ethers`: `getAddress` (EIP-55 checksum on lower- and upper-case input), `parseEther`/`formatEther` round-trip on 1.5 ETH, `parseUnits`/`formatUnits` at 6- (USDC) and 9-decimal (gwei) positions. Covers the five `js_ethers_*` helpers. Both new fixtures use the `test-parity/expected/` mechanism — Perry routes the npm-style imports to the bundled `perry-ext-*` wrappers, but Node can't resolve the same names without `node_modules`, so they fall through to stored expected-output comparison. **`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); no behavioral change. **Out of scope (each gets its own follow-up).** `jsonwebtoken.sign` — `NativeModSig` passes `payload`/`secret` as `NA_F64` (NaN-boxed) but `js_jwt_sign` reads them as `*const StringHeader`, producing garbage tokens (calling-convention mismatch, same shape as the #591 argon2 fix). `bcrypt.hash` — return value reports `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. 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. **Audit.** `./test-coverage/audit.sh --markdown` keeps TS-side and combined FFI coverage at **1791/1791 (100.0%)**. `test_ffi_surface_stdlib_integrations.ts` re-regenerated via `regen_ts_surface_inventory.py` to fold in the new `@covers` blocks. Comment-only changes; no behavioral or runtime impact. Contributor: @TheHypnoo.
6+
57
## v0.5.907 — test(stdlib): #697 — move stdlib_io FFI coverage into behavioral tests (#758). Follow-up to #694: relocates the 155 inventory entries from `test_ffi_surface_stdlib_io.ts` into `@covers` annotations attached to the existing behavioral fixtures for each surface — `fetch.rs` (43 names) → `test_gap_fetch_response.ts`; `streams.rs` (37) → `test_parity_stream_web.ts`; `http.rs` (13) → `test_parity_http.ts`; `net/mod.rs` (10) → `test_net_socket.ts`; `readline.rs` (5) → `test_parity_readline.ts`; `worker_threads.rs` (6) → `test_parity_worker_threads.ts`; `ws.rs` (11) → `test_node_http_ws_upgrade.ts`; `framework/{multipart,request,response,server}.rs` (28) → `test_fastify_integration.ts`. Each receiving fixture already exercises real behavior on its surface (local loopback servers / deterministic in-memory probes / Headers + Blob + Response API roundtrips) — no external services added. **Mechanism.** `regen_ts_surface_inventory.py` excludes the six `test_ffi_surface_*.ts` inventory files when scanning for `@covers` references, so any FFI name that appears in a non-inventory fixture's `@covers` block is dropped from its inventory file on the next regen. After this PR, `test_ffi_surface_stdlib_io.ts` shrinks from **155 → 0** unique FFI names. **Audit.** `./test-coverage/audit.sh --markdown` keeps TypeScript and combined FFI coverage at **1791/1791 (100.0%)**. `test_ffi_surface_runtime_core.ts` re-regenerated against current `main` post-rebase — the inventory drift visible in the diff (added `js_array_flat_depth`, `js_template_raw`, `js_path_matches_glob`, `js_async_first_call`, the 7 new `webassembly.rs` exports; removed `js_mul`, `js_net_socket_destroy/end/write`, the 9 `js_ws_*` stubs from `stdlib_stubs.rs`) reflects upstream Rust refactors, not hand edits. Comment-only changes; no behavioral or runtime impact. Contributor: @TheHypnoo.
68

79
## v0.5.906 — test(stdlib): #696 — behavioral parity fixtures for stdlib core utilities (#757). Converts the stdlib-core FFI inventory entries called out in #696 into focused parity fixtures: 13 new `test_parity_*.ts` files (`lodash`, `dotenv`, `validator`, `uuid`, `nanoid`, `decimal`, `dayjs`, `moment`, `date_fns`, `lru_cache`, `commander`, `cron`, `async_local_storage`) plus `@covers` blocks appended to the existing `test_parity_events.ts` and `test_parity_zlib.ts`. Non-deterministic surfaces (uuid v4/v7, nanoid, dayjs.now / fromNow) use shape checks (length, alphabet, `validate()` round-trip) so output stays byte-stable; everything else uses fixed inputs and anchored UTC timestamps (e.g. dayjs anchored to `1709209096789` / 2024-02-29). `test_parity_async_local_storage.ts` is the one fixture that runs end-to-end in Node today (built-in `node:async_hooks`); the other 12 import npm packages not installed in the parity worker and will record as `NODE_FAIL`/`SKIP` until those land, acting as `@covers`-driven coverage anchors in the meantime. After `./test-coverage/regen_ts_surface_inventory.py`, `test_ffi_surface_stdlib_core.ts` drops from **313 → 84** unique FFI names; `./test-coverage/audit.sh --markdown` keeps TS-side coverage at **1791/1791 (100.0%)**. CI workflow tweak: `decimal`, `dotenv`, `lodash`, `moment`, `validator` added to the compile-smoke `SKIP_TESTS` list (no native stdlib path); the other 7 npm-package fixtures compile under perry-stdlib's native dispatch so they're left to the standard runner. `test_ffi_surface_runtime_core.ts` re-regenerated against current `main` (post-#756) — pure regen artifact, not a behavioral change. Contributor: @TheHypnoo.

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
88

99
Perry is a native TypeScript compiler written in Rust that compiles TypeScript source code directly to native executables. It uses SWC for TypeScript parsing and LLVM for code generation.
1010

11-
**Current Version:** 0.5.907
11+
**Current Version:** 0.5.908
1212

1313

1414
## TypeScript Parity Status

0 commit comments

Comments
 (0)