Add storage stack modules and track them in git
The modules workspace previously ignored every path matching `storage-*`, which kept all Hypercore, Hyperbee, Hyperdrive, and Autobase packages out of version control. Narrow .gitignore to test-artifact patterns only so production category trees are committed. Storage packages (23 total): - storage-hypercore (7): replicator, seed-policy, fork-picker, merkle-sync, priority-fetch, bitfield-scheduler, audit-chain - storage-hyperbee (5): batch-write, diff-follow, range-watch, secondary-index, tombstone-gc - storage-hyperdrive (6): entry-catalog, gc-sweep, mirror-sync, mount-bridge, version-snapshot, watch-notify - storage-autobase (5): fork-choice, view-sync, writer-lease, indexer-bus, light-writer Implementation highlights: - Shared attach/gossip helpers in _shared/storage-gossip-base.js - P2P modules use Protomux gossip via p2p-bare; local planners omit swarm - Recent deepen pass: priority queues, batch caps, audit export/import, watch/notify aliases on range-watch, fork/view lease helpers, etc. - Per-package README, docs/api.md, docs/architecture.md, tests, examples Also update modules/README.md doc hub links for the full storage stack (hypercore, hyperbee, hyperdrive, autobase). Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
require('bare-process/global')
|
||||
const test = require('brittle')
|
||||
const { HyperP2PCoreAuditChain, PROTOCOL } = require('../index.js')
|
||||
|
||||
const mockCore = { length: 3 }
|
||||
|
||||
test('exports', (t) => {
|
||||
t.ok(HyperP2PCoreAuditChain)
|
||||
t.is(PROTOCOL, 'core-audit-chain/v1')
|
||||
})
|
||||
|
||||
test('appendAudit verifyChain tail', async (t) => {
|
||||
const m = new HyperP2PCoreAuditChain()
|
||||
m.attach(mockCore)
|
||||
m.appendAudit({ op: 'init' })
|
||||
m.appendAudit({ op: 'write' })
|
||||
const v = m.verifyChain()
|
||||
t.ok(v.ok)
|
||||
t.is(m.tail(1).length, 1)
|
||||
t.is(m.tail(2).length, 2)
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('validation', async (t) => {
|
||||
const m = new HyperP2PCoreAuditChain()
|
||||
try { m.appendAudit(null) } catch (e) { t.ok(e) }
|
||||
try { m.attach(null) } catch (e) { t.ok(e) }
|
||||
try { m.tail(-1) } catch (e) { t.ok(e) }
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('getStats', async (t) => {
|
||||
const m = new HyperP2PCoreAuditChain()
|
||||
m.appendAudit({ x: 1 })
|
||||
const s = m.getStats()
|
||||
t.is(s.protocol, 'core-audit-chain/v1')
|
||||
t.is(s.length, 1)
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('exportChain importChain', async (t) => {
|
||||
const m = new HyperP2PCoreAuditChain()
|
||||
m.appendAudit({ op: 'a' })
|
||||
m.appendAudit({ op: 'b' })
|
||||
const exported = m.exportChain()
|
||||
const m2 = new HyperP2PCoreAuditChain()
|
||||
const v = m2.importChain(exported)
|
||||
t.ok(v.ok)
|
||||
t.is(m2.getStats().length, 2)
|
||||
await m.close()
|
||||
await m2.close()
|
||||
})
|
||||
|
||||
test('broken chain detected', async (t) => {
|
||||
const m = new HyperP2PCoreAuditChain()
|
||||
m.appendAudit({ a: 1 })
|
||||
m._chain[0].hash = 'bad'
|
||||
const v = m.verifyChain()
|
||||
t.not(v.ok)
|
||||
await m.close()
|
||||
})
|
||||
Reference in New Issue
Block a user