Initial import of verae-archive-worm from zapier monorepo

This commit is contained in:
George Lambert 2026-09-11 16:18:38 -04:00
commit 012684ca23
7 changed files with 179 additions and 0 deletions

28
test/archive.test.js Normal file
View file

@ -0,0 +1,28 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { WormArchive } from '../src/archive.js';
import { Bloom } from '../src/bloom.js';
describe('WormArchive + Bloom', () => {
it('miss stays silent (null)', () => {
const a = new WormArchive('archive-a');
assert.equal(a.query('a'.repeat(64)), null);
});
it('put then query returns records', () => {
const a = new WormArchive('archive-b');
const sha = 'b'.repeat(64);
a.put({ sha256: sha, kind: 'publicMeta', record: { publicMetadata: { t: 1 } } });
const hit = a.query(sha);
assert.ok(Array.isArray(hit));
assert.equal(hit[0].kind, 'publicMeta');
assert.equal(hit[0].archiveId, 'archive-b');
});
it('bloom reports maybe after add', () => {
const b = new Bloom();
assert.equal(b.mightHave('hello'), false);
b.add('hello');
assert.equal(b.mightHave('hello'), true);
});
});