@githolon/testing

中文文档
0.122.2发布于 2026/11/11SEE LICENSE IN LICENSE.mdTypeScriptES Module近 30 天下载 2726

@githolon/testing — Law TDD通过每个Nomos平台外壳使用的同名Runtime v2 Pere Office.

中文使用文档
文档目录4 节
  1. 水面 水面
  2. 决定时钟( R)
  3. 食谱
  4. 跑步时间是怎样来的(这本原话,老实说)

@githolon/testing-Nomos域的法律TDD

测试你的律法 任何同行判断它的方式. testHolon() 靴子峡谷 同行办公室 正在与节点本地开发平台进行中 (原始内容存档于2012-10-12) (英语). wasm32-wasp1 内核文物——每个平台使用的相同生命周期——安装了您 将律法编成起源, 并给你一个喇叭 通过编译器生成的接收器从vitest驱动(build/<name>.reception.mjs) (中文(简体) ). 无物被模拟:每个生成的呼叫运行真实 作者出道口(载荷 zod ) 计划再运行 出道口 出道口 出道口 出道口 出道口 出道口 出道口 出道口 出道口 出道口 出道口 出道口 出道口 出道口 出道口 出道口口 出道口 出道口口 出道口 出道口口 出道口 出道口 出道口出道口 出道口出道 出道口出道口出道口出道 出道口出道 出道口出道口出道口出道口口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道口出道 被封在铁链上 verify() 是同一个原 verify_chain 页:1 云运行于上传生.

npm i -D @githolon/testing vitest
npx nomos-compile    # your canonical law → build/<name>.law.usdz
import { describe, expect, it } from "vitest";
import { testHolon } from "@githolon/testing";
import { seatsClient } from "./build/seats.reception.mjs";

it("the law refuses an over-capacity booking", async () => {
  const h = await testHolon({ law: "./build/seats.law.usdz", deterministic: true });
  const app = h.app(seatsClient, { actor: "person:alice" });
  const b = await app.openBooking({ label: "launch", capacity: 2 });
  await app.takeSeat({ bookingId: b.booking, attendee: "ada", takenAt: T });
  await app.takeSeat({ bookingId: b.booking, attendee: "bob", takenAt: T });

  // THE HEADLINE — invariants are real law; the refusal carries the law's own reject code:
  await expect(
    app.takeSeat({ bookingId: b.booking, attendee: "eve", takenAt: T }),
  ).rejects.toThrow(/seats-exceed-capacity/);
});

水面 水面

const h = await testHolon({
  law: "./build/<name>.law.usdz", // opaque canonical archive; the kernel composes and identifies it
  deterministic: true,                  // pinned clock + seeded rng + fixed replica (below)
});
const app = h.app(generatedClient, { actor: "person:alice" });

await app.someBusinessAction(typedPayload); // compiler-generated payload, result and USDA codec
await app.someDeclaredQuestion(typedParams); // compiler-generated nominal query + typed decoder

h.intents();                // the chain, parsed — genesis installs first, then every dispatch
h.verify();                 // the wasm verify_chain verdict (the cloud's upload-birth gate)
await h.fork();             // a cheap what-if branch — a fresh engine cold-mounting the
                            // exact tree bytes; fork dispatches never touch the parent
await h.device();           // another offline device starting from this exact state
await h.sync(peer);         // idempotent exchange; conflicts remain typed domain data
await h.restart();          // cold rebuild from ledger history, never a trusted snapshot
h.lawHash;                  // sha256(package bytes) — the content-addressed law id
h.kernelSha256;             // exact provider-selected kernel fetched, verified and cached by digest

Refusal 已输入 : { name: "Refusal", domain, directiveId, refusal } 与 逐字记录 message - 有效载荷 -- -- schema拒绝、缺失事例和 被宣布的无变种人全部通过同一条道到达,与边缘完全相同.

决定时钟( R)

计划是纯粹的功能 (payload, ports)被俘虏的人质 钟和Rng 在每个意图的信封。 绳子都钉在那主机上 边框( 以同步作者调用为范围 —— 引擎未受影响 ) :

// the shorthand: clock 2026-01-01 advancing +1s/intent, seed 42, replica 7
const h = await testHolon({ law, deterministic: true });

// or granular:
const h = await testHolon({
  law,
  clock: { start: "2026-01-01T00:00:00.000Z", stepMs: 1000 }, // or an ISO/ms start, or () => now
  seed: 7,        // minted ids reproduce run-to-run
  replica: 99,    // the 63-bit replica id on every captured clock
});

await app.someBusinessAction(payload);

同样的种子 + 时钟 + 复制 + QQ 字节相同历史相同的薄荷身份证, 同样的链子头,运行后运行。 (记住: 域名时间戳仍然搭入 IN 您的有效载荷作为 ISO 字符串—— 捕获的时钟是信封的,而不是您的 诸法相. )

食谱

测试一个不变量 (自无常门落地以来) 在作者处所、收监和核实的变量:

await expect(app.takeSeat(overCapacityPayload))
  .rejects.toThrow(/seats-exceed-capacity/);
expect(h.intents().length).toBe(before);   // a refusal commits NOTHING
expect(h.verify().valid).toBe(true);       // the chain stays green

测试合并驱动程序 - 合并是法律:

await app.tagEntry({ entry: entry.ref, tags: ["kind"] });
await app.tagEntry({ entry: entry.ref, tags: ["warm", "kind"] });
expect((await app.entries.find(entry.ref)).tags).toEqual(["kind", "warm"]); // AddWins unions

