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); }); });