Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 35 to 318

Compare

+44 −0 in 1 place
new file, 44 lines
1+import assert from "node:assert/strict";
2+import { createHash } from "node:crypto";
3+import { before, describe, it } from "node:test";
4+import { BlobStore } from "../src/blobs.ts";
5+import { installDigestStream, memoryStorage, streamOf } from "./helpers.ts";
6+
7+const sha = (text: string) => createHash("sha256").update(text).digest("hex");
8+
9+describe("the blob store", () => {
10+ before(installDigestStream);
12+ it("keeps bytes whose SHA-256 is their name", async () => {
13+ const store = new BlobStore(memoryStorage());
14+ const a = await store.put(sha("hello"), streamOf("hello"));
15+ assert.deepEqual(a, { status: 200, body: { sha256: sha("hello"), size: 5, stored: true } });
16+ assert.equal(store.has(sha("hello")), true);
17+ assert.equal(new TextDecoder().decode(store.read(sha("hello"))!), "hello");
18+ const again = await store.put(sha("hello"), streamOf("hello"));
19+ assert.equal((again.body as { stored: boolean }).stored, false);
20+ });
22+ it("refuses bytes that hash to something else, and keeps nothing", async () => {
23+ const store = new BlobStore(memoryStorage());
24+ const a = await store.put(sha("hello"), streamOf("goodbye"));
25+ assert.equal(a.status, 400);
26+ assert.match((a.body as { error: string }).error, new RegExp(`hash to ${sha("goodbye")}`));
27+ assert.equal(store.has(sha("hello")), false);
28+ assert.equal(store.has(sha("goodbye")), false);
29+ assert.deepEqual(store.list("", 10), { blobs: [], next: null });
30+ });
32+ it("refuses a name that isn't a lowercase SHA-256", async () => {
33+ const store = new BlobStore(memoryStorage());
34+ assert.equal((await store.put("abc", streamOf("x"))).status, 400);
35+ assert.equal((await store.put(sha("x").toUpperCase(), streamOf("x"))).status, 400);
36+ });
38+ it("refuses a blob over the size cap", async () => {
39+ const store = new BlobStore(memoryStorage());
40+ const a = await store.put(sha("too big"), streamOf("too big"), 3);
41+ assert.equal(a.status, 413);
42+ assert.equal(store.total(), 0);
43+ });
44+});
MCP
compare on this site's /mcp
CLI
abso diff 35 318 server/test/blobs.test.ts --json
JSON
/christopher/abso-core/compare/35..318?file=server%2Ftest%2Fblobs.test.ts&format=json