Skip to content

Commit

Permalink
Merge pull request #386 from dajiaji/refine-test
Browse files Browse the repository at this point in the history
Refine test to add test:cloudflare to deno task.
  • Loading branch information
dajiaji authored Sep 7, 2024
2 parents d3474e8 + b08bcd6 commit d944e13
Show file tree
Hide file tree
Showing 54 changed files with 14,772 additions and 1,047 deletions.
65 changes: 2 additions & 63 deletions .github/workflows/ci_cloudflare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,68 +20,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: v20.x
- name: Install esbuild
run: npm install -g esbuild
- name: Prepare test
run: deno task npm
- name: Run test for ./packages/core
working-directory: ./packages/core/test/runtimes/cloudflare
run: |
npm install
npm link @hpke/core
nohup npm start &
sleep 3
deno test --import-map=../../../../../import_map.json core.spec.ts --allow-net --config ../../../deno.json
- name: Run test for ./packages/chacha20poly1305
working-directory: ./packages/chacha20poly1305/test/runtimes/cloudflare
run: |
npm install
npm link @hpke/core
npm link @hpke/chacha20poly1305
nohup npm start &
sleep 3
deno test --import-map=../../../../../import_map.json chacha20poly1305.spec.ts --allow-net --config ../../../deno.json
- name: Run test for ./packages/dhkem-x25519
working-directory: ./packages/dhkem-x25519/test/runtimes/cloudflare
run: |
npm install
npm link @hpke/core
npm link @hpke/dhkem-x25519
nohup npm start &
sleep 3
deno test --import-map=../../../../../import_map.json dhkem-x25519.spec.ts --allow-net --config ../../../deno.json
- name: Run test for ./packages/dhkem-x448
working-directory: ./packages/dhkem-x448/test/runtimes/cloudflare
run: |
npm install
npm link @hpke/core
npm link @hpke/dhkem-x448
nohup npm start &
sleep 3
deno test --import-map=../../../../../import_map.json dhkem-x448.spec.ts --allow-net --config ../../../deno.json
- name: Run test for ./packages/dhkem-secp256k1
working-directory: ./packages/dhkem-secp256k1/test/runtimes/cloudflare
run: |
npm install
npm link @hpke/core
npm link @hpke/dhkem-secp256k1
nohup npm start &
sleep 3
deno test --import-map=../../../../../import_map.json dhkem-secp256k1.spec.ts --allow-net --config ../../../deno.json
- name: Run test for ./packages/hybridkem-x25519-kyber768
working-directory: ./packages/hybridkem-x25519-kyber768/test/runtimes/cloudflare
run: |
npm install
npm link @hpke/core
npm link @hpke/hybridkem-x25519-kyber768
nohup npm start &
sleep 3
deno test --import-map=../../../../../import_map.json hybridkem-x25519-kyber768.spec.ts --allow-net --config ../../../deno.json
- name: Run test for ./packages/hpke-js
working-directory: ./packages/hpke-js/test/runtimes/cloudflare
run: |
npm install
npm link hpke-js
nohup npm start &
sleep 3
deno test --import-map=../../../../../import_map.json hpke.spec.ts --allow-net --config ../../../deno.json
- name: Run test
run: deno task test:cloudflare
18 changes: 18 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"npm/",
"**/*/*.js",
"**/*/npm/",
"**/*/.wrangler/",
"coverage/*.json"
]
},
Expand All @@ -28,6 +29,7 @@
"npm/",
"**/*/*.js",
"**/*/npm/",
"**/*/.wrangler/",
"coverage/*.json"
]
},
Expand All @@ -36,11 +38,27 @@
"npm/",
"**/*/*.js",
"**/*/npm/",
"**/*/.wrangler/",
"coverage/*.json"
]
},
"tasks": {
"test": "deno fmt && deno lint && deno test --import-map=./import_map.json -A --fail-fast --doc --coverage=coverage --parallel --allow-read",
"test:core": "cd packages/core && deno task test",
"test:chacha20poly1305": "cd packages/chacha20poly1305 && deno task test",
"test:dhkem-x25519": "cd packages/dhkem-x25519 && deno task test",
"test:dhkem-x448": "cd packages/dhkem-x448 && deno task test",
"test:dhkem-secp256k1": "cd packages/dhkem-secp256k1 && deno task test",
"test:hybridkem-x25519-kyber768": "cd packages/hybridkem-x25519-kyber768 && deno task test",
"test:hpke-js": "cd packages/hpke-js && deno task test",
"test:cloudflare": "deno task test:cloudflare:core && deno task test:cloudflare:chacha20poly1305 && deno task test:cloudflare:dhkem-x25519 && deno task test:cloudflare:dhkem-x448 && deno task test:cloudflare:dhkem-secp256k1 && deno task test:cloudflare:hybridkem-x25519-kyber768 && deno task test:cloudflare:hpke-js",
"test:cloudflare:core": "cd packages/core && deno task test:cloudflare",
"test:cloudflare:chacha20poly1305": "cd packages/chacha20poly1305 && deno task test:cloudflare",
"test:cloudflare:dhkem-x25519": "cd packages/dhkem-x25519 && deno task test:cloudflare",
"test:cloudflare:dhkem-x448": "cd packages/dhkem-x448 && deno task test:cloudflare",
"test:cloudflare:dhkem-secp256k1": "cd packages/dhkem-secp256k1 && deno task test:cloudflare",
"test:cloudflare:hybridkem-x25519-kyber768": "cd packages/hybridkem-x25519-kyber768 && deno task test:cloudflare",
"test:cloudflare:hpke-js": "cd packages/hpke-js && deno task test:cloudflare",
"cov": "deno coverage ./coverage --lcov --exclude='test'",
"dnt": "deno task dnt:core && deno task dnt:chacha20poly1305 && deno task dnt:dhkem-x25519 && deno task dnt:dhkem-x448 && deno task dnt:dhkem-secp256k1 && deno task dnt:hybridkem-x25519-kyber768 && deno task dnt:hpke-js",
"npm": "deno task dnt && deno task npm-link && deno task npm-pack",
Expand Down
1 change: 1 addition & 0 deletions packages/chacha20poly1305/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
},
"tasks": {
"test": "deno fmt && deno lint && deno test --import-map=../../import_map.json -A --fail-fast --doc --coverage=coverage --parallel --allow-read",
"test:cloudflare": "cd test/runtimes/cloudflare && npm install && npm link @hpke/core @hpke/chacha20poly1305 && npm run test",
"cov": "deno coverage ./coverage --lcov --exclude='test'",
"dnt": "deno run --import-map=../../import_map.json -A dnt.ts",
"minify": "esbuild ../../npm/packages/chacha20poly1305/esm/chacha20poly1305/mod.js --bundle --format=esm --minify"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { assertEquals } from "@std/assert";
import { describe, it } from "@std/testing/bdd";
import { SELF } from "cloudflare:test";
import { describe, expect, it } from "vitest";

describe("Cloudflare Workers", () => {
describe("GET /test", () => {
it("should return ok", async () => {
for (const kem of ["0x0010", "0x0011", "0x0012"]) {
for (const kdf of ["0x0001", "0x0002", "0x0003"]) {
const res = await fetch(
`http://localhost:8792/test?kem=${kem}&kdf=${kdf}`,
const res = await SELF.fetch(
`https://example.com/test?kem=${kem}&kdf=${kdf}`,
);
assertEquals("ok", await res.text());
expect(res.status).toBe(200);
expect(await res.text()).toBe("ok");
}
}
});
Expand Down
Loading

0 comments on commit d944e13

Please sign in to comment.