// Abstract-namespace UNIX socket transport (the '@'-prefixed path). Exercises
// the full UdsServer + Client RPC round-trip over an abstract socket, which is
// how the daemon runs where SELinux denies pathname sockets (unrooted Android /
// celltron). Stream I/O is done by stock bare-pipe; bare-abstract-socket only
// creates the socket. Linux-only (abstract sockets are a Linux extension).
import test from 'brittle'
import { UdsServer } from '../lib/transports/uds.js'
import { Client } from '../lib/client.js'
test('RPC over an abstract-namespace UNIX socket (@-prefix)', async (t) => {
const NAME = '@hyper-svc-abstract-test'
const server = new UdsServer({
path: NAME,
idleTimeout: 0,
dispatch: async (method, params) => {
if (method === 'echo') return { echoed: params }
throw new Error('unknown method: ' + method)
}
})
await server.listen()
t.teardown(() => server.close())
t.ok(server.listening, 'server is listening on the abstract name')
const client = await Client.connectUds(NAME)
t.teardown(() => client.close())
const res = await client.call('echo', { hi: 'celltron' })
t.alike(res, { echoed: { hi: 'celltron' } }, 'RPC round-trips over the abstract socket')
})