Skip to content

Commit

Permalink
fix: split test in attempt to evade CI badness
Browse files Browse the repository at this point in the history
  • Loading branch information
FUDCo authored and mergify[bot] committed May 28, 2022
1 parent 9ef4941 commit e8055a4
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 95 deletions.
110 changes: 110 additions & 0 deletions packages/SwingSet/test/vat-admin/terminate/test-terminate-critical.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// eslint-disable-next-line import/order
import { test } from '../../../tools/prepare-test-env-ava.js';
// eslint-disable-next-line import/order
import { provideHostStorage } from '../../../src/controller/hostStorage.js';

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

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

async function doTerminateCritical(t, deadVatID, mode, dynamic) {
const configPath = new URL('swingset-terminate.json', import.meta.url)
.pathname;
const config = await loadSwingsetConfigFile(configPath);
const hostStorage = provideHostStorage();
const controller = await buildVatController(config, [mode, true, dynamic], {
...t.context.data,
hostStorage,
});
t.is(controller.kpStatus(controller.bootstrapResult), 'unresolved');
const preProbe = hostStorage.kvStore.get(`${deadVatID}.options`);
if (!dynamic) {
t.truthy(preProbe);
}

const err = await t.throwsAsync(() => controller.run());
const body = JSON.parse(err.message);
if (typeof body === 'string') {
t.is(body, mode);
} else {
t.is(body['@qclass'], 'error');
t.is(body.message, mode);
}
t.is(
controller.kpStatus(controller.bootstrapResult),
dynamic ? 'unresolved' : 'fulfilled',
);
const postProbe = hostStorage.kvStore.get(`${deadVatID}.options`);
t.is(postProbe, undefined);
}

test('terminate (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'kill', true);
});

// no test 'terminate (static, critical)' because static vats can't be killed

test('exit happy path simple result (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'happy', true);
});

test('exit happy path simple result (static, critical)', async t => {
await doTerminateCritical(t, 'v3', 'happy', false);
});

test('exit happy path complex result (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'exceptionallyHappy', true);
});

test('exit happy path complex result (static, critical)', async t => {
await doTerminateCritical(t, 'v3', 'exceptionallyHappy', false);
});

test('exit sad path simple result (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'sad', true);
});

test('exit sad path simple result (static, critical)', async t => {
await doTerminateCritical(t, 'v3', 'sad', false);
});

test('exit sad path complex result (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'exceptionallySad', true);
});

test('exit sad path complex result (static, critical)', async t => {
await doTerminateCritical(t, 'v3', 'exceptionallySad', false);
});

test('exit happy path with ante-mortem message (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'happyTalkFirst', true);
});

test('exit happy path with ante-mortem message (static, critical)', async t => {
await doTerminateCritical(t, 'v3', 'happyTalkFirst', false);
});

test('exit sad path with ante-mortem message (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'sadTalkFirst', true);
});

test('exit sad path with ante-mortem message (static, critical)', async t => {
await doTerminateCritical(t, 'v3', 'sadTalkFirst', false);
});

