Skip to content

Commit

Permalink
test(SwingSet): Run bootstrap test vat controllers to completion (#4678)
Browse files Browse the repository at this point in the history
Fixes #4632
  • Loading branch information
gibson042 committed Feb 26, 2022
1 parent 5037442 commit 5647d10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
8 changes: 6 additions & 2 deletions packages/SwingSet/test/basedir-controller-2/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Far } from '@endo/marshal';

export function buildRootObject(vatPowers) {
vatPowers.testLog(`bootstrap called`);
return Far('root', {});
vatPowers.testLog(`buildRootObject called`);
return Far('root', {
bootstrap: () => {
vatPowers.testLog(`bootstrap called`);
},
});
}
30 changes: 6 additions & 24 deletions packages/SwingSet/test/test-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,9 @@ test('bootstrap', async t => {
const config = await loadBasedir(
new URL('basedir-controller-2', import.meta.url).pathname,
);
// the controller automatically runs the bootstrap function.
// basedir-controller-2/bootstrap.js logs "bootstrap called" and queues a call to
// left[0].bootstrap
const c = await buildVatController(config);
for (let i = 0; i < 5; i += 1) {
// eslint-disable-next-line no-await-in-loop
await c.step(); // vat start acceptance
// eslint-disable-next-line no-await-in-loop
await c.step(); // vat start deliver
}
t.deepEqual(c.dump().log, ['bootstrap called']);
await c.run();
t.deepEqual(c.dump().log, ['buildRootObject called', 'bootstrap called']);
});

test('XS bootstrap', async t => {
Expand All @@ -133,13 +125,8 @@ test('XS bootstrap', async t => {
config.defaultManagerType = 'xs-worker';
const hostStorage = provideHostStorage();
const c = await buildVatController(config, [], { hostStorage });
for (let i = 0; i < 5; i += 1) {
// eslint-disable-next-line no-await-in-loop
await c.step(); // vat start acceptance
// eslint-disable-next-line no-await-in-loop
await c.step(); // vat start deliver
}
t.deepEqual(c.dump().log, ['bootstrap called']);
await c.run();
t.deepEqual(c.dump().log, ['buildRootObject called', 'bootstrap called']);
t.is(
hostStorage.kvStore.get('kernel.defaultManagerType'),
'xs-worker',
Expand Down Expand Up @@ -172,13 +159,8 @@ test('static vats are unmetered on XS', async t => {
},
},
);
for (let i = 0; i < 5; i += 1) {
// eslint-disable-next-line no-await-in-loop
await c.step(); // vat start acceptance
// eslint-disable-next-line no-await-in-loop
await c.step(); // vat start deliver
}
t.deepEqual(c.dump().log, ['bootstrap called']);
await c.run();
t.deepEqual(c.dump().log, ['buildRootObject called', 'bootstrap called']);
t.deepEqual(limited, [false, false, false, false]);
});

Expand Down

0 comments on commit 5647d10

Please sign in to comment.