Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(orchestration): errors should have error messages #9593

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/orchestration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@agoric/zoe": "^0.26.2",
"@agoric/zone": "^0.2.2",
"@endo/base64": "^1.0.5",
"@endo/errors": "^1.2.2",
"@endo/far": "^1.1.2",
"@endo/marshal": "^1.5.0",
"@endo/patterns": "^1.4.0"
Expand Down
3 changes: 2 additions & 1 deletion packages/orchestration/src/utils/packet.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Fail } from '@endo/errors';
import { TxBody } from '@agoric/cosmic-proto/cosmos/tx/v1beta1/tx.js';
import { Any } from '@agoric/cosmic-proto/google/protobuf/any.js';
import { RequestQuery } from '@agoric/cosmic-proto/tendermint/abci/types.js';
Expand Down Expand Up @@ -84,7 +85,7 @@ export function parseTxPacket(response) {
const { result, error } = JSON.parse(response);
if (result) return result;
else if (error) throw Error(error);
else throw Error(response);
else throw Fail`expected either result or error: ${response}`;
}
harden(parseTxPacket);

Expand Down
4 changes: 2 additions & 2 deletions packages/orchestration/test/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test('makeICQConnection returns an ICQConnection', async t => {
),
]),
),
{ message: /"data":"(.*)"memo":""/ },
{ message: /\\"data\\":\\"(.*)\\"memo\\":\\"\\"/ },
'TODO do not use echo connection',
);
});
Expand Down Expand Up @@ -118,7 +118,7 @@ test('makeAccount returns a ChainAccount', async t => {
);
await t.throwsAsync(
heapVowTools.when(E(account).executeEncodedTx([delegateMsg])),
{ message: /"type":1(.*)"data":"(.*)"memo":""/ },
{ message: /\\"type\\":1(.*)\\"data\\":\\"(.*)\\"memo\\":\\"\\"/ },
'TODO do not use echo connection',
);

Expand Down
4 changes: 2 additions & 2 deletions packages/orchestration/test/utils/packet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ test('parseTxPacket', t => {
t.throws(
() => parseTxPacket('{"foo":"bar"}'),
{
message: '{"foo":"bar"}',
message: 'expected either result or error: "{\\"foo\\":\\"bar\\"}"',
},
'returns original string as error if `result` is not found',
);
Expand Down Expand Up @@ -187,7 +187,7 @@ test('parseQueryPacket', t => {
t.throws(
() => parseQueryPacket('{"foo":"bar"}'),
{
message: '{"foo":"bar"}',
message: 'expected either result or error: "{\\"foo\\":\\"bar\\"}"',
},
'throws an error if `result` is not found',
);
Expand Down
Loading