Skip to content

Commit

Permalink
chore: more review comment stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
FUDCo committed Sep 9, 2023
1 parent 5b5e64c commit 1b81633
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const collateralBrandKey = 'ATOM';

const makeDefaultTestContext = async t => {
console.time('DefaultTestContext');
const swingsetTestKit = await makeSwingsetTestKit(t, 'bundles/vaults');
const swingsetTestKit = await makeSwingsetTestKit(t.log, 'bundles/vaults');

const { runUtils, storage } = swingsetTestKit;
console.timeLog('DefaultTestContext', 'swingsetTestKit');
Expand Down
5 changes: 3 additions & 2 deletions packages/boot/test/bootstrapTests/benchmarkerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import '@endo/init';
import { Fail } from '@agoric/assert';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import { makeAgoricNamesRemotesFromFakeStorage } from '@agoric/vats/tools/board-utils.js';
import { makeStandaloneSwingsetTestKit } from './supports.js';
import { makeSwingsetTestKit } from './supports.js';
import { makeWalletFactoryDriver } from './drivers.js';

// When I was a child my family took a lot of roadtrips around California to go
Expand Down Expand Up @@ -112,6 +112,7 @@ let defaultRounds = 1;
let verbose = false;
let help = false;
let dump = false;
/** @type ManagerType */
let defaultManagerType = 'xs-worker';
const options = {};
const benchmarkPatts = [];
Expand Down Expand Up @@ -414,7 +415,7 @@ export const makeBenchmarkerator = async () => {
const benchmarks = new Map();

const setupStartTime = readClock();
const swingsetTestKit = await makeStandaloneSwingsetTestKit(undefined, {
const swingsetTestKit = await makeSwingsetTestKit(console.log, undefined, {
defaultManagerType,
verbose,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/test/bootstrapTests/liquidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const likePayouts = ({ Bid, Collateral }) => ({

export const makeLiquidationTestContext = async t => {
console.time('DefaultTestContext');
const swingsetTestKit = await makeSwingsetTestKit(t, 'bundles/vaults', {
const swingsetTestKit = await makeSwingsetTestKit(t.log, 'bundles/vaults', {
configSpecifier: '@agoric/vm-config/decentral-main-vaults-config.json',
});

Expand Down
48 changes: 14 additions & 34 deletions packages/boot/test/bootstrapTests/supports.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,19 @@ export const makeProposalExtractor = ({ childProcess, fs }) => {
harden(makeProposalExtractor);

/**
* Common body for makeSwingsetTestKit and makeStandaloneSwingsetTestKit.
* Start a SwingSet kernel to be used by tests and benchmarks.
*
* In the case of Ava tests, this kernel is expected to be shared across all
* tests in a given test module. By default Ava tests run in parallel, so be
* careful to avoid ordering dependencies between them. For example, test
* accounts balances using separate wallets or test vault factory metrics using
* separate collateral managers. (Or use test.serial)
*
* The shutdown() function _must_ be called after the test or benchmarks are
* complete, else V8 will see the xsnap workers still running, and will never
* exit (leading to a timeout error). Ava tests should use
* t.after.always(shutdown), because the normal t.after() hooks are not run if a
* test fails.
*
* @param {(..._: any[]) => any} log
* @param {string} bundleDir directory to write bundles and config to
Expand All @@ -335,7 +347,7 @@ harden(makeProposalExtractor);
* @param {boolean} [options.verbose]
* @param {ManagerType} [options.defaultManagerType]
*/
const makeBaseSwingsetTestKit = async (
export const makeSwingsetTestKit = async (
log,
bundleDir = 'bundles',
{
Expand Down Expand Up @@ -513,35 +525,3 @@ const makeBaseSwingsetTestKit = async (
timer,
};
};

/**
* Start a SwingSet kernel to be used by Ava tests. This kernel is expected to
* be shared across all tests in a given test module. By default Ava tests run
* in parallel, so be careful to avoid ordering dependencies between them. For
* example, test accounts balances using separate wallets or test vault factory
* metrics using separate collateral managers. (Or use test.serial)
*
* The shutdown() function _must_ be called after the test is complete, or else
* V8 will see the xsnap workers still running, and will never exit (leading to
* a timeout error). Use t.after.always(shutdown), because the normal t.after()
* hooks are not run if a test fails.
*
* @param {import('ava').ExecutionContext} t
* @param {string} [bundleDir] directory to write bundles and config to
* @param {object} [options]
*/
export const makeSwingsetTestKit = async (t, bundleDir, options) =>
makeBaseSwingsetTestKit(t.log, bundleDir, options);

/**
* Start a SwingSet kernel to be used by a standalone executable.
*
* The shutdown() function _must_ be called after execution is complete, or else
* V8 will see the xsnap workers still running, and will never exit (leading to
* a timeout error).
*
* @param {string} [bundleDir] directory to write bundles and config to
* @param {object} [options]
*/
export const makeStandaloneSwingsetTestKit = async (bundleDir, options) =>
makeBaseSwingsetTestKit(console.log, bundleDir, options);
8 changes: 5 additions & 3 deletions packages/boot/test/bootstrapTests/test-demo-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ const { keys } = Object;
const test = anyTest;

const makeDefaultTestContext = async t => {
const swingsetTestKit = await makeSwingsetTestKit(t, 'bundles/demo-config', {
configSpecifier: '@agoric/vm-config/decentral-demo-config.json',
});
const swingsetTestKit = await makeSwingsetTestKit(
t.log,
'bundles/demo-config',
{ configSpecifier: '@agoric/vm-config/decentral-demo-config.json' },
);
return swingsetTestKit;
};

Expand Down
2 changes: 1 addition & 1 deletion packages/boot/test/bootstrapTests/test-vats-restart.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const PLATFORM_CONFIG = '@agoric/vm-config/decentral-itest-vaults-config.json';
export const makeTestContext = async t => {
console.time('DefaultTestContext');
/** @type {SwingsetTestKit} */
const swingsetTestKit = await makeSwingsetTestKit(t, 'bundles/vaults', {
const swingsetTestKit = await makeSwingsetTestKit(t.log, 'bundles/vaults', {
configSpecifier: PLATFORM_CONFIG,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const likePayouts = (collateral, minted) => ({

const makeDefaultTestContext = async t => {
console.time('DefaultTestContext');
const swingsetTestKit = await makeSwingsetTestKit(t, 'bundles/vaults');
const swingsetTestKit = await makeSwingsetTestKit(t.log, 'bundles/vaults');

const { runUtils, storage } = swingsetTestKit;
console.timeLog('DefaultTestContext', 'swingsetTestKit');
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/test/bootstrapTests/test-vaults-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const makeDefaultTestContext = async (
{ incarnation = 1, logTiming = true, storage = undefined } = {},
) => {
logTiming && console.time('DefaultTestContext');
const swingsetTestKit = await makeSwingsetTestKit(t, 'bundles/vaults', {
const swingsetTestKit = await makeSwingsetTestKit(t.log, 'bundles/vaults', {
storage,
});

Expand Down
2 changes: 1 addition & 1 deletion packages/boot/test/bootstrapTests/test-zcf-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const ZCF_PROBE_SRC = './zcfProbe.js';
export const makeZoeTestContext = async t => {
console.time('ZoeTestContext');
/** @type {SwingsetTestKit} */
const swingsetTestKit = await makeSwingsetTestKit(t, 'bundles/zoe', {
const swingsetTestKit = await makeSwingsetTestKit(t.log, 'bundles/zoe', {
configSpecifier: '@agoric/vm-config/decentral-demo-config.json',
});

Expand Down

0 comments on commit 1b81633

Please sign in to comment.