Skip to content

Commit

Permalink
fixup: update test-vatwarehouse w.r.t. SwingSet API progress
Browse files Browse the repository at this point in the history
 - types such as VatManager are now available to import
 - setVatSyscallHandler() machinations are gone
 - ManagerOptions.name is required
 - kernelSlog is required
  • Loading branch information
dckc committed May 17, 2021
1 parent 14b7604 commit 794cbf1
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions packages/SwingSet/test/workers/test-vatwarehouse.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* global process, require, __dirname */
// @ts-check
import path from 'path';
import { spawn } from 'child_process';

// eslint-disable-next-line import/order
import { test } from '../../tools/prepare-test-env-ava';
Expand All @@ -24,14 +25,6 @@ import { makeVatTranslators } from '../../src/kernel/vatTranslator';
* @param { (vatID: string, translators: unknown) => VatSyscallHandler } buildVatSyscallHandler
* @param {{ sizeHint?: number }=} policyOptions
*
* @typedef { import('../../src/kernel/vatManager/manager-subprocess-xsnap').VatManagerFactory } VatManagerFactory
* @typedef { {
* replayTranscript: () => Promise<void>,
* setVatSyscallHandler: (handler: VatSyscallHandler) => void,
* deliver: (d: Tagged) => Promise<Tagged>,
* shutdown: () => Promise<void>,
* } } VatManager
*
* @typedef { ReturnType<typeof initSwingStore> } SwingStore
* @typedef {(syscall: Tagged) => ['error', string] | ['ok', null] | ['ok', Capdata]} VatSyscallHandler
* @typedef {{ body: string, slots: unknown[] }} Capdata
Expand Down Expand Up @@ -114,17 +107,18 @@ export function makeVatWarehouse(

const { bundle, options } = detail;
const { managerType } = options;

const translators = makeVatTranslators(vatID, kernelKeeper);
const vatSyscallHandler = buildVatSyscallHandler(vatID, translators);

// console.log('provide: creating from bundle', vatID);
const manager = await factories[managerType].createFromBundle(
vatID,
bundle,
options,
vatSyscallHandler,
);

const translators = makeVatTranslators(vatID, kernelKeeper);

const vatSyscallHandler = buildVatSyscallHandler(vatID, translators);
manager.setVatSyscallHandler(vatSyscallHandler);
await manager.replayTranscript();
idToManager.set(vatID, manager);
return manager;
Expand Down Expand Up @@ -166,7 +160,7 @@ export function makeVatWarehouse(
await evict(lru);
}

/** @type {(vatID: string, d: Tagged) => Promise<Tagged> } */
/** @type {(vatID: string, d: VatDeliveryObject) => Promise<Tagged> } */
async function deliverToVat(vatID, delivery) {
await applyAvailabilityPolicy(vatID);
return (await provideVatManager(vatID)).deliver(delivery);
Expand Down Expand Up @@ -218,13 +212,14 @@ async function theXSFactory(
const startXSnap = makeStartXSnap(bundles, {
snapstorePath,
env: process.env,
spawn,
});

/** @type { unknown } */
const TODO = undefined;
const kernelSlog = { write: () => {} };
const xsf = makeXsSubprocessFactory({
allVatPowers: {
transformTildot: src => src,
Remotable,
getInterfaceOf,
exitVat: TODO,
Expand All @@ -233,13 +228,13 @@ async function theXSFactory(
kernelKeeper,
startXSnap,
testLog: _ => {},
decref: _ => {},
kernelSlog,
});

return xsf;
}

/** @type {(r: string, m: string, ...args: unknown[]) => Tagged} */
/** @type {(r: string, m: string, ...args: unknown[]) => VatDeliveryMessage} */
const msg = (result, method, ...args) => [
'message',
'o+0',
Expand Down Expand Up @@ -302,6 +297,7 @@ test('initialize vat; ensure deliveries maintain state', async t => {
virtualObjectCacheSize: 1,
enableSetup: false,
bundle: undefined,
name: 'target',
});

// send delivery to vatmanager
Expand Down Expand Up @@ -353,6 +349,7 @@ test('deliver to lots of vats', async t => {
virtualObjectCacheSize: 1,
enableSetup: false,
bundle: undefined,
name: 'target',
});
});

Expand Down

0 comments on commit 794cbf1

Please sign in to comment.