This commit is contained in:
Raven Scott
2026-05-20 21:02:45 -04:00
parent 1f3f4b24a2
commit 14d0980b4f
734 changed files with 682 additions and 746 deletions
@@ -0,0 +1,26 @@
require('bare-process/global')
const test = require('brittle')
const { HyperP2PTopicLease } = require('../index.js')
test('topic-lease: acquire renew release', async (t) => {
const l = new HyperP2PTopicLease({ leaseMs: 60000 })
const r = l.acquire('shard-1')
t.ok(r.ok)
t.ok(l.renew('shard-1'))
t.is(l.holderOf('shard-1'), l.ownerHex)
t.ok(l.release('shard-1'))
t.is(l.holderOf('shard-1'), null)
await l.close()
})
test('topic-lease: no background timer default', async (t) => {
const l = new HyperP2PTopicLease()
t.is(l.enableBackgroundTimers, false)
t.is(l._timer, null)
await l.close()
})
test('hyper-p2p-topic-lease: close without leak', async (t) => {
const m = new HyperP2PTopicLease()
await m.close()
t.pass()
})