From 2f3d54bbe628a12671ea31977e41d6e157e9b87a Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Wed, 4 May 2022 18:34:49 -0500 Subject: [PATCH] chore(swingset): split test out to a separate file 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 --- .../terminate/test-terminate-replay.js | 49 +++++++++++++++++++ .../vat-admin/terminate/test-terminate.js | 41 +--------------- 2 files changed, 50 insertions(+), 40 deletions(-) create mode 100644 packages/SwingSet/test/vat-admin/terminate/test-terminate-replay.js diff --git a/packages/SwingSet/test/vat-admin/terminate/test-terminate-replay.js b/packages/SwingSet/test/vat-admin/terminate/test-terminate-replay.js new file mode 100644 index 00000000000..04c591792ad --- /dev/null +++ b/packages/SwingSet/test/vat-admin/terminate/test-terminate-replay.js @@ -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, []); + } +}); diff --git a/packages/SwingSet/test/vat-admin/terminate/test-terminate.js b/packages/SwingSet/test/vat-admin/terminate/test-terminate.js index 27d8d1717cd..ab2db020cf8 100644 --- a/packages/SwingSet/test/vat-admin/terminate/test-terminate.js +++ b/packages/SwingSet/test/vat-admin/terminate/test-terminate.js @@ -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(); @@ -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;