Skip to content

Commit

Permalink
test(vats): add a regression test for issue #3621
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Aug 9, 2021
1 parent 118daee commit f09f31f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/SwingSet/src/vats/network/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ export default function makeRouter() {
});
}
/**
* @typedef {Protocol} RouterProtocol
* @property {(prefix: string, protocolHandler: ProtocolHandler) => void} registerProtocolHandler
* @typedef {Object} RouterProtocol
* @property {(prefix: string) => Promise<Port>} bind
* @property {(paths: string[], protocolHandler: ProtocolHandler) => void} registerProtocolHandler
* @property {(prefix: string, protocolHandler: ProtocolHandler) => void} unregisterProtocolHandler
*/

Expand Down
33 changes: 33 additions & 0 deletions packages/vats/test/test-network.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// @ts-check
// eslint-disable-next-line import/no-extraneous-dependencies
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava';

import { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';

import { buildRootObject as ibcBuildRootObject } from '../src/vat-ibc.js';
import { buildRootObject as networkBuildRootObject } from '../src/vat-network.js';

test('network - ibc', async t => {
t.plan(2);

const networkVat = E(networkBuildRootObject)();
const ibcVat = E(ibcBuildRootObject)();

const callbacks = Far('ibcCallbacks', {
downcall: (method, params) => {
t.is(method, 'bindPort');
t.deepEqual(params, { packet: { source_port: 'port-1' } });
},
});

const ibcHandler = await E(ibcVat).createInstance(callbacks);
await E(networkVat).registerProtocolHandler(
['/ibc-port', '/ibc-hop'],
ibcHandler,
);

// Actually test the ibc port binding.
// TODO: Do more tests on the returned Port object.
await E(networkVat).bind('/ibc-port/');
});

0 comments on commit f09f31f

Please sign in to comment.