Skip to content

Commit

Permalink
tools: inboundVTransferEvent to simulate ack packet
Browse files Browse the repository at this point in the history
- helper to simulate VTransfer acknowledgement inbound evenet from remote chain
- refs: #10131
  • Loading branch information
0xpatrickdev committed Sep 24, 2024
1 parent f991204 commit 0f1ca0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
11 changes: 11 additions & 0 deletions packages/boot/tools/supports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ import type { SwingsetController } from '@agoric/swingset-vat/src/controller/con
import type { BridgeHandler, IBCMethod, IBCPacket } from '@agoric/vats';
import type { BootstrapRootObject } from '@agoric/vats/src/core/lib-boot.js';
import type { EProxy } from '@endo/eventual-send';
import {
buildVTransferEvent,
type BuildVTransferEventParams,
} from '@agoric/orchestration/tools/ibc-mocks.js';
import { icaMocks, protoMsgMockMap, protoMsgMocks } from './ibc/mocks.js';

const trace = makeTracer('BSTSupport', false);
Expand Down Expand Up @@ -615,6 +619,13 @@ export const makeSwingsetTestKit = async (
console.log('🧻');
return i;
},

async inboundVTransferEvent(params: BuildVTransferEventParams) {
await runUtils.queueAndRun(
() => inbound(BridgeId.VTRANSFER, buildVTransferEvent(params)),
true,
);
},
};

return {
Expand Down
9 changes: 5 additions & 4 deletions packages/orchestration/tools/ibc-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -152,18 +152,19 @@ export function buildQueryPacketString(
return btoa(makeQueryPacket(msgs.map(msg => toRequestQueryJson(msg, opts))));
}

type BuildVTransferEventParams = {
export 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<PacketSDKType['sequence']>;
};

/**
Expand Down

0 comments on commit 0f1ca0f

Please sign in to comment.