Expand crypto parity coverage - #1419
Conversation
4f80de4 to
644da53
Compare
644da53 to
1d7af8b
Compare
1d7af8b to
ca761af
Compare
|
Note on CI flake: the
Other PRs that ran in between ( Will retry the Tests workflow once if it fails again on the latest push (commit |
ca761af to
04225ca
Compare
The PR-side .export/.equals routing fix plus main's process-module additions pushed crates/perry-runtime/src/object/field_get_set.rs to 2035 lines (over the 2000 threshold). Splitting is tracked under #1435; allowlist with a one-line rationale until then.
…pansion # Conflicts: # docs/api/perry.d.ts # docs/src/api/reference.md
…#1511) The named-import path (`import { randomBytes } from "node:crypto"; randomBytes(16)`, lowered in `globals.rs`) and the dotted path (`crypto.randomBytes(16)`, lowered in `module_static.rs`) used to inline the same `Expr::CryptoRandom*` constructions side-by-side. Each new crypto method added required parallel edits at both sites, and #1419 had to keep the two lists manually in sync. New `expr_call/crypto.rs` submodule with `lower_crypto_passthrough(method, args)` (and a cheap `is_passthrough_method(method)` pre-check so the caller can avoid moving `args` into the helper when the method isn't ours). Both call sites delegate to it. Today's covered set: `randomBytes`, `randomUUID`, `randomFillSync`. Methods whose lowering shape diverges between sites — dotted-only `sha256` / `md5` (dedicated shortcuts), dotted-only `getRandomValues` (rewrites into an instance method on the buffer), named-import-only `createSecretKey` (synthetic PropertyGet through NativeModuleRef) — stay at their call site. The shared helper grows naturally when a method's shape lines up across both sites. Pure refactor: behavior identical, verified by exercising `randomBytes(n)` / `randomUUID()` / `randomFillSync(buf)` through both shapes and confirming identical output.
…pansion # Conflicts: # crates/perry-codegen/src/type_analysis.rs # crates/perry-hir/src/lower/expr_call/globals.rs # crates/perry-hir/src/lower/expr_call/module_static.rs # docs/api/perry.d.ts # docs/src/api/reference.md
…pansion # Conflicts: # docs/api/perry.d.ts # docs/src/api/reference.md
The PR's earlier amend that converted aes_gcm_rejects_192_bit_key into aes_gcm_round_trip_192 was lost during the latest merge with main. Restore the round-trip assertion so cargo-test stays green for the AES-192-GCM support added in #1419.
Summary
Expands Perry's
node:cryptoparity coverage with a broad deterministic test suite curated from Node.js, Bun, and Deno crypto compatibility coverage, and closes the compatibility gaps discovered while porting those cases.This PR adds granular TypeScript parity tests for the main crypto surfaces and documents the intentionally deferred gaps in
test-parity/node-suite/crypto/README.md.Covered areas
nameparity.crypto.hash(), and legacy callable constructors.getCipherInfo().Runtime/codegen changes
node:cryptonative support for the parity suite areas above.Hash.update()/Hmac.update()input encodings through the codegen fallback path.Validation
Latest local run:
find test-parity/node-suite/crypto -type d -name .perry-cache -prune -exec rm -rf {} + && ./run_parity_tests.sh --suite node-suite --module crypto Parity Pass: 181 Parity Fail: 0 Compile Fail: 0 Skipped: 0 Parity Rate: 100.0%Report generated locally at:
Known follow-up gaps
These are intentionally left for future PRs:
X509Certificateandcrypto.Certificate/ SPKAC APIs.CryptoKey/KeyObject.toCryptoKey()asymmetric object identity/prototype behavior.