Add e2e script to the repo, Dockerfile, and a Nix flake with a NixOS module

- scripts/e2e.sh (+ scripts/e2e/*.ts): the two-node end-to-end test, now
  self-contained and cleaning up after itself; `make e2e`, part of `make check`
- Dockerfile/.dockerignore: static Go build in a non-root alpine image, data in
  /data, defaults to region u1j; `make docker`
- flake.nix, nix/: package (buildGoModule), dev shell, NixOS module
  services.allmende (hardened systemd unit that waits for `allmende-admin init`),
  and a NixOS VM test run by `nix flake check`
- README: running a node with Docker and NixOS

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 21:21:21 +01:00
co-authored by Claude Sonnet 5.5
parent dc690a72c9
commit 20ea9b32f7
13 changed files with 604 additions and 2 deletions
+31
View File
@@ -0,0 +1,31 @@
// A stand-in for the browser, for the e2e script: node buyer.ts send|read <gateway> <author> <id> [secretHex]
import { buildToOwner, mailbox, newThreadSecret, openReply, threadPublic, toHex } from "../../web/src/message.ts";
import { canonicalize } from "../../web/src/jcs.ts";
const [cmd, gw, author, id, secretHex] = process.argv.slice(2) as [string, string, string, string, string?];
const now = Math.floor(Date.now() / 1000);
if (cmd === "send") {
const listing = (await (await fetch(`${gw}/api/v1/listings/${author}/${id}`)).json()) as { device: string };
const status = (await (await fetch(`${gw}/api/v1/status`)).json()) as { message_difficulty: number };
const secret = newThreadSecret();
const env = await buildToOwner({
listing: { author, id, device: listing.device },
threadSecret: secret,
text: secretHex ?? "Ist die Wohnung noch frei?",
n: 1,
now,
difficulty: status.message_difficulty,
first: true,
});
const res = await fetch(`${gw}/api/v1/messages`, { method: "POST", body: canonicalize(env) });
if (res.status !== 202) throw new Error(`post: ${res.status} ${await res.text()}`);
console.log(toHex(secret));
} else {
const secret = Uint8Array.from(Buffer.from(secretHex!, "hex"));
const envs = (await (await fetch(`${gw}/api/v1/messages?mailbox=${mailbox(threadPublic(secret))}&since=${now - 7200}`)).json()) as unknown[];
for (const e of envs) {
const r = openReply(e, secret, { author, id });
console.log(r.ok ? `OK ${r.plain.t} ${r.plain.text ?? r.plain.address}` : `BAD ${r.error}`);
}
}
+10
View File
@@ -0,0 +1,10 @@
// Prints the draft the UI's Renew button would PUT for a listing, read from stdin (the listing JSON).
import { readFileSync } from "node:fs";
import { draftFromListing } from "../../web/src/draft.ts";
import type { Listing } from "../../web/src/verify.ts";
const l = JSON.parse(readFileSync(0, "utf8")) as Listing;
const title = process.argv[2];
const d = draftFromListing(l, Number(process.argv[3] ?? 30));
if (title) d.title = title;
process.stdout.write(JSON.stringify(d));