import test from 'brittle' import { readFile } from 'node:fs/promises' import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' const __dirname = dirname(fileURLToPath(import.meta.url)) const coreutilsRoot = join(__dirname, '..') const kernelBin = join(__dirname, '../../../kernel/bin') async function read(p) { return readFile(p, 'utf8') } test('p2p TUI bins include ctx.tui.run after build', async (t) => { const names = [ 'swarmtop', 'dhttop', 'swarmmap', 'routeview', 'holepunch-view' ] for (const name of names) { const src = await read(join(kernelBin, name)) t.ok(src.includes('ctx.tui.run'), name + ' uses ctx.tui.run') t.ok( src.includes('bareP2pCreateSimpleTuiApp'), name + ' includes TEA factory' ) } }) test('p2p suite commands include shared envelope helper in kernel bins', async (t) => { const names = [ 'swarmtop', 'meshdrop', 'taskmesh', 'peernote', 'hypershell-board', 'p2ping', 'dhtscan', 'dhttop', 'swarmdoctor', 'swarmmap', 'peerdiscover', 'p2ptrace', 'peerctl', 'routeview', 'holepunch-view' ] for (const name of names) { const src = await read(join(kernelBin, name)) t.ok(src.includes('BARE_P2P_SUITE_PREFIX'), name + ' includes p2p preamble') t.ok( src.includes('async function run(ctx, argv)'), name + ' includes run()' ) } }) test('p2p suite man pages exist', async (t) => { const pages = [ 'swarmtop', 'meshdrop', 'taskmesh', 'peernote', 'hypershell-board', 'p2ping', 'dhtscan', 'dhttop', 'swarmdoctor', 'swarmmap', 'peerdiscover', 'p2ptrace', 'peerctl', 'routeview', 'holepunch-view' ] for (const page of pages) { const body = await read(join(coreutilsRoot, 'man/pages', page + '.json')) t.ok(body.includes('"name": "' + page + '"'), page + ' man page present') } })