Updates
This commit is contained in:
@@ -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()
|
||||
})
|
||||
Reference in New Issue
Block a user