From be9054654d45b78b50fedaddef393bf52ac522eb Mon Sep 17 00:00:00 2001 From: 0xPatrick Date: Tue, 24 Sep 2024 19:45:39 -0400 Subject: [PATCH 1/3] tools: bridgeUtils.runInbound helper --- packages/boot/tools/supports.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/boot/tools/supports.ts b/packages/boot/tools/supports.ts index 1841c06bfcb..9f6a89f7cdc 100644 --- a/packages/boot/tools/supports.ts +++ b/packages/boot/tools/supports.ts @@ -627,6 +627,9 @@ export const makeSwingsetTestKit = async ( console.log('🧻'); return i; }, + async runInbound(bridgeId: BridgeIdValue, msg: unknown) { + await runUtils.queueAndRun(() => inbound(bridgeId, msg), true); + }, }; return { From 52736052c16d8aa8a3a196c7f817f7913fa7567a Mon Sep 17 00:00:00 2001 From: 0xPatrick Date: Tue, 24 Sep 2024 19:46:25 -0400 Subject: [PATCH 2/3] types: BuildVTransferEventParams accepts JsonSafe sequence --- packages/orchestration/tools/ibc-mocks.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/orchestration/tools/ibc-mocks.ts b/packages/orchestration/tools/ibc-mocks.ts index 65266645e5d..4c1ba2ea16b 100644 --- a/packages/orchestration/tools/ibc-mocks.ts +++ b/packages/orchestration/tools/ibc-mocks.ts @@ -6,7 +6,7 @@ import { ResponseQuery, } from '@agoric/cosmic-proto/tendermint/abci/types.js'; import { encodeBase64, btoa, atob, decodeBase64 } from '@endo/base64'; -import { toRequestQueryJson } from '@agoric/cosmic-proto'; +import { type JsonSafe, toRequestQueryJson } from '@agoric/cosmic-proto'; import { IBCChannelID, IBCEvent, @@ -156,14 +156,15 @@ type BuildVTransferEventParams = { event?: VTransferIBCEvent['event']; /* defaults to cosmos1AccAddress. set to `agoric1fakeLCAAddress` to simulate an outgoing transfer event */ sender?: ChainAddress['value']; - /** defaults to agoric1fakeLCAAddress. set to a different value to simulate an outgoing transfer event */ + /* defaults to agoric1fakeLCAAddress. set to a different value to simulate an outgoing transfer event */ receiver?: ChainAddress['value']; target?: ChainAddress['value']; amount?: bigint; denom?: string; destinationChannel?: IBCChannelID; sourceChannel?: IBCChannelID; - sequence?: PacketSDKType['sequence']; + /* support bigint and string, to facilitate bootstrap testing */ + sequence?: PacketSDKType['sequence'] | JsonSafe; }; /** From 75086182be622ee0dec6379464ff237711b82b08 Mon Sep 17 00:00:00 2001 From: 0xPatrick Date: Tue, 24 Sep 2024 19:47:26 -0400 Subject: [PATCH 3/3] test: send-anywhere settled offer --- .../orchestration/restart-contracts.test.ts | 64 ++++++++++--------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/packages/boot/test/orchestration/restart-contracts.test.ts b/packages/boot/test/orchestration/restart-contracts.test.ts index 25e7d881268..67b6efd520c 100644 --- a/packages/boot/test/orchestration/restart-contracts.test.ts +++ b/packages/boot/test/orchestration/restart-contracts.test.ts @@ -2,7 +2,9 @@ import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js'; import { TestFn } from 'ava'; +import { BridgeId } from '@agoric/internal'; import type { CosmosValidatorAddress } from '@agoric/orchestration'; +import { buildVTransferEvent } from '@agoric/orchestration/tools/ibc-mocks.js'; import type { UpdateRecord } from '@agoric/smart-wallet/src/smartWallet.js'; import { makeWalletFactoryContext, @@ -18,14 +20,13 @@ test.before(async t => { }); test.after.always(t => t.context.shutdown?.()); -// FIXME the test needs to be able to send the acknowledgementPacket ack -// so that the transfer vow resolves. -test.serial.failing('send-anywhere', async t => { +// TODO #9303 execute restart-send-anywhere.js proposal +test.serial('send-anywhere', async t => { const { walletFactoryDriver, buildProposal, evalProposal, - bridgeUtils: { flushInboundQueue }, + bridgeUtils: { runInbound }, } = t.context; const { IST } = t.context.agoricNamesRemotes.brand; @@ -57,43 +58,48 @@ test.serial.failing('send-anywhere', async t => { chainName: 'cosmoshub', }, }); - // no errors and no resolution - const beforeFlush = wallet.getLatestUpdateRecord(); - t.like(wallet.getLatestUpdateRecord(), { - updated: 'offerStatus', - status: { - id: 'send-somewhere', - error: undefined, - }, - numWantsSatisfied: undefined, - payouts: undefined, - result: undefined, - }); - t.is(await flushInboundQueue(), 0); - t.deepEqual(wallet.getLatestUpdateRecord(), beforeFlush); + t.like( + wallet.getCurrentWalletRecord(), + { liveOffers: [['send-somewhere']] }, + 'live offer until we simulate the transfer ack', + ); - t.log('restart send-anywhere'); - await evalProposal( - buildProposal('@agoric/builders/scripts/testing/restart-send-anywhere.js'), + // TODO #9303 Error#1: replay 12: ["checkCall","[Alleged: contractState guest wrapper]","get",["localAccount"],12] vs ["doReturn",11,"[undefined]"] : length: unequal 5 vs 3 + // t.log('restart send-anywhere'); + // await evalProposal( + // buildProposal('@agoric/builders/scripts/testing/restart-send-anywhere.js'), + // ); + + t.like( + wallet.getLatestUpdateRecord(), + { + updated: 'balance', + currentAmount: { value: [] }, + }, + 'no offerStatus updates', + ); + + // simulate ibc/MsgTransfer ack from remote chain, enabling `.transfer()` promise + // to resolve + await runInbound( + BridgeId.VTRANSFER, + buildVTransferEvent({ + sourceChannel: 'channel-5', + sequence: '1', + }), ); const conclusion = wallet.getLatestUpdateRecord(); - console.log('conclusion', conclusion); t.like(conclusion, { updated: 'offerStatus', status: { id: 'send-somewhere', + numWantsSatisfied: 1, error: undefined, + result: undefined, }, - numWantsSatisfied: undefined, - payouts: undefined, - result: undefined, }); - - await flushInboundQueue(); - - // Nothing interesting to confirm here. }); const validatorAddress: CosmosValidatorAddress = {