Skip to content

Commit 649cc9d

Browse files
authored
Merge pull request #241 from Agoric/gibson-2025-05-agd-debugging
chore(synthetic-chain): Improve output for debugging `agd` invocations
2 parents f5b0f6d + f63eb5c commit 649cc9d

File tree

5 files changed

+32
-10
lines changed

5 files changed

+32
-10
lines changed

.changeset/giant-jeans-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@agoric/synthetic-chain': patch
3+
---
4+
5+
Improve output for debugging `agd` invocations

packages/synthetic-chain/src/lib/agd-lib.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,17 @@ export const makeAgd = ({
3535
const exec = (
3636
args: string[],
3737
opts?: ExecFileSyncOptionsWithStringEncoding,
38-
) => execFileSync(agdBinary, args, opts).toString();
38+
) => {
39+
console.warn(
40+
'# invoking agd:',
41+
...[agdBinary, ...args].map(arg =>
42+
arg.match(/[^a-zA-Z0-9,._+:@%/-]/)
43+
? `'${arg.replaceAll(`'`, `'\\''`)}'`
44+
: arg,
45+
),
46+
);
47+
return execFileSync(agdBinary, args, opts).toString();
48+
};
3949

4050
const outJson = ['--output', 'json'];
4151

packages/synthetic-chain/src/lib/cliHelper.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import { $, execaCommand } from 'execa';
22
import { BINARY, SDK_ROOT } from './constants.js';
3+
import type { Options as ExecaOptions } from 'execa';
34

45
export const executeCommand = async (
56
command: string,
67
params: string[],
7-
options = {},
8+
options: Omit<
9+
ExecaOptions,
10+
'buffer' | 'encoding' | 'lines' | 'stdio' | 'stdout'
11+
> = {},
812
) => {
9-
const { stdout } = await execaCommand(
10-
`${command} ${params.join(' ')}`,
11-
options,
12-
);
13-
return stdout;
13+
const invocation = `${command} ${params.join(' ')}`;
14+
console.warn('# invoking:', invocation);
15+
const result = await execaCommand(invocation, options);
16+
if (!options.stderr) {
17+
const { stderr } = result;
18+
if (stderr) console.warn(stderr);
19+
}
20+
return result.stdout;
1421
};
1522

1623
export const agd = {

packages/synthetic-chain/src/lib/core-eval-support.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export const flags = (record: Record<string, string>): string[] => {
4646
};
4747

4848
export const txAbbr = (tx: any) => {
49-
const { txhash, code, height, gas_used } = tx;
50-
return { txhash, code, height, gas_used };
49+
const { txhash, codespace, code, height, gas_used } = tx;
50+
return { txhash, codespace, code, height, gas_used };
5151
};
5252

5353
export const loadedBundleIds = (swingstore: any) => {

packages/synthetic-chain/src/lib/core-eval.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export const passCoreEvalProposal = async (
170170
['swingset', 'install-bundle', `@${bundleRd}`],
171171
{ from, chainId, yes: true },
172172
);
173-
console.log(txAbbr(result));
173+
console.log(result.code === 0 ? txAbbr(result) : result);
174174
assert.equal(result.code, 0);
175175

176176
const info = await getContractInfo('bundles', { agoric, prefix: '' });

0 commit comments

Comments
 (0)