Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: probe node/crypto API in crosstest for browserify compat #44

Merged
merged 1 commit into from
Nov 10, 2024

Conversation

ChALkeR
Copy link
Contributor

@ChALkeR ChALkeR commented Nov 10, 2024

This allows running tests in bundle mode under different engines

In bundle, reqire('crypto') is https://www.npmjs.com/package/crypto-browserify
For compatibility:

  1. Don't use iv = null, pass an empty Uint8Array instance instead to crypto.createCipheriv / crypto.createDecipheriv
  2. Check that crypto implementation supports chacha20, chacha20-poly1305, aes*-wrap before using them

To test:

  • npm run lint && npm run test
  • CI
  • node test/crosstest.test.js and check that modified ciphers have Node.js implementation cross-tested (unlike e.g. xchacha20poly1305)
  • npx @exodus/test test/*.test.js (Node.js)
    This is also faster than npm test here 🙃 (not very noticeable, both are fast)
  • npx @exodus/test --engine jsc:bundle --bundle-entropy-size=10000000 --testTimeout 5000000 test/*.test.js (JSC)
    Requires jsc being available in PATH
    Note that due to micro-should relying on Node.js unhandled rejection handling to update the process exit code and jsc cli not supporting that, reported process status will be incorrect. micro-should stdout output indicates a pass though.
  • npx @exodus/test --engine hermes:bundle --bundle-entropy-size=10000000 --testTimeout 5000000 test/*.test.js (Hermes)
    Requires hermes being available in PATH or https://npmjs.com/hermes-engine-cli installed with @exodus/test:
    npm add @exodus/test hermes-engine-cli
    This one sets proper process exit code on unhandled rejections.

Refs: paulmillr/noble-curves#166

@paulmillr paulmillr merged commit ec968a9 into paulmillr:main Nov 10, 2024
5 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.

2 participants