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,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()
})