mirror of
https://github.com/hanzoai/trust.git
synced 2026-10-30 14:54:58 +00:00
92 lines
3.2 KiB
JavaScript
92 lines
3.2 KiB
JavaScript
// Loads a bundle in an isolated node:vm context with only the globals the Go
|
|
// host provides. If a test passes here, the artifact that ships is the thing
|
|
// that passed — not the TypeScript it was built from.
|
|
//
|
|
// The context is deliberately spare: no `require`, no `process`, no `fetch`, no
|
|
// `Date.now`. Anything the bundle reaches for that is not listed here is a bug
|
|
// in the bundle, and it surfaces as a ReferenceError rather than as a surprise
|
|
// in production.
|
|
|
|
import { readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname, join } from "node:path";
|
|
import vm from "node:vm";
|
|
import { build } from "../build.mjs";
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
|
|
export const NOW = 1_760_000_000_000; // a fixed clock, so `generated` is exact
|
|
|
|
// The tenant store, as the Go host presents it: the four statements db.ts
|
|
// issues, over a map. It is a MODEL of the host and not a second SQLite — the Go
|
|
// side runs the real one against the real schema, and its own test is what says
|
|
// the two agree. Keeping it here means a bundle test never needs a database.
|
|
function store() {
|
|
const rows = new Map(); // "kind |