Skip to content

Commit

Permalink
test: IcaAccountKit and ICQConnectionKit Port behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Jul 31, 2024
1 parent 270a667 commit d2f072c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/orchestration/test/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { matches } from '@endo/patterns';
import { heapVowE as E } from '@agoric/vow/vat.js';
import { decodeBase64 } from '@endo/base64';
import type { LocalIbcAddress } from '@agoric/vats/tools/ibc-utils.js';
import { getMethodNames } from '@agoric/internal';
import { Port } from '@agoric/network';
import { commonSetup } from './supports.js';
import { ChainAddressShape } from '../src/typeGuards.js';
import { tryDecodeResponse } from '../src/utils/cosmos.js';
Expand Down Expand Up @@ -97,6 +99,13 @@ test('makeICQConnection returns an ICQConnection', async t => {
);
t.regex([...uniquePortIds][0], /icqcontroller-\d+/);
t.is(uniquePortIds.size, 1, 'all connections share same port');

await t.throwsAsync(
// @ts-expect-error icqConnectionKit doesn't have a port method
() => E(icqConnection).getPort(),
undefined,
'ICQConnection Kit does not expose its port',
);
});

test('makeAccount returns an IcaAccountKit', async t => {
Expand All @@ -109,10 +118,11 @@ test('makeAccount returns an IcaAccountKit', async t => {
HOST_CONNECTION_ID,
CONTROLLER_CONNECTION_ID,
);
const [localAddr, remoteAddr, chainAddr] = await Promise.all([
const [localAddr, remoteAddr, chainAddr, port] = await Promise.all([
E(account).getLocalAddress(),
E(account).getRemoteAddress(),
E(account).getAddress(),
E(account).getPort(),
]);
t.log(account, {
localAddr,
Expand All @@ -135,6 +145,12 @@ test('makeAccount returns an IcaAccountKit', async t => {
/"version":"ics27-1"(.*)"encoding":"proto3"/,
'remote address contains version and encoding in version string',
);
t.true(
(
['addListener', 'removeListener', 'connect', 'revoke'] as (keyof Port)[]
).every(method => getMethodNames(port).includes(method)),
'IcaAccountKit returns a Port remotable',
);

t.true(matches(chainAddr, ChainAddressShape));
t.regex(chainAddr.value, /cosmos1test/);
Expand Down

0 comments on commit d2f072c

Please sign in to comment.