Skip to content

Commit

Permalink
feat: pushInbound
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jul 25, 2024
1 parent f17022e commit 108606f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/boot/tools/supports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,18 @@ export const makeSwingsetTestKit = async (
};

const inboundQueue: [bridgeId: BridgeIdValue, arg1: unknown][] = [];
/** Add a message that will be sent to the bridge by flushInboundQueue. */
const pushInbound = (bridgeId: BridgeIdValue, arg1: unknown) => {
inboundQueue.push([bridgeId, arg1]);
};
/**
* Like ackImmediately but defers in the inbound receiverAck
* until `bridgeQueue()` is awaited.
*/
const ackLater = (obj: IBCMethod<'sendPacket'>, ack: string) => {
ibcSequenceNonce += 1;
const msg = icaMocks.ackPacketEvent(obj, ibcSequenceNonce, ack);
inboundQueue.push([BridgeId.DIBC, msg]);
pushInbound(BridgeId.DIBC, msg);
return msg.packet;
};

Expand Down Expand Up @@ -437,10 +441,7 @@ export const makeSwingsetTestKit = async (
case 'IBC_METHOD':
switch (obj.method) {
case 'startChannelOpenInit':
inboundQueue.push([
BridgeId.DIBC,
icaMocks.channelOpenAck(obj),
]);
pushInbound(BridgeId.DIBC, icaMocks.channelOpenAck(obj));
return undefined;
case 'sendPacket':
switch (obj.packet.data) {
Expand Down Expand Up @@ -620,7 +621,7 @@ export const makeSwingsetTestKit = async (
const getCrankNumber = () => Number(kernelStorage.kvStore.get('crankNumber'));

const bridgeUtils = {
bridgeInbound,
pushInbound,
getOutboundMessages: (bridgeId: string) =>
harden([...outboundMessages.get(bridgeId)]),
getInboundQueueLength: () => inboundQueue.length,
Expand Down

0 comments on commit 108606f

Please sign in to comment.