await app.reactToEntry({ entry: entry.ref, reactor: "bob", reaction: "👏", reactedAt });
await app.reactToEntry({ entry: entry.ref, reactor: "bob", reaction: "💚", reactedAt: later });
expect((await app.entries.find(entry.ref)).reactions).toEqual({ bob: "💚" }); // MapOf(Lww)

测试一个衍生字段 ——发动机预测,从未入帐:

const { entry } = await app.signGuestbook({ mood: "grumpy", ... });
expect((await app.entries.find(entry)).moodEmoji).toBe("😠");          // projected
expect(JSON.stringify(h.intents().at(-1))).not.toContain("moodEmoji"); // never sealed

如果在叉子上的话 - 无后果分支:

const f = await h.fork();
const forkApp = f.app(generatedClient);
await expect(forkApp.breachingWrite(payload)).rejects.toThrow(/your-code/);
await forkApp.somethingElse(payload); // lands on the fork; parent app remains unchanged

跨越两个离线设备生成的外观 无内核、意图或 租户测试中的工作空间管道:

import { co2Client } from "../build/co2.reception";

const alice = await testHolon({ law: "./build/co2.law.usdz", deterministic: true });
const aliceApp = alice.app(co2Client, { actor: "person:alice" });
await aliceApp.addSite({ estateId, name: "Trafford Depot" });

const bob = await alice.device();
const bobApp = bob.app(co2Client, { actor: "person:bob" });
await aliceApp.mergeAssetStatus({ assetId, operationalStatus: "operational" });
await bobApp.mergeAssetStatus({ assetId, operationalStatus: "inspection-due" });

await alice.sync(bob);
const [conflict] = await aliceApp.conflicts.asset.pending();
await conflict.merge(() => "operational-after-inspection");

const restarted = await alice.restart();
expect(restarted.verify().valid).toBe(true);

工作实例: 这个软件包自己的套件( Nametest/harness.test.mjs,座位 petture)和客本实例的法律测试 (单位:千美元)examples/guestbook/test/law.test.mts) (中文(简体) ).

跑步时间是怎样来的(这本原话,老实说)

节点平台壳牌和犬类同行办公室 构建时捆入此包 从源模块。 释放携带 只有生产内核的SHA-256描述符——而不是专有可执行文件. 第一次击出胜利:

  1. runtimeDir 选项/ NOMOS_OFFLINE_RUNTIME (或仅测试) GITHOLON_RUNTIME_DIR)——您控制的一个目录 持有 {holon.wasm, bootstrap.law.usdz, nomos.law.usdz}。该主题必须匹配此包 固定释放文摘。 在 CI 中按下此目录, 以进行完全的隐形运行 .
  2. 单曲 诺姆斯2雷波, cloud/cloudflare-shell销售商 d. 直接使用dam +域名文物。 从来没有任何网络.
  3. 释放缓存 —— 说 ~/.holon/runtime/kernels/<release-sha> (单位:千美元)HOLON_CONFIG_DIR (原始内容存档于2017-03-25). overse.
  4. 论云 ——取出不可磨灭之物 /v1/runtime/kernels/<release-sha>/holon.wasm 加上公共框架 软件包从 https://nomos.cafe (单位:千美元)cloud 选项/ NOMOS_CLOUD 覆盖). 诺摩斯先核实字节后再去抓取.

除了单曲之外的每一道在Web Assembly(CAP-813)开始前都会验证内核的SIGNATURE:提供方 向安保部提供内核证明(/v1/runtime/kernels/<sha>/attestation.dsse.json)和释放键 证书集( e)/v1/runtime/kernel-release-key.certificate.dsse.json; 对照信任根进行验证 此包针并缓存到内核旁边 kernel.attestation.dsse.json 财务报告和审定财务报表 kernel-release-key.certificate.dsse.jsonA级 runtimeDir 必须携带两个文件。 未签署、外国或 已过期内核被键入拒绝 KernelAttestationRefused 命名失败的链接。 你造的内核 仅在明确的本地开发选择下运行 NOMOS_LOCAL_DEV_KERNEL_TRUST_ROOT=<your local-dev root> (由签一个字的工具所印出) 绳子每次都会在板上公布.

因此:FIRST运行在单人机外的一款新鲜机器上需要网络 一次 一次吗. offline: true (或 GITHOLON_TESTING_OFFLINE=1禁止4号车道——你 获得一个明确错误来命名您的选项而不是一个惊喜获取 。 一个被遗忘或 不同的内核在Web Assembly开始前被拒绝.

版本与发布记录

@githolon/testing 共发布 266 个版本,首次发布于 2026/06/12;过去 12 个月发布了 266 个版本。

版本发布日期距今
0.122.2latest2026/11/115 天前
0.119.392026/10/2323 天前
0.119.382026/10/2323 天前
0.119.372026/10/2324 天前
0.119.362026/10/2324 天前
0.119.352026/10/2324 天前

关于 @githolon/testing 的常见问题

@githolon/testing 是什么?

@githolon/testing — Law TDD通过每个Nomos平台外壳使用的同名Runtime v2 Pere Office.

如何安装 @githolon/testing?

在项目目录运行 npm install @githolon/testing,或使用 pnpm add / yarn add / bun add。

@githolon/testing 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@githolon/testing 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@githolon/testing 可以商用吗?

@githolon/testing 使用 SEE LICENSE IN LICENSE.md 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@githolon/testing 的下载量有多少?

根据 npm 官方下载统计,@githolon/testing 在 2026/10/17 – 2026/11/15 这 30 天内被下载 2,726 次,日均约 91 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@githolon/testing 还在维护吗?

最新版本 0.122.2 发布于 2026/11/11(5 天前);至今共发布 266 个版本,其中过去 12 个月发布了 266 个;首次发布于 2026/06/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。