Skip to content

Commit 5d706a5

Browse files
committed
Improve mainnet probe observability
1 parent ab38a23 commit 5d706a5

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

test/helpers/probe.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -736,12 +736,37 @@ function runDevToolsCommand(
736736
shellQuote(JSON.stringify(payload)),
737737
].join(' ');
738738

739-
return execFileSync('adb', ['shell', command], {
740-
encoding: 'utf8',
741-
timeout: (timeoutSeconds + 10) * 1000,
742-
});
739+
try {
740+
return execFileSync('adb', ['shell', command], {
741+
encoding: 'utf8',
742+
timeout: (timeoutSeconds + 10) * 1000,
743+
});
744+
} catch (error) {
745+
throw new Error(formatDevToolsCommandError(method, error));
746+
}
743747
}
744748

745749
function shellQuote(value: string): string {
746750
return `'${value.replace(/'/g, "'\\''")}'`;
747751
}
752+
753+
function formatDevToolsCommandError(method: string, error: unknown): string {
754+
if (!(error instanceof Error)) {
755+
return `DevTools command '${method}' failed: ${String(error)}`;
756+
}
757+
758+
const details = error as Error & {
759+
status?: number;
760+
signal?: NodeJS.Signals;
761+
stdout?: string | Buffer;
762+
stderr?: string | Buffer;
763+
};
764+
const output = [
765+
details.stdout ? `stdout: ${details.stdout.toString().trim()}` : '',
766+
details.stderr ? `stderr: ${details.stderr.toString().trim()}` : '',
767+
details.status !== undefined ? `status: ${details.status}` : '',
768+
details.signal ? `signal: ${details.signal}` : '',
769+
].filter(Boolean);
770+
771+
return [`DevTools command '${method}' failed: ${error.message}`, ...output].join('\n');
772+
}

test/specs/mainnet/probe.e2e.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ describe('@probe_mainnet - Lightning probe smoke', () => {
244244
for (const [index, { target, amountMsat }] of probes.entries()) {
245245
const result = await runProbe(target, amountMsat);
246246
results.push(result);
247+
writeProbeArtifacts(results, readiness);
247248
console.info(
248249
`→ [Probe] ${result.targetName} ${result.amountSats} sats (${result.probeMode}): ${
249250
result.success ? '✅ success' : `❌ failed (${result.error ?? 'unknown'})`

0 commit comments

Comments
 (0)