diff --git a/packages/orchestration/package.json b/packages/orchestration/package.json index 91fffe2fc3f..1567a6550da 100644 --- a/packages/orchestration/package.json +++ b/packages/orchestration/package.json @@ -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" diff --git a/packages/orchestration/src/utils/packet.js b/packages/orchestration/src/utils/packet.js index d9c7abdeba4..9f5158abd59 100644 --- a/packages/orchestration/src/utils/packet.js +++ b/packages/orchestration/src/utils/packet.js @@ -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'; @@ -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); diff --git a/packages/orchestration/test/service.test.ts b/packages/orchestration/test/service.test.ts index b2829f146f2..a3e6febfabc 100644 --- a/packages/orchestration/test/service.test.ts +++ b/packages/orchestration/test/service.test.ts @@ -56,7 +56,7 @@ test('makeICQConnection returns an ICQConnection', async t => { ), ]), ), - { message: /"data":"(.*)"memo":""/ }, + { message: /\\"data\\":\\"(.*)\\"memo\\":\\"\\"/ }, 'TODO do not use echo connection', ); }); @@ -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', ); diff --git a/packages/orchestration/test/utils/packet.test.ts b/packages/orchestration/test/utils/packet.test.ts index 95c72b475f3..dc461aa26da 100644 --- a/packages/orchestration/test/utils/packet.test.ts +++ b/packages/orchestration/test/utils/packet.test.ts @@ -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', ); @@ -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', );