Skip to content

Commit

Permalink
fix(network): Connection should have negotiated remoteAddress and loc…
Browse files Browse the repository at this point in the history
…alAddress

    - refs #9064
  • Loading branch information
0xpatrickdev committed Apr 2, 2024
1 parent 9a1368f commit 4601a1a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import type { ExecutionContext, TestFn } from 'ava';
import { M, matches } from '@endo/patterns';
import type { start as stakeAtomStart } from '@agoric/orchestration/src/contracts/stakeAtom.contract.js';
import { makeWalletFactoryContext } from './walletFactory.ts';

const makeTestContext = async (t: ExecutionContext) =>
Expand Down
11 changes: 7 additions & 4 deletions packages/network/src/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,11 @@ const prepareBinder = (zone, powers) => {
},
},
binderOutboundConnectWatcher: {
onFulfilled({ handler: rchandler }, watchContext) {
const { lastFailure, remoteAddr, localAddr, lchandler, port } =
onFulfilled(
{ handler: rchandler, remoteAddress, localAddress },
watchContext,
) {
const { lastFailure, lchandler, localAddr, remoteAddr, port } =
watchContext;

const { currentConnections } = this.state;
Expand All @@ -979,11 +982,11 @@ const prepareBinder = (zone, powers) => {
/** @type {import('@agoric/vow').Remote<Required<ConnectionHandler>>} */ (
lchandler
),
localAddr,
localAddress || localAddr,
/** @type {import('@agoric/vow').Remote<Required<ConnectionHandler>>} */ (
rchandler
),
remoteAddr,
remoteAddress || remoteAddr,
makeConnection,
current,
)[0];
Expand Down
2 changes: 2 additions & 0 deletions packages/orchestration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
"@agoric/assert": "^0.6.0",
"@agoric/ertp": "^0.16.2",
"@agoric/internal": "^0.3.2",
"@agoric/network": "^0.1.0",
"@agoric/notifier": "^0.6.2",
"@agoric/store": "^0.9.2",
"@agoric/vat-data": "^0.5.2",
"@agoric/vats": "^0.15.1",
"@agoric/zoe": "^0.26.2",
Expand Down
10 changes: 9 additions & 1 deletion packages/vats/test/test-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,19 @@ test('network - ibc', async t => {
portID: 'port-1',
channelID: 'channel-1',
counterparty: { port_id: 'port-98', channel_id: 'channel-22' },
counterpartyVersion: 'bar',
counterpartyVersion: 'bar-negotiated',
connectionHops: ['connection-11'],
});

const c = await when(cP);
const remoteAddress = c.getRemoteAddress();
const localAddress = c.getLocalAddress();
t.is(
remoteAddress,
'/ibc-hop/connection-11/ibc-port/port-98/unordered/bar-negotiated/ibc-channel/channel-22',
);
t.is(localAddress, '/ibc-port/port-1/ibc-channel/channel-1');

t.log('Sending Data - transfer');
const ack = E(c).send('some-transfer-message');

Expand Down

0 comments on commit 4601a1a

Please sign in to comment.