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 { HyperP2PCongestionSignal } = require('../index.js')
test('hyper-p2p-congestion-signal: basic operation', async (t) => {
const m = new HyperP2PCongestionSignal()
m.reportSample('p1', 50, 0.1)
t.ok(m.getHint('p1').sendRateBps > 0)
await m.close()
})
test('hyper-p2p-congestion-signal: validation', async (t) => {
const m = new HyperP2PCongestionSignal()
try {
m.reportSample(null, -1, 0)
t.fail('expected throw')
} catch (e) {
t.ok(e instanceof Error)
}
await m.close()
})
test('hyper-p2p-congestion-signal: getStats', async (t) => {
const m = new HyperP2PCongestionSignal()
const s = m.getStats()
t.ok(s)
await m.close()
})
test('hyper-p2p-congestion-signal: close idempotent', async (t) => {
const m = new HyperP2PCongestionSignal()
await m.close()
await m.close()
t.pass()
})