import assert from 'node:assert/strict'; import test from 'node:test'; import { createSingboxSelectorService } from '../../dist/server/services/singboxSelectorService.js'; test('selector waits for the sing-box API after a fresh process start', async () => { let attempts = 0; const service = createSingboxSelectorService({ port: 0, send: async (method) => { attempts += 1; if (attempts < 3) throw Object.assign(new Error('not ready'), { code: 'ECONNREFUSED' }); return method === 'GET' ? { now: 'channel-primary' } : {}; }, }); assert.deepEqual(await service.select('primary'), { role: 'primary' }); assert.equal(attempts, 4); });