The matcher comparison does not depend on the runtime, so it should run on every
runtime core supports. Only the Node suite ran it before.
The comparison and the app.fetch fixtures move into differential.ts and
app-fixture.ts, which use neither vitest nor a file API. Each runtime passes in
a loader for the frozen JSON. The vitest files use the same modules, plus a
Node check that the neutral runners report no mismatch, so the two paths cannot
drift.
- Deno and Bun: test/{deno,bun}/router-parity.test.ts run all 1158 frozen
matcher cases (hand-picked, owner, generated v1 and v2, WS) through the oracle
and the live router, plus the 55 app.fetch cases.
- workerd: test/edge/parity-worker.ts bundles the frozen JSON and runs the
same checks; test/edge/run.ts adds the phase after its existing assertions.
The Node-socket, WS-upgrade, boot and mesh captures stay Node-only: they need
http.request, the ws client, or a mesh peer on a port.
Refs #109
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
33 lines
1.5 KiB
TypeScript
33 lines
1.5 KiB
TypeScript
// Worker entry that runs the frozen router-parity differential inside workerd: every matcher case
|
|
// through the oracle and the live router, and the app.fetch cases, against the same frozen files the
|
|
// Node suite uses. The frozen JSON is bundled in, since a worker has no file system. Driven by
|
|
// test/edge/run.ts; see test/router-parity/README.md.
|
|
import { runDifferential } from '../router-parity/differential';
|
|
import { runAppDifferential } from '../router-parity/app-fixture';
|
|
import matcherHand from '../router-parity/frozen/matcher-hand.json';
|
|
import matcherOwner from '../router-parity/frozen/matcher-owner.json';
|
|
import matcherGenerated from '../router-parity/frozen/matcher-generated.json';
|
|
import matcherGeneratedV2 from '../router-parity/frozen/matcher-generated-v2.json';
|
|
import matcherWs from '../router-parity/frozen/matcher-ws.json';
|
|
import appFetch from '../router-parity/frozen/app-fetch.json';
|
|
import ownerAppAllow from '../router-parity/frozen/owner-app-allow.json';
|
|
|
|
const FROZEN: Record<string, unknown> = {
|
|
'matcher-hand': matcherHand,
|
|
'matcher-owner': matcherOwner,
|
|
'matcher-generated': matcherGenerated,
|
|
'matcher-generated-v2': matcherGeneratedV2,
|
|
'matcher-ws': matcherWs,
|
|
'app-fetch': appFetch,
|
|
'owner-app-allow': ownerAppAllow,
|
|
};
|
|
|
|
export default {
|
|
fetch: async (): Promise<Response> => {
|
|
const load = (name: string) => FROZEN[name];
|
|
const matcher = await runDifferential(load);
|
|
const app = await runAppDifferential(load);
|
|
return Response.json({ matcher, app });
|
|
},
|
|
};
|