Skip to content

Commit 8ae2704

Browse files
authored
Merge pull request #188 from synonymdev/mainnet-probe-observability
Improve mainnet probe observability
2 parents 25a3a00 + 5d706a5 commit 8ae2704

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
@@ -774,12 +774,37 @@ function runDevToolsCommand(
774774
shellQuote(JSON.stringify(payload)),
775775
].join(' ');
776776

777-
return execFileSync('adb', ['shell', command], {
778-
encoding: 'utf8',
779-
timeout: (timeoutSeconds + 10) * 1000,
780-
});
777+
try {
778+
return execFileSync('adb', ['shell', command], {
779+
encoding: 'utf8',
780+
timeout: (timeoutSeconds + 10) * 1000,
781+
});
782+
} catch (error) {
783+
throw new Error(formatDevToolsCommandError(method, error));
784+
}
781785
}
782786

783787
function shellQuote(value: string): string {
784788
return `'${value.replace(/'/g, "'\\''")}'`;
785789
}
790+
791+
function formatDevToolsCommandError(method: string, error: unknown): string {
792+
if (!(error instanceof Error)) {
793+
return `DevTools command '${method}' failed: ${String(error)}`;
794+
}
795+
796+
const details = error as Error & {
797+
status?: number;
798+
signal?: NodeJS.Signals;
799+
stdout?: string | Buffer;
800+
stderr?: string | Buffer;
801+
};
802+
const output = [
803+
details.stdout ? `stdout: ${details.stdout.toString().trim()}` : '',
804+
details.stderr ? `stderr: ${details.stderr.toString().trim()}` : '',
805+
details.status !== undefined ? `status: ${details.status}` : '',
806+
details.signal ? `signal: ${details.signal}` : '',
807+
].filter(Boolean);
808+
809+
return [`DevTools command '${method}' failed: ${error.message}`, ...output].join('\n');
810+
}

test/specs/mainnet/probe.e2e.ts

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

0 commit comments

Comments
 (0)