Initial Commit

This commit is contained in:
2026-05-27 23:47:53 +01:00
parent fbc70f96e6
commit 9b28db724f
18103 changed files with 1600554 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
import { createRegistry } from "@suaveplan/schema-registry";
import { describe, expect, it } from "@suaveplan/testing/runner";
import {
PACKER_CHUNK_FORMAT_V1,
PACKER_SUBJECTS,
registerPackerSchemas,
} from "./registration.js";
describe("registerPackerSchemas", () => {
it("registers every option schema as a subject with formatVersion 1 metadata", {
timeout: 5000,
}, () => {
const registry = createRegistry();
const reg = registerPackerSchemas(registry);
expect(reg.PackerOptions.metadata?.formatVersion).toBe("1");
expect(reg.UnpackOptions.metadata?.formatVersion).toBe("1");
expect(reg.ChunkedPackerOptions.metadata?.formatVersion).toBe("1");
expect(reg.Manifest.metadata?.formatVersion).toBe("1");
const subs = registry.listSubjects().sort();
expect(subs).toEqual([...PACKER_SUBJECTS].sort());
});
it("records packer-chunk-format V1 with binary encoding and BACKWARD compatibility", {
timeout: 5000,
}, () => {
const registry = createRegistry();
registerPackerSchemas(registry);
const latest = registry.getLatest("packer-chunk-format");
expect(latest.metadata?.formatVersion).toBe("1");
expect(latest.metadata?.encoding).toBe("binary");
expect(latest.format).toBe("custom");
// A second registration of the IDENTICAL V1 descriptor must
// succeed under the registry's BACKWARD default.
const compat = registry.checkCompatibility(
"packer-chunk-format",
PACKER_CHUNK_FORMAT_V1,
"custom"
);
expect(compat.compatible).toBe(true);
});
it("PACKER_CHUNK_FORMAT_V1 is a frozen V1 binary descriptor", {
timeout: 5000,
}, () => {
expect(Object.isFrozen(PACKER_CHUNK_FORMAT_V1)).toBe(true);
expect(PACKER_CHUNK_FORMAT_V1.formatVersion).toBe(1);
expect(PACKER_CHUNK_FORMAT_V1.headerSize).toBe(164);
expect(PACKER_CHUNK_FORMAT_V1.aead).toBe("xchacha20-poly1305");
expect(PACKER_CHUNK_FORMAT_V1.signature).toBe("ed25519");
});
});