Initial commit

This commit is contained in:
Zoe
2026-08-07 22:13:25 -05:00
commit 8006fd67f3
40 changed files with 11017 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import test from "node:test";
import assert from "node:assert/strict";
import { loadModule } from "./test-helpers.mjs";
const contract = await loadModule("shared/utils/drop-contract.ts");
const types = await loadModule("shared/types/drop.ts");
const valid = {
version: 2,
chunkSize: types.CHUNK_SIZE,
chunkCount: 1,
noncePrefix: "AQIDBAUGBwg",
expiresIn: "24h",
maxReads: 1,
};
test("reservation validation accepts protocol geometry and rejects unsafe policies", () => {
assert.deepEqual(contract.validateReservation(valid), valid);
for (const bad of [
{ ...valid, chunkSize: 1 },
{ ...valid, chunkCount: 0 },
{ ...valid, chunkCount: 1.5 },
{ ...valid, expiresIn: "forever" },
{ ...valid, maxReads: 2 },
{ ...valid, unknown: true },
{ ...valid, noncePrefix: "AA" },
])
assert.throws(() => contract.validateReservation(bad));
});
test("manifest body must contain plaintext as well as the GCM tag", () => {
assert.throws(() => contract.validateManifestBodyLength(types.GCM_TAG_BYTES));
assert.doesNotThrow(() =>
contract.validateManifestBodyLength(types.GCM_TAG_BYTES + 1),
);
});