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
MCP
blame on this site's /mcp
CLI
abso blame server/test/blobs.test.ts --json
JSON
/christopher/abso-core/blame/server/test/blobs.test.ts?format=json
44 linesspeed 100%Last change speed in version 150,

44 lines from 1 change in 1 version.

speed150Open server: the project Worker, Durable Object and Artifacts (issue 17)Compare1import assert from "node:assert/strict";
2import { createHash } from "node:crypto";
3import { before, describe, it } from "node:test";
4import { BlobStore } from "../src/blobs.ts";
5import { installDigestStream, memoryStorage, streamOf } from "./helpers.ts";
6
7const sha = (text: string) => createHash("sha256").update(text).digest("hex");
8
9describe("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});