Skip to content

Commit

Permalink
test: update workerd expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Apr 30, 2023
1 parent a8ede7f commit 7777f2f
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
- name: Test Bun
run: npm run tap:bun

workers:
workerd:
needs:
- build
runs-on: ubuntu-latest
Expand All @@ -159,7 +159,7 @@ jobs:
key: ${{ needs.build.outputs.cache-key }}
fail-on-cache-miss: true
- name: Run Test Suite
run: npm run tap:workers
run: npm run tap:workerd

edge-runtime:
needs:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,5 @@ tap/*.js
tap/run-*.mjs
*.bak
*.bun
tap/.workerd.capnp
tap/.workers.capnp
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"vercel",
"verify",
"webcrypto",
"workerd",
"workers",
"x509"
],
Expand Down Expand Up @@ -132,7 +133,7 @@
"tap:edge-runtime": "./tap/.edge-runtime.sh",
"tap:electron": "./tap/.electron.sh",
"tap:node": "bash -c './tap/.node.sh'",
"tap:workers": "./tap/.workers.sh"
"tap:workerd": "./tap/.workerd.sh"
},
"devDependencies": {
"@types/node": "^18.16.2",
Expand Down
10 changes: 5 additions & 5 deletions tap/.workers.sh → tap/.workerd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ echo "Using workerd $WORKERD_VERSION, compatibility date $COMPATIBILITY_DATE"
--bundle \
--define:WORKERD_VERSION=\"$WORKERD_VERSION\" \
--target=esnext \
--outfile=tap/run-workers.js \
tap/run-workers.ts
--outfile=tap/run-workerd.js \
tap/run-workerd.ts

cat <<EOT > $(pwd)/tap/.workers.capnp
cat <<EOT > $(pwd)/tap/.workerd.capnp
using Workerd = import "/workerd/workerd.capnp";
const config :Workerd.Config = (
Expand All @@ -25,10 +25,10 @@ const config :Workerd.Config = (
const tapWorker :Workerd.Worker = (
modules = [
(name = "worker", esModule = embed "run-workers.js")
(name = "worker", esModule = embed "run-workerd.js")
],
compatibilityDate = "$COMPATIBILITY_DATE",
);
EOT

workerd test --verbose $(pwd)/tap/.workers.capnp
workerd test --verbose $(pwd)/tap/.workerd.capnp
2 changes: 1 addition & 1 deletion tap/ecdh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default (QUnit: QUnit, lib: typeof jose) => {
['ECDH-ES', true, { crv: 'P-384' }],
['ECDH-ES', !env.isDeno, { crv: 'P-521' }],
['ECDH-ES', false, { crv: 'secp256k1' }],
['ECDH-ES', env.isNode || env.isElectron, { crv: 'X25519' }],
['ECDH-ES', env.isNode || env.isElectron || env.isWorkerd, { crv: 'X25519' }],
['ECDH-ES', env.isNode, { crv: 'X448' }],
]

Expand Down
2 changes: 1 addition & 1 deletion tap/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const isEdgeRuntime = typeof EdgeRuntime !== 'undefined'
export const isBrowser =
typeof navigator !== 'undefined' && navigator.userAgent?.startsWith?.('Mozilla/5.0 ')

export const isWorkers =
export const isWorkerd =
typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers'

export const isChromium =
Expand Down
7 changes: 6 additions & 1 deletion tap/jwk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export default (QUnit: QUnit, lib: typeof jose) => {
['ECDH-ES', KEYS.P256.jwk, true],
['ECDH-ES', KEYS.P384.jwk, true],
['ECDH-ES', KEYS.P521.jwk, !env.isDeno],
['ECDH-ES', KEYS.X25519.jwk, env.isDeno || env.isNode || env.isElectron, env.isDeno],
[
'ECDH-ES',
KEYS.X25519.jwk,
env.isDeno || env.isNode || env.isElectron || env.isWorkerd,
env.isDeno,
],
['ECDH-ES', KEYS.X448.jwk, env.isNode],
['EdDSA', KEYS.Ed25519.jwk, !(env.isBrowser || env.isEdgeRuntime)],
['EdDSA', KEYS.Ed448.jwk, env.isNode],
Expand Down
12 changes: 10 additions & 2 deletions tap/pem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,16 @@ export default (QUnit: QUnit, lib: typeof jose) => {
[['ECDH-ES', 'P-521'], KEYS.P521.pkcs8, !env.isDeno],
[['ECDH-ES', 'P-521'], KEYS.P521.spki, !env.isDeno],
[['ECDH-ES', 'P-521'], KEYS.P521.x509, !env.isDeno],
[['ECDH-ES', 'X25519'], KEYS.X25519.pkcs8, env.isDeno || env.isNode || env.isElectron],
[['ECDH-ES', 'X25519'], KEYS.X25519.spki, env.isDeno || env.isNode || env.isElectron],
[
['ECDH-ES', 'X25519'],
KEYS.X25519.pkcs8,
env.isDeno || env.isNode || env.isElectron || env.isWorkerd,
],
[
['ECDH-ES', 'X25519'],
KEYS.X25519.spki,
env.isDeno || env.isNode || env.isElectron || env.isWorkerd,
],
[['ECDH-ES', 'X448'], KEYS.X448.pkcs8, env.isNode],
[['ECDH-ES', 'X448'], KEYS.X448.spki, env.isNode],
[['EdDSA', 'Ed25519'], KEYS.Ed25519.pkcs8, !(env.isBrowser || env.isEdgeRuntime)],
Expand Down
File renamed without changes.

0 comments on commit 7777f2f

Please sign in to comment.