Skip to content

Commit cc6edbb

Browse files
committed
chore(remotes): rename initNetwork to initTransport
1 parent 03e602a commit cc6edbb

File tree

5 files changed

+41
-41
lines changed

5 files changed

+41
-41
lines changed

packages/kernel-browser-runtime/src/PlatformServicesServer.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type {
1818
PlatformServicesStream,
1919
} from './PlatformServicesServer.ts';
2020

21-
// Mock initNetwork from ocap-kernel
21+
// Mock initTransport from ocap-kernel
2222
const mockSendRemoteMessage = vi.fn(async () => undefined);
2323
const mockStop = vi.fn(async () => undefined);
2424
const mockCloseConnection = vi.fn(async () => undefined);
@@ -35,7 +35,7 @@ vi.mock('@metamask/ocap-kernel', () => ({
3535
terminate: 'terminate',
3636
terminateAll: 'terminateAll',
3737
},
38-
initNetwork: vi.fn(
38+
initTransport: vi.fn(
3939
async (
4040
_keySeed: string,
4141
_options: unknown,
@@ -400,8 +400,8 @@ describe('PlatformServicesServer', () => {
400400
);
401401
await delay(10);
402402

403-
const { initNetwork } = await import('@metamask/ocap-kernel');
404-
expect(initNetwork).toHaveBeenCalledWith(
403+
const { initTransport } = await import('@metamask/ocap-kernel');
404+
expect(initTransport).toHaveBeenCalledWith(
405405
keySeed,
406406
{ relays },
407407
expect.any(Function),
@@ -422,8 +422,8 @@ describe('PlatformServicesServer', () => {
422422
);
423423
await delay(10);
424424

425-
const { initNetwork } = await import('@metamask/ocap-kernel');
426-
expect(initNetwork).toHaveBeenCalledWith(
425+
const { initTransport } = await import('@metamask/ocap-kernel');
426+
expect(initTransport).toHaveBeenCalledWith(
427427
keySeed,
428428
options,
429429
expect.any(Function),
@@ -458,7 +458,7 @@ describe('PlatformServicesServer', () => {
458458
});
459459

460460
describe('handleRemoteMessage', () => {
461-
it('captures handler from initNetwork', async () => {
461+
it('captures handler from initTransport', async () => {
462462
const keySeed = '0xabcd';
463463
const relays = ['/dns4/relay.example/tcp/443/wss/p2p/relayPeer'];
464464

@@ -529,7 +529,7 @@ describe('PlatformServicesServer', () => {
529529
});
530530

531531
describe('handleRemoteGiveUp', () => {
532-
it('captures handler from initNetwork', async () => {
532+
it('captures handler from initTransport', async () => {
533533
const keySeed = '0xabcd';
534534
const relays = ['/dns4/relay.example/tcp/443/wss/p2p/relayPeer'];
535535

@@ -658,17 +658,17 @@ describe('PlatformServicesServer', () => {
658658
await stream.receiveInput(makeStopRemoteCommsMessageEvent('m1'));
659659
await delay(10);
660660

661-
const { initNetwork } = await import('@metamask/ocap-kernel');
662-
const firstCallCount = (initNetwork as Mock).mock.calls.length;
661+
const { initTransport } = await import('@metamask/ocap-kernel');
662+
const firstCallCount = (initTransport as Mock).mock.calls.length;
663663

664664
// Re-initialize should work
665665
await stream.receiveInput(
666666
makeInitializeRemoteCommsMessageEvent('m2', keySeed, { relays }),
667667
);
668668
await delay(10);
669669

670-
// Should have called initNetwork again
671-
expect((initNetwork as Mock).mock.calls).toHaveLength(
670+
// Should have called initTransport again
671+
expect((initTransport as Mock).mock.calls).toHaveLength(
672672
firstCallCount + 1,
673673
);
674674
});

packages/kernel-browser-runtime/src/PlatformServicesServer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
StopRemoteComms,
1414
RemoteCommsOptions,
1515
} from '@metamask/ocap-kernel';
16-
import { initNetwork } from '@metamask/ocap-kernel';
16+
import { initTransport } from '@metamask/ocap-kernel';
1717
import {
1818
kernelRemoteMethodSpecs,
1919
platformServicesHandlers,
@@ -288,7 +288,7 @@ export class PlatformServicesServer {
288288
closeConnection,
289289
registerLocationHints,
290290
reconnectPeer,
291-
} = await initNetwork(
291+
} = await initTransport(
292292
keySeed,
293293
options,
294294
this.#handleRemoteMessage.bind(this),

packages/nodejs/src/kernel/PlatformServices.test.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ vi.mock('@metamask/ocap-kernel', async (importOriginal) => {
7979
const actual = await importOriginal<typeof import('@metamask/ocap-kernel')>();
8080
return {
8181
...actual,
82-
initNetwork: vi.fn(async () => ({
82+
initTransport: vi.fn(async () => ({
8383
sendRemoteMessage: mockSendRemoteMessage,
8484
stop: mockStop,
8585
closeConnection: mockCloseConnection,
@@ -245,8 +245,8 @@ describe('NodejsPlatformServices', () => {
245245

246246
await service.initializeRemoteComms(keySeed, { relays }, remoteHandler);
247247

248-
const { initNetwork } = await import('@metamask/ocap-kernel');
249-
expect(initNetwork).toHaveBeenCalledWith(
248+
const { initTransport } = await import('@metamask/ocap-kernel');
249+
expect(initTransport).toHaveBeenCalledWith(
250250
keySeed,
251251
{ relays },
252252
expect.any(Function),
@@ -266,8 +266,8 @@ describe('NodejsPlatformServices', () => {
266266

267267
await service.initializeRemoteComms(keySeed, options, remoteHandler);
268268

269-
const { initNetwork } = await import('@metamask/ocap-kernel');
270-
expect(initNetwork).toHaveBeenCalledWith(
269+
const { initTransport } = await import('@metamask/ocap-kernel');
270+
expect(initTransport).toHaveBeenCalledWith(
271271
keySeed,
272272
options,
273273
expect.any(Function),
@@ -289,8 +289,8 @@ describe('NodejsPlatformServices', () => {
289289
giveUpHandler,
290290
);
291291

292-
const { initNetwork } = await import('@metamask/ocap-kernel');
293-
expect(initNetwork).toHaveBeenCalledWith(
292+
const { initTransport } = await import('@metamask/ocap-kernel');
293+
expect(initTransport).toHaveBeenCalledWith(
294294
keySeed,
295295
{ relays },
296296
expect.any(Function),
@@ -332,17 +332,17 @@ describe('NodejsPlatformServices', () => {
332332

333333
await service.initializeRemoteComms('0xtest', {}, remoteHandler);
334334

335-
// Simulate handleRemoteMessage being called (via initNetwork callback)
335+
// Simulate handleRemoteMessage being called (via initTransport callback)
336336
// The handler should call sendRemoteMessage if reply is non-empty
337337
mockSendRemoteMessage.mockClear();
338338

339-
// Call the handler that was passed to initNetwork
340-
const { initNetwork } = await import('@metamask/ocap-kernel');
341-
const initNetworkMock = initNetwork as unknown as ReturnType<
339+
// Call the handler that was passed to initTransport
340+
const { initTransport } = await import('@metamask/ocap-kernel');
341+
const initTransportMock = initTransport as unknown as ReturnType<
342342
typeof vi.fn
343343
>;
344344
const lastCall =
345-
initNetworkMock.mock.calls[initNetworkMock.mock.calls.length - 1];
345+
initTransportMock.mock.calls[initTransportMock.mock.calls.length - 1];
346346
const handleRemoteMessage = lastCall?.[2] as (
347347
from: string,
348348
message: string,
@@ -365,13 +365,13 @@ describe('NodejsPlatformServices', () => {
365365

366366
mockSendRemoteMessage.mockClear();
367367

368-
// Call the handler that was passed to initNetwork
369-
const { initNetwork } = await import('@metamask/ocap-kernel');
370-
const initNetworkMock = initNetwork as unknown as ReturnType<
368+
// Call the handler that was passed to initTransport
369+
const { initTransport } = await import('@metamask/ocap-kernel');
370+
const initTransportMock = initTransport as unknown as ReturnType<
371371
typeof vi.fn
372372
>;
373373
const lastCall =
374-
initNetworkMock.mock.calls[initNetworkMock.mock.calls.length - 1];
374+
initTransportMock.mock.calls[initTransportMock.mock.calls.length - 1];
375375
const handleRemoteMessage = lastCall?.[2] as (
376376
from: string,
377377
message: string,
@@ -440,11 +440,11 @@ describe('NodejsPlatformServices', () => {
440440
// Initialize
441441
await service.initializeRemoteComms(keySeed, { relays }, remoteHandler);
442442

443-
const { initNetwork } = await import('@metamask/ocap-kernel');
444-
const initNetworkMock = initNetwork as unknown as ReturnType<
443+
const { initTransport } = await import('@metamask/ocap-kernel');
444+
const initTransportMock = initTransport as unknown as ReturnType<
445445
typeof vi.fn
446446
>;
447-
const firstCallCount = initNetworkMock.mock.calls.length;
447+
const firstCallCount = initTransportMock.mock.calls.length;
448448

449449
// Stop
450450
await service.stopRemoteComms();
@@ -453,8 +453,8 @@ describe('NodejsPlatformServices', () => {
453453
// Re-initialize should work
454454
await service.initializeRemoteComms(keySeed, { relays }, remoteHandler);
455455

456-
// Should have called initNetwork again
457-
expect(initNetworkMock.mock.calls).toHaveLength(firstCallCount + 1);
456+
// Should have called initTransport again
457+
expect(initTransportMock.mock.calls).toHaveLength(firstCallCount + 1);
458458
});
459459

460460
it('clears internal state after stop', async () => {

packages/nodejs/src/kernel/PlatformServices.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
StopRemoteComms,
1111
RemoteCommsOptions,
1212
} from '@metamask/ocap-kernel';
13-
import { initNetwork } from '@metamask/ocap-kernel';
13+
import { initTransport } from '@metamask/ocap-kernel';
1414
import { NodeWorkerDuplexStream } from '@metamask/streams';
1515
import type { DuplexStream } from '@metamask/streams';
1616
import { strict as assert } from 'node:assert';
@@ -249,7 +249,7 @@ export class NodejsPlatformServices implements PlatformServices {
249249
closeConnection,
250250
registerLocationHints,
251251
reconnectPeer,
252-
} = await initNetwork(
252+
} = await initTransport(
253253
keySeed,
254254
options,
255255
this.#handleRemoteMessage.bind(this),

vitest.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ export default defineConfig({
159159
lines: 25,
160160
},
161161
'packages/ocap-kernel/**': {
162-
statements: 95.12,
163-
functions: 97.69,
164-
branches: 86.95,
165-
lines: 95.1,
162+
statements: 95.93,
163+
functions: 97.77,
164+
branches: 88.4,
165+
lines: 95.91,
166166
},
167167
'packages/omnium-gatherum/**': {
168168
statements: 5.26,

0 commit comments

Comments
 (0)