test('invalid criticalVatKey causes vat creation to fail', async t => {
const configPath = new URL('swingset-bad-vat-key.json', import.meta.url)
.pathname;
const config = await loadSwingsetConfigFile(configPath);
const controller = await buildVatController(config, [], t.context.data);
await t.throwsAsync(() => controller.run(), {
message: /invalid criticalVatKey/,
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -67,37 +67,6 @@ async function doTerminateNonCritical(
t.is(postProbe, undefined);
}

async function doTerminateCritical(t, deadVatID, mode, dynamic) {
const configPath = new URL('swingset-terminate.json', import.meta.url)
.pathname;
const config = await loadSwingsetConfigFile(configPath);
const hostStorage = provideHostStorage();
const controller = await buildVatController(config, [mode, true, dynamic], {
...t.context.data,
hostStorage,
});
t.is(controller.kpStatus(controller.bootstrapResult), 'unresolved');
const preProbe = hostStorage.kvStore.get(`${deadVatID}.options`);
if (!dynamic) {
t.truthy(preProbe);
}

const err = await t.throwsAsync(() => controller.run());
const body = JSON.parse(err.message);
if (typeof body === 'string') {
t.is(body, mode);
} else {
t.is(body['@qclass'], 'error');
t.is(body.message, mode);
}
t.is(
controller.kpStatus(controller.bootstrapResult),
dynamic ? 'unresolved' : 'fulfilled',
);
const postProbe = hostStorage.kvStore.get(`${deadVatID}.options`);
t.is(postProbe, undefined);
}

test('terminate (dynamic, non-critical)', async t => {
await doTerminateNonCritical(
t,
Expand All @@ -110,12 +79,6 @@ test('terminate (dynamic, non-critical)', async t => {

// no test 'terminate (static, non-critical)' because static vats can't be killed

test('terminate (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'kill', true);
});

// no test 'terminate (static, critical)' because static vats can't be killed

test('exit happy path simple result (dynamic, non-critical)', async t => {
await doTerminateNonCritical(
t,
Expand All @@ -136,14 +99,6 @@ test('exit happy path simple result (static, non-critical)', async t => {
);
});

test('exit happy path simple result (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'happy', true);
});

test('exit happy path simple result (static, critical)', async t => {
await doTerminateCritical(t, 'v3', 'happy', false);
});

test('exit happy path complex result (dynamic, non-critical)', async t => {
await doTerminateNonCritical(
t,
Expand All @@ -164,14 +119,6 @@ test('exit happy path complex result (static, non-critical)', async t => {
);
});

test('exit happy path complex result (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'exceptionallyHappy', true);
});

test('exit happy path complex result (static, critical)', async t => {
await doTerminateCritical(t, 'v3', 'exceptionallyHappy', false);
});

test('exit sad path simple result (dynamic, non-critical)', async t => {
await doTerminateNonCritical(
t,
Expand All @@ -192,14 +139,6 @@ test('exit sad path simple result (static, non-critical)', async t => {
);
});

test('exit sad path simple result (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'sad', true);
});

test('exit sad path simple result (static, critical)', async t => {
await doTerminateCritical(t, 'v3', 'sad', false);
});

test('exit sad path complex result (dynamic, non-critical)', async t => {
await doTerminateNonCritical(
t,
Expand All @@ -220,14 +159,6 @@ test('exit sad path complex result (static, non-critical)', async t => {
);
});

test('exit sad path complex result (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'exceptionallySad', true);
});

test('exit sad path complex result (static, critical)', async t => {
await doTerminateCritical(t, 'v3', 'exceptionallySad', false);
});

test('exit happy path with ante-mortem message (dynamic, non-critical)', async t => {
await doTerminateNonCritical(
t,
Expand All @@ -250,14 +181,6 @@ test('exit happy path with ante-mortem message (static, non-critical)', async t
);
});

test('exit happy path with ante-mortem message (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'happyTalkFirst', true);
});

test('exit happy path with ante-mortem message (static, critical)', async t => {
await doTerminateCritical(t, 'v3', 'happyTalkFirst', false);
});

test('exit sad path with ante-mortem message (dynamic, non-critical)', async t => {
await doTerminateNonCritical(
t,
Expand All @@ -284,14 +207,6 @@ test('exit sad path with ante-mortem message (static, non-critical)', async t =>
);
});

test('exit sad path with ante-mortem message (dynamic, critical)', async t => {
await doTerminateCritical(t, 'v8', 'sadTalkFirst', true);
});

test('exit sad path with ante-mortem message (static, critical)', async t => {
await doTerminateCritical(t, 'v3', 'sadTalkFirst', false);
});

test('exit with presence', async t => {
const configPath = new URL('swingset-die-with-presence.json', import.meta.url)
.pathname;
Expand Down Expand Up @@ -349,16 +264,6 @@ test.serial('dispatches to the dead do not harm kernel', async t => {
}
});

test('invalid criticalVatKey causes vat creation to fail', async t => {
const configPath = new URL('swingset-bad-vat-key.json', import.meta.url)
.pathname;
const config = await loadSwingsetConfigFile(configPath);
const controller = await buildVatController(config, [], t.context.data);
await t.throwsAsync(() => controller.run(), {
message: /invalid criticalVatKey/,
});
});

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 e8055a4

Please sign in to comment.