diff --git a/packages/SwingSet/src/controller/controller.js b/packages/SwingSet/src/controller/controller.js index d65f2c04ab4..b5f7ca9fd89 100644 --- a/packages/SwingSet/src/controller/controller.js +++ b/packages/SwingSet/src/controller/controller.js @@ -26,6 +26,7 @@ import { makeGcAndFinalize } from '../lib-nodejs/gc-and-finalize.js'; import { insistStorageAPI } from '../lib/storageAPI.js'; import { provideHostStorage } from './hostStorage.js'; import { + buildKernelBundle, swingsetIsInitialized, initializeSwingset, } from './initializeSwingset.js'; @@ -168,7 +169,8 @@ export function makeStartXSnap(bundles, { snapStore, env, spawn }) { * warehousePolicy?: { maxVatsOnline?: number }, * overrideVatManagerOptions?: unknown, * spawn?: typeof import('child_process').spawn, - * env?: Record + * env?: Record, + * kernelBundle?: Bundle * }} runtimeOptions */ export async function makeSwingsetController( @@ -238,6 +240,10 @@ export async function makeSwingsetController( // see https://github.com/Agoric/SES-shim/issues/292 for details harden(console); + writeSlogObject({ type: 'bundle-kernel-start' }); + const { kernelBundle = await buildKernelBundle() } = runtimeOptions; + writeSlogObject({ type: 'bundle-kernel-finish' }); + // FIXME: Put this somewhere better. const handlers = process.listeners('unhandledRejection'); let haveUnhandledRejectionHandler = false; @@ -254,8 +260,6 @@ export async function makeSwingsetController( function kernelRequire(what) { assert.fail(X`kernelRequire unprepared to satisfy require(${what})`); } - // @ts-expect-error assume kernelBundle is set - const kernelBundle = JSON.parse(kvStore.get('kernelBundle')); writeSlogObject({ type: 'import-kernel-start' }); const kernelNS = await importBundle(kernelBundle, { filePrefix: 'kernel/...', @@ -515,7 +519,7 @@ export async function makeSwingsetController( * @param {SwingSetConfig} config * @param {string[]} argv * @param {{ hostStorage?: HostStore, env?: Record, verbose?: - * boolean, kernelBundles?: Record, debugPrefix?: string, + * boolean, kernelBundles?: Record, debugPrefix?: string, * slogCallbacks?: unknown, testTrackDecref?: unknown, warehousePolicy?: { * maxVatsOnline?: number }, slogFile?: string }} runtimeOptions * @typedef { import('@agoric/swing-store').KVStore } KVStore @@ -529,12 +533,15 @@ export async function buildVatController( hostStorage = provideHostStorage(), env, verbose, - kernelBundles, + kernelBundles: kernelAndOtherBundles = {}, debugPrefix, slogCallbacks, warehousePolicy, slogFile, } = runtimeOptions; + const { kernel: kernelBundle, ...otherBundles } = kernelAndOtherBundles; + const kernelBundles = runtimeOptions.kernelBundles ? otherBundles : undefined; + const actualRuntimeOptions = { env, verbose, @@ -542,6 +549,7 @@ export async function buildVatController( slogCallbacks, warehousePolicy, slogFile, + kernelBundle, }; const initializationOptions = { verbose, kernelBundles }; let bootstrapResult; diff --git a/packages/SwingSet/src/controller/initializeSwingset.js b/packages/SwingSet/src/controller/initializeSwingset.js index d7c7b491c7f..61aebcc3b93 100644 --- a/packages/SwingSet/src/controller/initializeSwingset.js +++ b/packages/SwingSet/src/controller/initializeSwingset.js @@ -28,38 +28,38 @@ const { keys, values, fromEntries } = Object; const allValues = async obj => fromEntries(zip(keys(obj), await Promise.all(values(obj)))); +const bundleRelative = rel => + bundleSource(new URL(rel, import.meta.url).pathname); +const bundleRelativeGE = rel => + bundleSource(new URL(rel, import.meta.url).pathname, { format: 'getExport' }); + /** - * Build the source bundles for the kernel and xsnap vat worker. - * - * @param {object} [options] - * @param {ModuleFormat} [options.bundleFormat] + * Build the source bundles for the kernel. makeSwingsetController() + * calls this on each launch, to get the + * current kernel sources */ -export async function buildKernelBundles(options = {}) { - // this takes 2.7s on my computer - - const { bundleFormat = undefined } = options; - - const src = rel => - bundleSource(new URL(rel, import.meta.url).pathname, { - format: bundleFormat, - }); - const srcGE = rel => - bundleSource(new URL(rel, import.meta.url).pathname, { - format: 'getExport', - }); +export async function buildKernelBundle() { + // this takes about 1.0s on my computer + const kernelBundle = await bundleRelative('../kernel/kernel.js'); + return harden(kernelBundle); +} +/** + * Build the source bundles for built-in vats and devices, and for the + * xsnap vat worker. + */ +export async function buildVatAndDeviceBundles() { const bundles = await allValues({ - kernel: src('../kernel/kernel.js'), - adminDevice: src('../devices/vat-admin/device-vat-admin.js'), - adminVat: src('../vats/vat-admin/vat-vat-admin.js'), - comms: src('../vats/comms/index.js'), - vattp: src('../vats/vattp/vat-vattp.js'), - timer: src('../vats/timer/vat-timer.js'), - - lockdown: srcGE( + adminDevice: bundleRelative('../devices/vat-admin/device-vat-admin.js'), + adminVat: bundleRelative('../vats/vat-admin/vat-vat-admin.js'), + comms: bundleRelative('../vats/comms/index.js'), + vattp: bundleRelative('../vats/vattp/vat-vattp.js'), + timer: bundleRelative('../vats/timer/vat-timer.js'), + + lockdown: bundleRelativeGE( '../supervisors/subprocess-xsnap/lockdown-subprocess-xsnap.js', ), - supervisor: srcGE( + supervisor: bundleRelativeGE( '../supervisors/subprocess-xsnap/supervisor-subprocess-xsnap.js', ), }); @@ -67,6 +67,22 @@ export async function buildKernelBundles(options = {}) { return harden(bundles); } +// Unit tests can call this to amortize the bundling costs: pass the +// result to initializeSwingset's initializationOptions.kernelBundles +// (for the vat/device/worker bundles), and you can pass .kernelBundle +// individually to makeSwingsetController's +// runtimeOptions.kernelBundle + +// Tests can also pass the whole result to buildVatController's +// runtimeOptions.kernelBundles, which will pass it through to both. + +export async function buildKernelBundles() { + const bp = buildVatAndDeviceBundles(); + const kp = buildKernelBundle(); + const [vdBundles, kernelBundle] = await Promise.all([bp, kp]); + return harden({ kernel: kernelBundle, ...vdBundles }); +} + function byName(a, b) { if (a.name < b.name) { return -1; @@ -256,7 +272,7 @@ function sortObjectProperties(obj, firsts = []) { return result; } -/** @typedef {{ kernelBundles?: Record, verbose?: boolean, +/** @typedef {{ kernelBundles?: Record, verbose?: boolean, * addVatAdmin?: boolean, addComms?: boolean, addVattp?: boolean, * addTimer?: boolean, * }} InitializationOptions @@ -318,9 +334,7 @@ export async function initializeSwingset( } const { - kernelBundles = await buildKernelBundles({ - bundleFormat: config.bundleFormat, - }), + kernelBundles = await buildVatAndDeviceBundles(), verbose, addVatAdmin = true, addComms = true, @@ -328,7 +342,6 @@ export async function initializeSwingset( addTimer = true, } = initializationOptions; - kvStore.set('kernelBundle', JSON.stringify(kernelBundles.kernel)); kvStore.set('lockdownBundle', JSON.stringify(kernelBundles.lockdown)); kvStore.set('supervisorBundle', JSON.stringify(kernelBundles.supervisor)); diff --git a/packages/SwingSet/src/kernel/state/kernelKeeper.js b/packages/SwingSet/src/kernel/state/kernelKeeper.js index 875f0fcdc97..c4a85811eed 100644 --- a/packages/SwingSet/src/kernel/state/kernelKeeper.js +++ b/packages/SwingSet/src/kernel/state/kernelKeeper.js @@ -52,7 +52,6 @@ const enableKernelGC = true; // device.nextID = $NN // meter.nextID = $NN // used to make m$NN -// kernelBundle = JSON(bundle) // namedBundleID.$NAME = bundleID // bundle.$BUNDLEID = JSON(bundle) // diff --git a/packages/SwingSet/test/device-hooks/test-device-hooks.js b/packages/SwingSet/test/device-hooks/test-device-hooks.js index 8ce832df808..94b56bd2ba8 100644 --- a/packages/SwingSet/test/device-hooks/test-device-hooks.js +++ b/packages/SwingSet/test/device-hooks/test-device-hooks.js @@ -59,8 +59,10 @@ test('add hook', async t => { addVattp: false, addTimer: false, }; + const { kernelBundle } = t.context.data.kernelBundles; + const runtimeOpts = { kernelBundle }; await initializeSwingset(config, [], hostStorage, initOpts); - const c = await makeSwingsetController(hostStorage, {}); + const c = await makeSwingsetController(hostStorage, {}, runtimeOpts); let hookreturn; function setHookReturn(args, slots = []) { diff --git a/packages/SwingSet/test/device-mailbox/test-device-mailbox.js b/packages/SwingSet/test/device-mailbox/test-device-mailbox.js index 7eb991419fb..1ce98d2c49c 100644 --- a/packages/SwingSet/test/device-mailbox/test-device-mailbox.js +++ b/packages/SwingSet/test/device-mailbox/test-device-mailbox.js @@ -13,6 +13,7 @@ import { buildMailboxStateMap, buildMailbox, } from '../../src/devices/mailbox/mailbox.js'; +import { bundleOpts } from '../util.js'; test.before(async t => { const kernelBundles = await buildKernelBundles(); @@ -37,13 +38,14 @@ test('mailbox outbound', async t => { }, }, }; - const deviceEndowments = { + const devEndows = { mailbox: { ...mb.endowments }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const hostStorage = provideHostStorage(); - await initializeSwingset(config, ['mailbox1'], hostStorage, t.context.data); - const c = await makeSwingsetController(hostStorage, deviceEndowments); + await initializeSwingset(config, ['mailbox1'], hostStorage, initOpts); + const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts); await c.run(); // exportToData() provides plain Numbers to the host that needs to convey the messages t.deepEqual(s.exportToData(), { @@ -85,13 +87,14 @@ test('mailbox inbound', async t => { }, }, }; - const deviceEndowments = { + const devEndows = { mailbox: { ...mb.endowments }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const hostStorage = provideHostStorage(); - await initializeSwingset(config, ['mailbox2'], hostStorage, t.context.data); - const c = await makeSwingsetController(hostStorage, deviceEndowments); + await initializeSwingset(config, ['mailbox2'], hostStorage, initOpts); + const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts); await c.run(); const m1 = [1, 'msg1']; const m2 = [2, 'msg2']; @@ -143,23 +146,25 @@ async function initializeMailboxKernel(t) { }, }, }; + const { initOpts } = bundleOpts(t.context.data); const hostStorage = provideHostStorage(); await initializeSwingset( config, ['mailbox-determinism'], hostStorage, - t.context.data, + initOpts, ); return hostStorage; } -async function makeMailboxKernel(hostStorage) { +async function makeMailboxKernel(t, hostStorage) { const s = buildMailboxStateMap(); const mb = buildMailbox(s); - const deviceEndowments = { + const devEndows = { mailbox: { ...mb.endowments }, }; - const c = await makeSwingsetController(hostStorage, deviceEndowments); + const { runtimeOpts } = bundleOpts(t.context.data); + const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts); c.pinVatRoot('bootstrap'); await c.run(); return [c, mb]; @@ -169,8 +174,8 @@ test('mailbox determinism', async t => { // we run two kernels in parallel const hostStorage1 = await initializeMailboxKernel(t); const hostStorage2 = await initializeMailboxKernel(t); - const [c1a, mb1a] = await makeMailboxKernel(hostStorage1); - const [c2, mb2] = await makeMailboxKernel(hostStorage2); + const [c1a, mb1a] = await makeMailboxKernel(t, hostStorage1); + const [c2, mb2] = await makeMailboxKernel(t, hostStorage2); // they get the same inbound message const msg1 = [[1, 'msg1']]; @@ -195,7 +200,7 @@ test('mailbox determinism', async t => { ); // then one is restarted, but the other keeps running - const [c1b, mb1b] = await makeMailboxKernel(hostStorage1); + const [c1b, mb1b] = await makeMailboxKernel(t, hostStorage1); // Now we repeat delivery of that message to both. The mailbox should send // it to vattp, even though it's duplicate, because the mailbox doesn't diff --git a/packages/SwingSet/test/devices/test-devices.js b/packages/SwingSet/test/devices/test-devices.js index 31c579cffa0..e7277cd1de1 100644 --- a/packages/SwingSet/test/devices/test-devices.js +++ b/packages/SwingSet/test/devices/test-devices.js @@ -12,6 +12,7 @@ import { buildKernelBundles, } from '../../src/index.js'; import buildCommand from '../../src/devices/command/command.js'; +import { bundleOpts } from '../util.js'; function capdata(body, slots = []) { return harden({ body, slots }); @@ -61,9 +62,10 @@ test.serial('d0', async t => { }, }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const hostStorage = provideHostStorage(); - await initializeSwingset(config, [], hostStorage); - const c = await makeSwingsetController(hostStorage, {}); + await initializeSwingset(config, [], hostStorage, initOpts); + const c = await makeSwingsetController(hostStorage, {}, runtimeOpts); await c.run(); // console.log(util.inspect(c.dump(), { depth: null })); @@ -108,15 +110,16 @@ test.serial('d1', async t => { }, }, }; - const deviceEndowments = { + const devEndows = { d1: { shared: sharedArray, }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const hostStorage = provideHostStorage(); - await initializeSwingset(config, [], hostStorage, t.context.data); - const c = await makeSwingsetController(hostStorage, deviceEndowments); + await initializeSwingset(config, [], hostStorage, initOpts); + const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts); c.pinVatRoot('bootstrap'); await c.run(); @@ -149,9 +152,10 @@ async function test2(t, mode) { }, }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const hostStorage = provideHostStorage(); - await initializeSwingset(config, [], hostStorage, t.context.data); - const c = await makeSwingsetController(hostStorage, {}); + await initializeSwingset(config, [], hostStorage, initOpts); + const c = await makeSwingsetController(hostStorage, {}, runtimeOpts); c.pinVatRoot('bootstrap'); await c.run(); // startup @@ -238,10 +242,11 @@ test.serial('device state', async t => { }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); // The initial state should be missing (null). Then we set it with the call // from bootstrap, and read it back. - await initializeSwingset(config, ['write+read'], hostStorage, t.context.data); - const c1 = await makeSwingsetController(hostStorage, {}); + await initializeSwingset(config, ['write+read'], hostStorage, initOpts); + const c1 = await makeSwingsetController(hostStorage, {}, runtimeOpts); const d3 = c1.deviceNameToID('d3'); await c1.run(); t.deepEqual(c1.dump().log, ['undefined', 'w+r', 'called', 'got {"s":"new"}']); @@ -266,13 +271,14 @@ test.serial('command broadcast', async t => { }, }, }; - const deviceEndowments = { + const devEndows = { command: { ...cm.endowments }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const hostStorage = provideHostStorage(); - await initializeSwingset(config, [], hostStorage, t.context.data); - const c = await makeSwingsetController(hostStorage, deviceEndowments); + await initializeSwingset(config, [], hostStorage, initOpts); + const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts); c.pinVatRoot('bootstrap'); c.queueToVatRoot('bootstrap', 'doCommand1', [], 'panic'); await c.run(); @@ -294,13 +300,14 @@ test.serial('command deliver', async t => { }, }, }; - const deviceEndowments = { + const devEndows = { command: { ...cm.endowments }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const hostStorage = provideHostStorage(); - await initializeSwingset(config, [], hostStorage, t.context.data); - const c = await makeSwingsetController(hostStorage, deviceEndowments); + await initializeSwingset(config, [], hostStorage, initOpts); + const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts); c.pinVatRoot('bootstrap'); c.queueToVatRoot('bootstrap', 'doCommand2', [], 'panic'); await c.run(); @@ -339,9 +346,10 @@ test.serial('liveslots throws when D() gets promise', async t => { }, }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const hostStorage = provideHostStorage(); - await initializeSwingset(config, [], hostStorage, t.context.data); - const c = await makeSwingsetController(hostStorage, {}); + await initializeSwingset(config, [], hostStorage, initOpts); + const c = await makeSwingsetController(hostStorage, {}, runtimeOpts); c.pinVatRoot('bootstrap'); // When liveslots catches an attempt to send a promise into D(), it throws @@ -377,9 +385,10 @@ test.serial('syscall.callNow(promise) is vat-fatal', async t => { }, }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const hostStorage = provideHostStorage(); - await initializeSwingset(config, [], hostStorage, t.context.data); - const c = await makeSwingsetController(hostStorage, {}); + await initializeSwingset(config, [], hostStorage, initOpts); + const c = await makeSwingsetController(hostStorage, {}, runtimeOpts); c.pinVatRoot('bootstrap'); await c.run(); @@ -413,13 +422,14 @@ test.serial('device errors cause vat-catchable D error', async t => { }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const bootstrapResult = await initializeSwingset( config, [], hostStorage, - t.context.data, + initOpts, ); - const c = await makeSwingsetController(hostStorage, {}); + const c = await makeSwingsetController(hostStorage, {}, runtimeOpts); await c.run(); t.is(c.kpStatus(bootstrapResult), 'fulfilled'); // not 'rejected' @@ -451,13 +461,14 @@ test.serial('foreign device nodes cause a catchable error', async t => { }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const bootstrapResult = await initializeSwingset( config, [], hostStorage, - t.context.data, + initOpts, ); - const c = await makeSwingsetController(hostStorage, {}); + const c = await makeSwingsetController(hostStorage, {}, runtimeOpts); await c.run(); t.is(c.kpStatus(bootstrapResult), 'fulfilled'); // not 'rejected' diff --git a/packages/SwingSet/test/devices/test-raw-device.js b/packages/SwingSet/test/devices/test-raw-device.js index 9a4cdad75c8..9d276381c17 100644 --- a/packages/SwingSet/test/devices/test-raw-device.js +++ b/packages/SwingSet/test/devices/test-raw-device.js @@ -11,6 +11,7 @@ import { makeSwingsetController, buildKernelBundles, } from '../../src/index.js'; +import { bundleOpts } from '../util.js'; function dfile(name) { return new URL(`./${name}`, import.meta.url).pathname; @@ -41,15 +42,16 @@ test('d1', async t => { }, }, }; - const deviceEndowments = { + const devEndows = { dr: { shared: sharedArray, }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const hostStorage = provideHostStorage(); - await initializeSwingset(config, [], hostStorage, t.context.data); - const c = await makeSwingsetController(hostStorage, deviceEndowments); + await initializeSwingset(config, [], hostStorage, initOpts); + const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts); c.pinVatRoot('bootstrap'); await c.run(); diff --git a/packages/SwingSet/test/test-message-patterns.js b/packages/SwingSet/test/test-message-patterns.js index 61257039621..f89cabc1aff 100644 --- a/packages/SwingSet/test/test-message-patterns.js +++ b/packages/SwingSet/test/test-message-patterns.js @@ -19,6 +19,7 @@ import { buildVatController, buildKernelBundles, } from '../src/index.js'; +import { bundleOpts } from './util.js'; import { buildLoopbox } from '../src/devices/loopbox/loopbox.js'; import { buildPatterns } from './message-patterns.js'; @@ -127,7 +128,7 @@ for (const name of Array.from(bp.patterns.keys()).sort()) { } export async function runVatsInComms(t, name) { - const { commsConfig, kernelBundles } = t.context.data; + const { commsConfig } = t.context.data; const { passOneMessage, loopboxSrcPath, loopboxEndowments } = buildLoopbox('queued'); const devices = { @@ -139,12 +140,13 @@ export async function runVatsInComms(t, name) { }, }; const config = { ...commsConfig, devices }; - const deviceEndowments = { + const devEndows = { loopbox: { ...loopboxEndowments }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const hostStorage = provideHostStorage(); - await initializeSwingset(config, [name], hostStorage, { kernelBundles }); - const c = await makeSwingsetController(hostStorage, deviceEndowments); + await initializeSwingset(config, [name], hostStorage, initOpts); + const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts); t.teardown(c.shutdown); // await runWithTrace(c); diff --git a/packages/SwingSet/test/upgrade/test-upgrade-replay.js b/packages/SwingSet/test/upgrade/test-upgrade-replay.js index 775725f629e..2454a5f9000 100644 --- a/packages/SwingSet/test/upgrade/test-upgrade-replay.js +++ b/packages/SwingSet/test/upgrade/test-upgrade-replay.js @@ -9,7 +9,7 @@ import { initializeSwingset, makeSwingsetController, } from '../../src/index.js'; -import { capargs } from '../util.js'; +import { capargs, bundleOpts } from '../util.js'; function bfile(name) { return new URL(name, import.meta.url).pathname; @@ -43,13 +43,12 @@ test('replay after upgrade', async t => { upton: { sourceSpec: bfile('vat-upton-replay.js') }, }, }; + const { initOpts, runtimeOpts } = bundleOpts(t.context.data); const hostStorage1 = provideHostStorage(); { - await initializeSwingset(copy(config), [], hostStorage1, { - kernelBundles: t.context.data.kernelBundles, - }); - const c1 = await makeSwingsetController(hostStorage1); + await initializeSwingset(copy(config), [], hostStorage1, initOpts); + const c1 = await makeSwingsetController(hostStorage1, {}, runtimeOpts); c1.pinVatRoot('bootstrap'); await c1.run(); @@ -70,7 +69,7 @@ test('replay after upgrade', async t => { const hostStorage2 = provideHostStorage(); setAllState(hostStorage2, state1); { - const c2 = await makeSwingsetController(hostStorage2); + const c2 = await makeSwingsetController(hostStorage2, {}, runtimeOpts); c2.pinVatRoot('bootstrap'); await c2.run(); diff --git a/packages/SwingSet/test/util.js b/packages/SwingSet/test/util.js index d98d1cea0ac..6c75f5ccc59 100644 --- a/packages/SwingSet/test/util.js +++ b/packages/SwingSet/test/util.js @@ -171,3 +171,10 @@ export function makeKernelEndowments() { createSHA256, }; } + +export function bundleOpts(data, extraRuntimeOpts) { + const { kernel: kernelBundle, ...kernelBundles } = data.kernelBundles; + const initOpts = { kernelBundles }; + const runtimeOpts = { kernelBundle, ...extraRuntimeOpts }; + return { initOpts, runtimeOpts }; +} diff --git a/packages/SwingSet/test/vat-admin/test-create-vat.js b/packages/SwingSet/test/vat-admin/test-create-vat.js index 2b48e53b050..ddbe039e7e7 100644 --- a/packages/SwingSet/test/vat-admin/test-create-vat.js +++ b/packages/SwingSet/test/vat-admin/test-create-vat.js @@ -10,7 +10,7 @@ import { makeSwingsetController, loadBasedir, } from '../../src/index.js'; -import { capSlot } from '../util.js'; +import { capSlot, bundleOpts } from '../util.js'; import { extractMethod } from '../../src/lib/kdebug.js'; function nonBundleFunction(_E) { @@ -51,7 +51,7 @@ test.before(async t => { }); async function doTestSetup(t, enableSlog = false) { - const { bundles, kernelBundles } = t.context.data; + const { bundles } = t.context.data; const config = await loadBasedir(new URL('./', import.meta.url).pathname); config.defaultManagerType = 'xs-worker'; config.bundles = { @@ -60,8 +60,6 @@ async function doTestSetup(t, enableSlog = false) { brokenRoot: { bundle: bundles.brokenRootVatBundle }, brokenHang: { bundle: bundles.brokenHangVatBundle }, }; - const hostStorage = provideHostStorage(); - await initializeSwingset(config, [], hostStorage, { kernelBundles }); let doSlog = false; function slogSender(_, s) { if (!doSlog) return; @@ -74,7 +72,10 @@ async function doTestSetup(t, enableSlog = false) { console.log(JSON.stringify(o)); } } - const c = await makeSwingsetController(hostStorage, {}, { slogSender }); + const { initOpts, runtimeOpts } = bundleOpts(t.context.data, { slogSender }); + const hostStorage = provideHostStorage(); + await initializeSwingset(config, [], hostStorage, initOpts); + const c = await makeSwingsetController(hostStorage, {}, runtimeOpts); const id44 = await c.validateAndInstallBundle(bundles.vat44Bundle); const idRC = await c.validateAndInstallBundle(bundles.vatRefcountBundle); c.pinVatRoot('bootstrap');