This commit is contained in:
Raven Scott
2026-05-20 20:19:20 -04:00
parent 040f1d05ea
commit d70060ec4e
365 changed files with 23547 additions and 431 deletions
+35
View File
@@ -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()
})