61 lines
2.2 KiB
JavaScript
61 lines
2.2 KiB
JavaScript
import test from 'brittle'
|
|
import { readFile } from 'node:fs/promises'
|
|
import { dirname, join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { createContext, runInContext } from 'node:vm'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
const snapshotPath = join(__dirname, '../lib/baretop-snapshot.js')
|
|
const helpersPath = join(__dirname, '../lib/baretop-ui-helpers.js')
|
|
const tuiPath = join(__dirname, '../lib/baretop-tui.js')
|
|
|
|
test('baretop snapshot supports extended missing-signal hints', async (t) => {
|
|
const src = await readFile(snapshotPath, 'utf8')
|
|
t.ok(src.includes('BARE_TOP_SNAPSHOT_EXTENDED_HINT_KEYS'))
|
|
t.ok(src.includes('BARE_TOP_MISSING_SIGNALS'))
|
|
t.ok(src.includes("profile: snapshotProfile"))
|
|
t.ok(src.includes('snapshotBytesByKey'))
|
|
t.ok(src.includes('procIndexAvailability'))
|
|
})
|
|
|
|
test('network deep-dive helper lines are available', async (t) => {
|
|
const src = await readFile(helpersPath, 'utf8')
|
|
const ctx = createContext({})
|
|
runInContext(src, ctx)
|
|
const extra = {
|
|
routeSummary: { directCount: 8, relayCount: 2 },
|
|
holepunchSummary: { attempts: 4, ok: 3 },
|
|
swarmDoctor: { verdict: 'degraded', remediation: ['check relay'] },
|
|
dhtScan: { firewalled: false, bootstrapReachable: true, randomizedEndpoints: true },
|
|
meshdrop: { rxTotal: 9, txTotal: 7 },
|
|
peerDetails: {
|
|
peers: [
|
|
{
|
|
remotePublicKey: 'abcdef',
|
|
state: 'connected',
|
|
endpoint: { address: '1.2.3.4', port: 4242 },
|
|
peerOs: { osHint: 'linux' }
|
|
}
|
|
]
|
|
}
|
|
}
|
|
const dd = ctx.bareTopNetworkDeepDiveLines(extra, 120)
|
|
const dht = ctx.bareTopDhtScanPostureLines(extra)
|
|
const md = ctx.bareTopMeshdropLines(extra)
|
|
const peers = ctx.bareTopPeerDetailsLines(extra, 120)
|
|
t.ok(dd.length >= 1)
|
|
t.ok(dht.length === 1)
|
|
t.ok(md.length === 1)
|
|
t.ok(peers.length >= 1)
|
|
})
|
|
|
|
test('tui includes missing-signal sections and process detail panes', async (t) => {
|
|
const src = await readFile(tuiPath, 'utf8')
|
|
t.ok(src.includes('network deep-dive'))
|
|
t.ok(src.includes('Prom counters:'))
|
|
t.ok(src.includes("sub:"))
|
|
t.ok(src.includes("procDetailSub === 'io'"))
|
|
t.ok(src.includes("procDetailSub === 'threads'"))
|
|
t.ok(src.includes("procDetailSub === 'maps'"))
|
|
})
|