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
+38
View File
@@ -0,0 +1,38 @@
require('bare-process/global')
const test = require('brittle')
const { HyperP2PAnycastSelector } = require('../index.js')
test('hyper-p2p-anycast-selector: basic operation', async (t) => {
const m = new HyperP2PAnycastSelector()
m.registerCapability('compute', 'peer-a')
m.registerCapability('compute', 'peer-b')
m.updateLatency('peer-a', 10)
m.updateLatency('peer-b', 50)
t.is(m.resolve('compute'), 'peer-a')
await m.close()
})
test('hyper-p2p-anycast-selector: validation', async (t) => {
const m = new HyperP2PAnycastSelector()
try {
m.resolve(null)
t.fail('expected throw')
} catch (e) {
t.ok(e instanceof Error)
}
await m.close()
})
test('hyper-p2p-anycast-selector: getStats', async (t) => {
const m = new HyperP2PAnycastSelector()
const s = m.getStats()
t.ok(s)
await m.close()
})
test('hyper-p2p-anycast-selector: close idempotent', async (t) => {
const m = new HyperP2PAnycastSelector()
await m.close()
await m.close()
t.pass()
})