Skip to content

Commit

Permalink
test(fake-bridge): FakeTransferBridge implements IBC_METHOD
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jul 3, 2024
1 parent a68cb2e commit 84eb287
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions packages/vats/tools/fake-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ export const makeFakeBankBridge = (zone, opts = { balances: {} }) => {
});
};

/** @param {any} obj */
const toBridgeIbcMethod = obj => {
const { type, method, ...params } = obj;
assert.equal(type, 'IBC_METHOD');
if (method === 'sendPacket') {
const { packet } = params;
return harden({ ...packet, sequence: '39' });
}
return undefined;
};

/**
* @param {import('@agoric/zone').Zone} zone
* @param {(obj) => void} onToBridge
Expand All @@ -132,13 +143,7 @@ export const makeFakeIbcBridge = (zone, onToBridge) => {
getBridgeId: () => 'dibc',
toBridge: async obj => {
onToBridge(obj);
const { method, type, ...params } = obj;
assert.equal(type, 'IBC_METHOD');
if (method === 'sendPacket') {
const { packet } = params;
return { ...packet, sequence: '39' };
}
return undefined;
return toBridgeIbcMethod(obj);
},
fromBridge: async obj => {
if (!hndlr) throw Error('no handler!');
Expand Down Expand Up @@ -260,6 +265,9 @@ export const makeFakeTransferBridge = (zone, onToBridge = () => {}) => {
registered.delete(params.target);
return undefined;
}
case 'IBC_METHOD': {
return toBridgeIbcMethod(obj);
}
default:
Fail`unknown type ${type}`;
}
Expand Down

0 comments on commit 84eb287

Please sign in to comment.