Updates
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
require('bare-process/global')
|
||||
const test = require('brittle')
|
||||
const { HyperP2PBandwidthBroker } = require('../index.js')
|
||||
|
||||
test('hyper-p2p-bandwidth-broker: basic operation', async (t) => {
|
||||
const m = new HyperP2PBandwidthBroker()
|
||||
m.grant('peer-a', 1000)
|
||||
t.ok(m.consume('peer-a', 400))
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('hyper-p2p-bandwidth-broker: validation', async (t) => {
|
||||
const m = new HyperP2PBandwidthBroker()
|
||||
try {
|
||||
m.grant(null, -1)
|
||||
t.fail('expected throw')
|
||||
} catch (e) {
|
||||
t.ok(e instanceof Error)
|
||||
}
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('hyper-p2p-bandwidth-broker: getStats', async (t) => {
|
||||
const m = new HyperP2PBandwidthBroker()
|
||||
const s = m.getStats()
|
||||
t.ok(s)
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('hyper-p2p-bandwidth-broker: close idempotent', async (t) => {
|
||||
const m = new HyperP2PBandwidthBroker()
|
||||
await m.close()
|
||||
await m.close()
|
||||
t.pass()
|
||||
})
|
||||
Reference in New Issue
Block a user