Skip to content

Commit

Permalink
chore(swingset): split test out to a separate file
Browse files Browse the repository at this point in the history
We think GC under Node.js is a bit squirrly in the face of AVA's
parallelism, and moving the intermittently-failing test into its own
file might help

refs #5266
  • Loading branch information
warner authored and mergify[bot] committed May 5, 2022
1 parent 92da539 commit 2f3d54b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// eslint-disable-next-line import/order
import { test } from '../../../tools/prepare-test-env-ava.js';
// eslint-disable-next-line import/order
import { getAllState, setAllState } from '@agoric/swing-store';
import { provideHostStorage } from '../../../src/controller/hostStorage.js';

import {
buildVatController,
loadSwingsetConfigFile,
buildKernelBundles,
} from '../../../src/index.js';
import { capargs } from '../../util.js';

test.before(async t => {
const kernelBundles = await buildKernelBundles();
t.context.data = { kernelBundles };
});

test.serial('replay does not resurrect dead vat', async t => {
const configPath = new URL('swingset-no-zombies.json', import.meta.url)
.pathname;
const config = await loadSwingsetConfigFile(configPath);

const hostStorage1 = provideHostStorage();
{
const c1 = await buildVatController(config, [], {
hostStorage: hostStorage1,
kernelBundles: t.context.data.kernelBundles,
});
await c1.run();
t.deepEqual(c1.kpResolution(c1.bootstrapResult), capargs('bootstrap done'));
// this comes from the dynamic vat...
t.deepEqual(c1.dump().log, [`w: I ate'nt dead`]);
}

const state1 = getAllState(hostStorage1);
const hostStorage2 = provideHostStorage();
// XXX TODO also copy transcripts
setAllState(hostStorage2, state1);
{
const c2 = await buildVatController(config, [], {
hostStorage: hostStorage2,
kernelBundles: t.context.data.kernelBundles,
});
await c2.run();
// ...which shouldn't run the second time through
t.deepEqual(c2.dump().log, []);
}
});
41 changes: 1 addition & 40 deletions packages/SwingSet/test/vat-admin/terminate/test-terminate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ import {
loadSwingsetConfigFile,
buildKernelBundles,
} from '../../../src/index.js';

function capdata(body, slots = []) {
return harden({ body, slots });
}

function capargs(args, slots = []) {
return capdata(JSON.stringify(args), slots);
}
import { capargs } from '../../util.js';

test.before(async t => {
const kernelBundles = await buildKernelBundles();
Expand Down Expand Up @@ -162,38 +155,6 @@ test.serial('dispatches to the dead do not harm kernel', async t => {
}
});

test.serial('replay does not resurrect dead vat', async t => {
const configPath = new URL('swingset-no-zombies.json', import.meta.url)
.pathname;
const config = await loadSwingsetConfigFile(configPath);

const hostStorage1 = provideHostStorage();
{
const c1 = await buildVatController(config, [], {
hostStorage: hostStorage1,
kernelBundles: t.context.data.kernelBundles,
});
await c1.run();
t.deepEqual(c1.kpResolution(c1.bootstrapResult), capargs('bootstrap done'));
// this comes from the dynamic vat...
t.deepEqual(c1.dump().log, [`w: I ate'nt dead`]);
}

const state1 = getAllState(hostStorage1);
const hostStorage2 = provideHostStorage();
// XXX TODO also copy transcripts
setAllState(hostStorage2, state1);
{
const c2 = await buildVatController(config, [], {
hostStorage: hostStorage2,
kernelBundles: t.context.data.kernelBundles,
});
await c2.run();
// ...which shouldn't run the second time through
t.deepEqual(c2.dump().log, []);
}
});

test('dead vat state removed', async t => {
const configPath = new URL('swingset-die-cleanly.json', import.meta.url)
.pathname;
Expand Down

0 comments on commit 2f3d54b

Please sign in to comment.