Initial import of verae-archive-worm from zapier monorepo
This commit is contained in:
commit
1a23c1f6a5
6 changed files with 145 additions and 0 deletions
28
test/archive.test.js
Normal file
28
test/archive.test.js
Normal 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);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue