From 6c2e3a4383851b103b2eab64bab790327f5e8d08 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Fri, 1 Apr 2022 09:19:29 -0700 Subject: [PATCH] chore: comply with ava/recommended eslint --- packages/SwingSet/test/message-patterns.js | 3 +- packages/SwingSet/test/test-bundle-handler.js | 6 +- .../vat-admin/terminate/test-terminate.js | 1 + .../SwingSet/test/vat-admin/test-replay.js | 1 + .../test/test-provision-smartwallet.js | 8 +- packages/eslint-config/eslint-config.cjs | 2 - .../committeeBinary/test-committee.js | 1 + .../test/unitTests/test-importsA.js | 9 - .../test/test-gov-collateral.js | 8 +- packages/internal/test/test-callback.js | 2 +- packages/notifier/test/test-publish-kit.js | 5 +- packages/solo/src/start.js | 1 + packages/solo/test/test-home.js | 2 +- .../test/test-collection-schema-refcount.js | 4 +- .../test/test-durabilityChecks.js | 4 +- .../swingset-liveslots/test/test-liveslots.js | 23 +- packages/swingset-liveslots/test/util.js | 2 +- .../virtual-objects/test-reachable-vrefs.js | 2 +- packages/vats/test/test-dump.js | 17 +- packages/vats/test/test-repl.js | 20 +- .../vats/test/upgrading/test-upgrade-vats.js | 2 +- packages/xsnap-lockdown/test/test-inspect.js | 3 +- packages/xsnap/test/test-boot-lockdown.js | 64 +++--- packages/xsnap/test/test-gc.js | 2 +- packages/xsnap/test/test-replay.js | 2 +- packages/xsnap/test/test-xs-limits.js | 2 +- packages/xsnap/test/test-xs-perf.js | 7 +- packages/xsnap/test/test-xsnap.js | 208 ++++++------------ .../zoe/test/swingsetTests/zoe/test-zoe.js | 2 +- 29 files changed, 164 insertions(+), 249 deletions(-) diff --git a/packages/SwingSet/test/message-patterns.js b/packages/SwingSet/test/message-patterns.js index 26aed4cec3a..fc10fe888d1 100644 --- a/packages/SwingSet/test/message-patterns.js +++ b/packages/SwingSet/test/message-patterns.js @@ -1,5 +1,4 @@ -/* eslint no-lone-blocks: "off" */ -/* eslint dot-notation: "off" */ +/* eslint-disable no-lone-blocks, dot-notation */ // I turned off dot-notation so eslint won't rewrite the grep-preserving // test.stuff patterns. diff --git a/packages/SwingSet/test/test-bundle-handler.js b/packages/SwingSet/test/test-bundle-handler.js index afb69a1e064..5dc879e8f75 100644 --- a/packages/SwingSet/test/test-bundle-handler.js +++ b/packages/SwingSet/test/test-bundle-handler.js @@ -56,8 +56,8 @@ test('bundle handler', async t => { t.is(store.size, 2); t.deepEqual(ids, ['b0-lockdown.sha', 'b0-supervisor.sha']); // contents were fetched from bundleData - t.deepEqual(await handler.getBundle('b0-lockdown.sha'), 'lockdown'); - t.deepEqual(await handler.getBundle('b0-supervisor.sha'), 'supervisor'); + t.is(await handler.getBundle('b0-lockdown.sha'), 'lockdown'); + t.is(await handler.getBundle('b0-supervisor.sha'), 'supervisor'); // subsequent queries should check hashes/ids but not re-read bundles const ids2 = await handler.getCurrentBundleIDs(); @@ -67,7 +67,7 @@ test('bundle handler', async t => { // getBundle is served from bundleStore, not elsewhere store.set('b0-lockdown.sha', 'other'); - t.deepEqual(await handler.getBundle('b0-lockdown.sha'), 'other'); + t.is(await handler.getBundle('b0-lockdown.sha'), 'other'); }); test('bundle data', async t => { diff --git a/packages/SwingSet/test/vat-admin/terminate/test-terminate.js b/packages/SwingSet/test/vat-admin/terminate/test-terminate.js index 61963431353..c1baf849f73 100644 --- a/packages/SwingSet/test/vat-admin/terminate/test-terminate.js +++ b/packages/SwingSet/test/vat-admin/terminate/test-terminate.js @@ -1,3 +1,4 @@ +/* eslint-disable no-lone-blocks */ // eslint-disable-next-line import/order import { test } from '../../../tools/prepare-test-env-ava.js'; // eslint-disable-next-line import/order diff --git a/packages/SwingSet/test/vat-admin/test-replay.js b/packages/SwingSet/test/vat-admin/test-replay.js index f380bd0a166..360d0582a45 100644 --- a/packages/SwingSet/test/vat-admin/test-replay.js +++ b/packages/SwingSet/test/vat-admin/test-replay.js @@ -1,3 +1,4 @@ +/* eslint-disable no-lone-blocks */ // eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; // eslint-disable-next-line import/order diff --git a/packages/cosmic-swingset/test/test-provision-smartwallet.js b/packages/cosmic-swingset/test/test-provision-smartwallet.js index 01df5c206cf..9a3e4cce6eb 100644 --- a/packages/cosmic-swingset/test/test-provision-smartwallet.js +++ b/packages/cosmic-swingset/test/test-provision-smartwallet.js @@ -59,13 +59,7 @@ test.before(async t => { t.context = { scenario2, walletTool, pspawnAgd, bootstrapAddr, soloAddr }; }); -// SKIP: struggling with timing issues resulting in one of... -// Error: cannot grab 250000uist coins: 0uist is smaller than 250000uist: insufficient funds -// error: code = NotFound desc = account agoric1mhu... not found -// Sometimes I can get this test to work alone, but not -// if run with the test above. -// TODO: https://github.com/Agoric/agoric-sdk/issues/6766 -test.skip('integration test: smart wallet provision', async t => { +test('integration test: smart wallet provision', async t => { const { scenario2, walletTool, soloAddr } = t.context; const enoughBlocksToProvision = 7; diff --git a/packages/eslint-config/eslint-config.cjs b/packages/eslint-config/eslint-config.cjs index f84bddbd99d..69843c6c7f8 100644 --- a/packages/eslint-config/eslint-config.cjs +++ b/packages/eslint-config/eslint-config.cjs @@ -48,8 +48,6 @@ module.exports = { }, ], - // We allow disabled tests in master - 'ava/no-skip-test': 'off', // Contrary to recommendation https://github.com/avajs/ava/blob/main/docs/recipes/typescript.md#typing-tcontext 'ava/use-test': 'off', diff --git a/packages/governance/test/swingsetTests/committeeBinary/test-committee.js b/packages/governance/test/swingsetTests/committeeBinary/test-committee.js index ad828181dc1..bd023896d1d 100644 --- a/packages/governance/test/swingsetTests/committeeBinary/test-committee.js +++ b/packages/governance/test/swingsetTests/committeeBinary/test-committee.js @@ -1,3 +1,4 @@ +/* eslint-disable ava/assertion-arguments -- the standard diff is unreadable */ // eslint-disable-next-line import/no-extraneous-dependencies import '@endo/init/debug.js'; import test from 'ava'; diff --git a/packages/import-manager/test/unitTests/test-importsA.js b/packages/import-manager/test/unitTests/test-importsA.js index 943ce83b863..fb3e3baaaf1 100644 --- a/packages/import-manager/test/unitTests/test-importsA.js +++ b/packages/import-manager/test/unitTests/test-importsA.js @@ -29,12 +29,3 @@ test('import listIsEmpty (true)', t => { const op = 'listIsEmpty'; t.truthy(importer[op]([])); }); - -// TODO: This test throws because `lookupImport` does not exist. This -// test needs to be fixed. -test.skip('import not found', t => { - const importer = makeGoodImportManager(); - t.throws(() => importer.lookupImport('emptyPixel'), { - message: /There is no entry for "c"./, - }); -}); diff --git a/packages/inter-protocol/test/test-gov-collateral.js b/packages/inter-protocol/test/test-gov-collateral.js index e80bc68dc2c..669228b7157 100644 --- a/packages/inter-protocol/test/test-gov-collateral.js +++ b/packages/inter-protocol/test/test-gov-collateral.js @@ -412,7 +412,7 @@ const makeScenario = async (t, { env = process.env } = {}) => { }; }; -test.skip('Benefactor can add to reserve', async t => { +test.failing('Benefactor can add to reserve', async t => { const s = await makeScenario(t); await s.startDevNet(); await s.provisionMembers(); @@ -427,7 +427,7 @@ test.skip('Benefactor can add to reserve', async t => { t.deepEqual(result, 'added Collateral to the Reserve'); }); -test.skip('voters get invitations', async t => { +test.failing('voters get invitations', async t => { const s = await makeScenario(t); await s.startDevNet(); const purses = await s.provisionMembers(); @@ -459,7 +459,7 @@ test.skip('voters get invitations', async t => { ); }); -test.skip('assets are in Vaults', async t => { +test.failing('assets are in Vaults', async t => { const s = await makeScenario(t); await s.startDevNet(); await s.provisionMembers(); @@ -491,7 +491,7 @@ test.skip('assets are in Vaults', async t => { }); }); -test.skip('Committee can raise debt limit', async t => { +test.failing('Committee can raise debt limit', async t => { const s = await makeScenario(t); await s.startDevNet(); const invitationPurses = await s.provisionMembers(); diff --git a/packages/internal/test/test-callback.js b/packages/internal/test/test-callback.js index 487b926eab6..9ac798ed4c2 100644 --- a/packages/internal/test/test-callback.js +++ b/packages/internal/test/test-callback.js @@ -188,7 +188,7 @@ test('far function callbacks', async t => { t.is(await p2r, '19go'); }); -test('bad callbacks', async t => { +test('bad callbacks', t => { t.throws( // @ts-expect-error deliberate: number is not assignable to function () => cb.makeFunctionCallback(42), diff --git a/packages/notifier/test/test-publish-kit.js b/packages/notifier/test/test-publish-kit.js index 709a4c1ded7..cb29878073d 100644 --- a/packages/notifier/test/test-publish-kit.js +++ b/packages/notifier/test/test-publish-kit.js @@ -395,6 +395,7 @@ test('durable publish kit upgrade trauma (full-vat integration)', async t => { const eachIterator2 = await run('messageVatObject', [ { presence: eachIterable, methodName: Symbol.asyncIterator }, ]); + // eslint-disable-next-line ava/prefer-async-await const assertDisconnection = (p, label) => { const expected = { incarnationNumber: 0, @@ -402,7 +403,7 @@ test('durable publish kit upgrade trauma (full-vat integration)', async t => { upgradeMessage: 'vat upgraded', }; return p.then( - (...args) => t.deepEqual(args, undefined, `${label} must be rejected`), + (...args) => t.is(args, undefined, `${label} must be rejected`), failure => t.deepEqual(failure, expected, `${label} must indicate disconnection`), ); @@ -458,7 +459,7 @@ test('durable publish kit upgrade trauma (full-vat integration)', async t => { // TODO: Find a way to test virtual object rehydration // without the overhead of vats. // https://github.com/Agoric/agoric-sdk/pull/6502#discussion_r1008492055 -test.skip('durable publish kit upgrade trauma', async t => { +test.failing('durable publish kit upgrade trauma', async t => { const baggage = makeBaggage(); const makeDurablePublishKit = prepareDurablePublishKit( baggage, diff --git a/packages/solo/src/start.js b/packages/solo/src/start.js index 81d13102d2c..ac62d3d843b 100644 --- a/packages/solo/src/start.js +++ b/packages/solo/src/start.js @@ -1,4 +1,5 @@ // @ts-check +/* eslint-disable no-lone-blocks */ /* global process setTimeout */ import fs from 'fs'; import url from 'url'; diff --git a/packages/solo/test/test-home.js b/packages/solo/test/test-home.js index b948b998ee9..23fb44b3e58 100644 --- a/packages/solo/test/test-home.js +++ b/packages/solo/test/test-home.js @@ -141,7 +141,7 @@ test.serial('home.localTimerService makeNotifier', async t => { const notifier = E(localTimerService).makeNotifier(1n, 1n); const update1 = await E(notifier).getUpdateSince(); const firstUpdate = update1.updateCount; - t.truthy(firstUpdate > 0); + t.true(firstUpdate > 0); const update2 = await E(notifier).getUpdateSince(update1.updateCount); t.truthy(BigInt(update2.updateCount) > BigInt(firstUpdate)); diff --git a/packages/swingset-liveslots/test/test-collection-schema-refcount.js b/packages/swingset-liveslots/test/test-collection-schema-refcount.js index 03db7d350a4..6738ead357e 100644 --- a/packages/swingset-liveslots/test/test-collection-schema-refcount.js +++ b/packages/swingset-liveslots/test/test-collection-schema-refcount.js @@ -91,13 +91,13 @@ test( test('virtual collection shape holds virtual', shapetest, 'virtual', 'virtual'); test('virtual collection shape holds durable', shapetest, 'virtual', 'durable'); -test.skip( +test.failing( 'durable collection shape holds ephmeral', shapetest, 'durable', 'ephemeral', ); -test.skip( +test.failing( 'durable collection shape holds virtual', shapetest, 'durable', diff --git a/packages/swingset-liveslots/test/test-durabilityChecks.js b/packages/swingset-liveslots/test/test-durabilityChecks.js index 29e60067791..3004d99dcb7 100644 --- a/packages/swingset-liveslots/test/test-durabilityChecks.js +++ b/packages/swingset-liveslots/test/test-durabilityChecks.js @@ -269,5 +269,5 @@ async function runDurabilityCheckTest(t, relaxDurabilityRules) { } } -test('durability checks (strict)', t => runDurabilityCheckTest(t, false)); -test('durability checks (relaxed)', t => runDurabilityCheckTest(t, true)); +test('durability checks (strict)', runDurabilityCheckTest, false); +test('durability checks (relaxed)', runDurabilityCheckTest, true); diff --git a/packages/swingset-liveslots/test/test-liveslots.js b/packages/swingset-liveslots/test/test-liveslots.js index f73a0829779..6f766dc6365 100644 --- a/packages/swingset-liveslots/test/test-liveslots.js +++ b/packages/swingset-liveslots/test/test-liveslots.js @@ -45,14 +45,14 @@ test('calls', async t => { // root!one() // sendOnly await dispatch(makeMessage(rootA, 'one', ['args'])); - t.deepEqual(log.shift(), 'one'); + t.is(log.shift(), 'one'); // pr = makePromise() // root!two(pr.promise) // pr.resolve('result') await dispatch(makeMessage(rootA, 'two', [kslot('p-1')])); t.deepEqual(log.shift(), { type: 'subscribe', target: 'p-1' }); - t.deepEqual(log.shift(), 'two true'); + t.is(log.shift(), 'two true'); await dispatch(makeResolve('p-1', kser('result'))); t.deepEqual(log.shift(), ['res', 'result']); @@ -63,7 +63,7 @@ test('calls', async t => { await dispatch(makeMessage(rootA, 'two', [kslot('p-2')])); t.deepEqual(log.shift(), { type: 'subscribe', target: 'p-2' }); - t.deepEqual(log.shift(), 'two true'); + t.is(log.shift(), 'two true'); await dispatch(makeReject('p-2', kser('rejection'))); t.deepEqual(log.shift(), ['rej', 'rejection']); @@ -99,7 +99,7 @@ test('liveslots pipelines to syscall.send', async t => { // for x!pipe1(), a second pipelined to the result promise of it, and a // third pipelined to the result of the second. - t.deepEqual(log.shift(), 'sent p1p2p3'); + t.is(log.shift(), 'sent p1p2p3'); t.deepEqual(log.shift(), { type: 'send', targetSlot: x, @@ -656,8 +656,7 @@ test('capdata size limit on syscalls', async t => { }; const send = op => dispatch(makeMessage(rootA, op, [kslot(target)], rp)); - const expectFail = () => - t.deepEqual(log.shift(), 'fail: syscall capdata too large'); + const expectFail = () => t.is(log.shift(), 'fail: syscall capdata too large'); const expectVoidReturn = () => t.deepEqual(log.shift(), { type: 'resolve', @@ -906,7 +905,7 @@ test('disable disavow', async t => { // root~.one() // sendOnly await dispatch(makeMessage(rootA, 'one', [])); - t.deepEqual(log.shift(), false); + t.is(log.shift(), false); t.deepEqual(log, []); }); @@ -967,7 +966,7 @@ test('disavow', async t => { // root~.one(import1) // sendOnly await dispatch(makeMessage(rootA, 'one', [kslot(import1)])); t.deepEqual(log.shift(), { type: 'dropImports', slots: [import1] }); - t.deepEqual(log.shift(), 'disavowed pres1'); + t.is(log.shift(), 'disavowed pres1'); function loggedError(re) { const l = log.shift(); @@ -975,11 +974,11 @@ test('disavow', async t => { t.truthy(re.test(l.message)); } loggedError(/attempt to disavow unknown/); - t.deepEqual(log.shift(), 'tried duplicate disavow'); + t.is(log.shift(), 'tried duplicate disavow'); loggedError(/attempt to disavow unknown/); - t.deepEqual(log.shift(), 'tried to disavow Promise'); + t.is(log.shift(), 'tried to disavow Promise'); loggedError(/attempt to disavow an export/); - t.deepEqual(log.shift(), 'tried to disavow export'); + t.is(log.shift(), 'tried to disavow export'); const msg = log.shift(); t.like(msg, { type: 'exit', @@ -987,7 +986,7 @@ test('disavow', async t => { }); expectError(t, msg.info, /this Presence has been disavowed/); t.deepEqual(log.shift(), Error('this Presence has been disavowed')); - t.deepEqual(log.shift(), 'tried to send to disavowed'); + t.is(log.shift(), 'tried to send to disavowed'); t.deepEqual(log, []); }); diff --git a/packages/swingset-liveslots/test/util.js b/packages/swingset-liveslots/test/util.js index 96816290901..22af120c7ec 100644 --- a/packages/swingset-liveslots/test/util.js +++ b/packages/swingset-liveslots/test/util.js @@ -48,7 +48,7 @@ export function buildDispatch(onDispatchCallback) { /** * @param {unknown} target - * @param {string} method + * @param {string | symbol} method * @param {any[]} args * @param {unknown} result */ diff --git a/packages/swingset-liveslots/test/virtual-objects/test-reachable-vrefs.js b/packages/swingset-liveslots/test/virtual-objects/test-reachable-vrefs.js index d772f5fdfd7..15e6275bda6 100644 --- a/packages/swingset-liveslots/test/virtual-objects/test-reachable-vrefs.js +++ b/packages/swingset-liveslots/test/virtual-objects/test-reachable-vrefs.js @@ -7,7 +7,7 @@ import { initEmpty } from '@agoric/store'; import { makeVatSlot } from '../../src/parseVatSlots.js'; import { makeFakeVirtualStuff } from '../../tools/fakeVirtualSupport.js'; -test('VOM tracks reachable vrefs', async t => { +test('VOM tracks reachable vrefs', t => { const { vom, vrm, cm } = makeFakeVirtualStuff(); const { defineKind } = vom; const { makeScalarBigWeakMapStore } = cm; diff --git a/packages/vats/test/test-dump.js b/packages/vats/test/test-dump.js index ce6a909936b..31ec4c0c0e2 100644 --- a/packages/vats/test/test-dump.js +++ b/packages/vats/test/test-dump.js @@ -1,11 +1,10 @@ -// @ts-check -import '@endo/init/debug.js'; +import '@endo/init'; import test from 'ava'; import { dump } from '../src/repl.js'; -// Taken from https://github.com/endojs/endo/blob/43b796232634b54c9e7de1c0a2349d22c29fc384/packages/ses/test/error/test-assert-log.js#L414 -test('dump: the @erights challenge', async t => { +// Taken from https://github.com/endojs/endo/tree/main/packages/ses/test/error/test-assert-log.js#L414 +test('dump: the @erights challenge', t => { const superTagged = { [Symbol.toStringTag]: 'Tagged' }; const subTagged = { __proto__: superTagged }; const subTaggedNonEmpty = { __proto__: superTagged, foo: 'x' }; @@ -25,14 +24,13 @@ test('dump: the @erights challenge', async t => { }, 2 ** 54, { superTagged, subTagged, subTaggedNonEmpty }, - { __proto__: null }, ]; t.is( dump(challenges), - '[[Promise],[Function foo],"[hilbert]",undefined,"undefined",[URIError: wut?],[33n,Symbol(foo),Symbol(bar),Symbol(Symbol.asyncIterator)],{"NaN":NaN,"Infinity":Infinity,"neg":-Infinity},18014398509481984,{"superTagged":[Object Tagged]{[Symbol(Symbol.toStringTag)]:"Tagged"},"subTagged":[Object Tagged]{},"subTaggedNonEmpty":[Object Tagged]{"foo":"x"}},{}]', + '[[Promise],[Function foo],"[hilbert]",undefined,"undefined",[URIError: wut?],[33n,Symbol(foo),Symbol(bar),Symbol(Symbol.asyncIterator)],{"NaN":NaN,"Infinity":Infinity,"neg":-Infinity},18014398509481984,{"superTagged":{[Symbol(Symbol.toStringTag)]:"Tagged"},"subTagged":[Object Tagged]{},"subTaggedNonEmpty":[Object Tagged]{"foo":"x"}}]', ); t.is( - dump(challenges, 2), + dump(challenges, ' '), `\ [ [Promise], @@ -54,15 +52,14 @@ test('dump: the @erights challenge', async t => { }, 18014398509481984, { - "superTagged": [Object Tagged] { + "superTagged": { [Symbol(Symbol.toStringTag)]: "Tagged" }, "subTagged": [Object Tagged] {}, "subTaggedNonEmpty": [Object Tagged] { "foo": "x" } - }, - {} + } ]`, ); }); diff --git a/packages/vats/test/test-repl.js b/packages/vats/test/test-repl.js index c9f0553d250..8cece741517 100644 --- a/packages/vats/test/test-repl.js +++ b/packages/vats/test/test-repl.js @@ -25,7 +25,7 @@ test('repl: basic eval, eventual promise resolution', async t => { const { doEval, sentMessages, getHighestHistory } = make(); let m = sentMessages.shift(); - t.deepEqual(m.type, 'updateHistory'); + t.is(m.type, 'updateHistory'); t.is(sentMessages.length, 0); t.deepEqual(getHighestHistory(), { highestHistory: -1 }); @@ -62,13 +62,13 @@ test('repl: basic eval, eventual promise resolution', async t => { t.deepEqual(sentMessages, []); }); -test('repl: bigInts', async t => { +test('repl: bigInts', t => { const { doEval, sentMessages } = make(); let m = sentMessages.shift(); t.deepEqual(doEval(0, '3n'), {}); m = sentMessages.shift(); - t.deepEqual(m.type, 'updateHistory'); + t.is(m.type, 'updateHistory'); t.is(sentMessages.length, 1); t.is(m.histnum, 0); @@ -80,7 +80,7 @@ test('repl: bigInts', async t => { t.deepEqual(sentMessages, []); }); -test('repl: Symbols', async t => { +test('repl: Symbols', t => { const { doEval, sentMessages } = make(); let m = sentMessages.shift(); @@ -96,7 +96,7 @@ test('repl: Symbols', async t => { for (const [expr, display] of exprDisplays) { t.deepEqual(doEval(histnum, expr), {}); m = sentMessages.shift(); - t.deepEqual(m.type, 'updateHistory'); + t.is(m.type, 'updateHistory'); t.is(sentMessages.length, 1); t.is(m.histnum, histnum); @@ -110,7 +110,7 @@ test('repl: Symbols', async t => { } }); -test('repl: unjsonables', async t => { +test('repl: unjsonables', t => { const { doEval, sentMessages } = make(); let m = sentMessages.shift(); @@ -119,7 +119,7 @@ test('repl: unjsonables', async t => { for (const valStr of ['NaN', 'Infinity', '-Infinity', 'undefined']) { t.deepEqual(doEval(histnum, valStr), {}); m = sentMessages.shift(); - t.deepEqual(m.type, 'updateHistory'); + t.is(m.type, 'updateHistory'); t.is(sentMessages.length, 1); t.is(m.histnum, histnum); @@ -133,11 +133,11 @@ test('repl: unjsonables', async t => { } }); -test('repl: sloppyGlobals, home, endowments', async t => { +test('repl: sloppyGlobals, home, endowments', t => { const { doEval, sentMessages } = make(); let m = sentMessages.shift(); - t.deepEqual(m.type, 'updateHistory'); + t.is(m.type, 'updateHistory'); t.is(sentMessages.length, 0); t.deepEqual( @@ -170,7 +170,7 @@ test('repl: eventual send', async t => { const { doEval, sentMessages } = make(); let m = sentMessages.shift(); - t.deepEqual(m.type, 'updateHistory'); + t.is(m.type, 'updateHistory'); t.is(sentMessages.length, 0); t.deepEqual(doEval(0, 'target = harden({ foo(x) { return x+1; } })'), {}); diff --git a/packages/vats/test/upgrading/test-upgrade-vats.js b/packages/vats/test/upgrading/test-upgrade-vats.js index 074365bac1c..04e23cf31c0 100644 --- a/packages/vats/test/upgrading/test-upgrade-vats.js +++ b/packages/vats/test/upgrading/test-upgrade-vats.js @@ -95,7 +95,7 @@ test('upgrade vat-board', async t => { t.is(actualThing, thing, 'must get original value back'); }); -test.skip('upgrade bootstrap vat', async t => { +test.failing('upgrade bootstrap vat', async t => { const { bfile } = t.context; const bundles = { chain: { sourceSpec: bfile('../src/core/boot-chain.js') }, diff --git a/packages/xsnap-lockdown/test/test-inspect.js b/packages/xsnap-lockdown/test/test-inspect.js index ad6735517f4..fadb99ae3f4 100644 --- a/packages/xsnap-lockdown/test/test-inspect.js +++ b/packages/xsnap-lockdown/test/test-inspect.js @@ -48,7 +48,7 @@ const testCases = [ ["new Proxy(() => {}, { get: () => 'foo' })", '[Function: foo]'], ]; -test('unconfined inspect', async t => { +test('unconfined inspect', t => { for (const testCase of testCases) { const [toEval, toRender] = Array.isArray(testCase) ? testCase @@ -56,6 +56,7 @@ test('unconfined inspect', async t => { // eslint-disable-next-line no-eval const evaled = (1, eval)(`(${toEval})`); // t.log(evaled); + // eslint-disable-next-line ava/assertion-arguments t.is(unconfinedInspect(evaled), toRender, toEval); } }); diff --git a/packages/xsnap/test/test-boot-lockdown.js b/packages/xsnap/test/test-boot-lockdown.js index e1f9456c41d..6f459262cdd 100644 --- a/packages/xsnap/test/test-boot-lockdown.js +++ b/packages/xsnap/test/test-boot-lockdown.js @@ -1,33 +1,28 @@ +// @ts-check // eslint-disable-next-line import/no-extraneous-dependencies import test from 'ava'; -import '@endo/init/debug.js'; +import '@endo/init'; import * as proc from 'child_process'; import * as os from 'os'; import * as fs from 'fs'; -import { tmpName } from 'tmp'; - -import { getLockdownBundle } from '@agoric/xsnap-lockdown'; import { xsnap } from '../src/xsnap.js'; import { options, loader } from './message-tools.js'; -const io = { spawn: proc.spawn, os: os.type(), fs, tmpName }; // WARNING: ambient +const io = { spawn: proc.spawn, os: os.type() }; // WARNING: ambient const ld = loader(import.meta.url, fs.promises.readFile); -const getBootScript = () => - getLockdownBundle().then(bundle => `(${bundle.source}\n)()`.trim()); - /** * @param {string} name * @param {string} script to execute - * @param {boolean} [savePrinted] + * @param {boolean=} savePrinted */ async function bootWorker(name, script, savePrinted = false) { const opts = options(io); - const worker = await xsnap({ ...opts, name }); + const worker = xsnap({ ...opts, name }); const preface = savePrinted ? ` @@ -51,23 +46,21 @@ async function bootWorker(name, script, savePrinted = false) { } /** - * @param {*} t - * @param {boolean} [savePrinted] + * @param {string} name + * @param {boolean=} savePrinted */ -async function bootSESWorker(t, savePrinted = false) { - const bootScript = await getBootScript(); - const ret = await bootWorker(t.title, bootScript, savePrinted); - t.teardown(ret.worker.close); - return ret; +async function bootSESWorker(name, savePrinted = false) { + const bootScript = await ld.asset('../dist/bundle-ses-boot.umd.js'); + return bootWorker(name, bootScript, savePrinted); } test('bootstrap to SES lockdown', async t => { - const bootScript = await getBootScript(); + const bootScript = await ld.asset('../dist/bundle-ses-boot.umd.js'); const opts = options(io); const name = 'SES lockdown worker'; - const vat = await xsnap({ ...opts, name }); + const vat = xsnap({ ...opts, name }); await vat.evaluate(bootScript); - t.deepEqual([], opts.messages); + t.deepEqual(opts.messages, []); await vat.evaluate(` const encoder = new TextEncoder(); @@ -77,14 +70,15 @@ test('bootstrap to SES lockdown', async t => { send([ typeof harden, typeof Compartment, typeof HandledPromise ]); `); await vat.close(); - t.deepEqual(['["function","function","function"]'], opts.messages); + t.deepEqual(opts.messages, ['["function","function","function"]']); }); test('child compartment cannot access start powers', async t => { - const { worker: vat, opts } = await bootSESWorker(t); + const { worker: vat, opts } = await bootSESWorker(t.title); const script = await ld.asset('escapeCompartment.js'); await vat.evaluate(script); + await vat.close(); // Temporarily tolerate Endo behavior before and after // https://github.com/endojs/endo/pull/822 @@ -100,24 +94,24 @@ test('child compartment cannot access start powers', async t => { }); test('SES deep stacks work on xsnap', async t => { - const { worker: vat, opts } = await bootSESWorker(t); + const { worker: vat, opts } = await bootSESWorker(t.title); await vat.evaluate(` const encoder = new TextEncoder(); const send = msg => issueCommand(encoder.encode(JSON.stringify(msg)).buffer); const err = Error('msg'); - send(err.stack); + send('stack' in err); const msg = getStackString(err); send(msg); `); - const [stack, msg] = opts.messages.map(s => JSON.parse(s)); - t.is(stack, 'Error: msg'); // No frames + const [stackInErr, msg] = opts.messages.map(s => JSON.parse(s)); + t.assert(!stackInErr); t.is(typeof msg, 'string'); t.assert(msg.length >= 1); }); test('TextDecoder under xsnap handles TypedArray and subarrays', async t => { - const { worker: vat, opts } = await bootSESWorker(t); + const { worker: vat, opts } = await bootSESWorker(t.title); await vat.evaluate(` const decoder = new TextDecoder(); const encoder = new TextEncoder(); @@ -137,8 +131,8 @@ test('TextDecoder under xsnap handles TypedArray and subarrays', async t => { test('console - symbols', async t => { // our console-shim.js handles Symbol specially - const { worker: vat, opts } = await bootSESWorker(t); - t.deepEqual([], opts.messages); + const { worker: vat, opts } = await bootSESWorker(t.title); + t.deepEqual(opts.messages, []); await vat.evaluate(` const encoder = new TextEncoder(); globalThis.send = msg => issueCommand(encoder.encode(JSON.stringify(msg)).buffer); @@ -147,7 +141,8 @@ test('console - symbols', async t => { console.log('console:', Symbol.for('registered')); send('ok'); `); - t.deepEqual(['"ok"'], opts.messages); + await vat.close(); + t.deepEqual(opts.messages, ['"ok"']); }); test('console - objects should include detail', async t => { @@ -173,13 +168,12 @@ test('console - objects should include detail', async t => { richStructure, new ArrayBuffer(10), new Promise(_r => null), - Error('oops!'), + new Error('oops!'), ]; - - const { Fail } = assert; + const { details: X } = assert; try { - Fail`assertion text ${richStructure}`; + assert.fail(X`assertion text ${richStructure}`); } catch (e) { console.error(e); } @@ -188,7 +182,7 @@ test('console - objects should include detail', async t => { } // start a worker with the SES shim plus a global that captures args to print() - const { worker, opts } = await bootSESWorker(t, true); + const { worker, opts } = await bootSESWorker(t.title, true); await worker.evaluate(`(${runInWorker})()`); diff --git a/packages/xsnap/test/test-gc.js b/packages/xsnap/test/test-gc.js index 788bb1babbf..e54b67ae711 100644 --- a/packages/xsnap/test/test-gc.js +++ b/packages/xsnap/test/test-gc.js @@ -56,7 +56,7 @@ provokeGC(globalThis.gc).then(data => issueCommand(new TextEncoder().encode(JSON `; await vat.evaluate(code); await vat.close(); - t.truthy(opts.messages.length === 1, `xsnap didn't send response`); + t.true(opts.messages.length === 1, `xsnap didn't send response`); const { wrState, finalizerState } = JSON.parse(opts.messages[0]); // console.log([wrState, finalizerState]); t.is(wrState, 'weakref is dead'); diff --git a/packages/xsnap/test/test-replay.js b/packages/xsnap/test/test-replay.js index a0eaf88d857..f2efbe28156 100644 --- a/packages/xsnap/test/test-replay.js +++ b/packages/xsnap/test/test-replay.js @@ -42,7 +42,7 @@ test('record: evaluate and issueCommand', async t => { `issueCommand(new TextEncoder().encode("Hello, World!").buffer);`, ); await vat.close(); - t.deepEqual(['Hello, World!'], opts.messages); + t.deepEqual(opts.messages, ['Hello, World!']); t.deepEqual( transcript1, diff --git a/packages/xsnap/test/test-xs-limits.js b/packages/xsnap/test/test-xs-limits.js index f7280201bd0..0f18ec14023 100644 --- a/packages/xsnap/test/test-xs-limits.js +++ b/packages/xsnap/test/test-xs-limits.js @@ -35,7 +35,7 @@ test('heap exhaustion: orderly fail-stop', async t => { } }); -test.skip('property name space exhaustion: orderly fail-stop', async t => { +test.failing('property name space exhaustion: orderly fail-stop', async t => { const grow = qty => ` const objmap = {}; try { diff --git a/packages/xsnap/test/test-xs-perf.js b/packages/xsnap/test/test-xs-perf.js index 817e0e6b7c1..9d5dfc115a1 100644 --- a/packages/xsnap/test/test-xs-perf.js +++ b/packages/xsnap/test/test-xs-perf.js @@ -69,7 +69,7 @@ test('meter details', async t => { // test disabled until rewritten to tolerate fast CI hosts getting // multiple events within the same microsecond, #5951 // (globalThis.performance ? test : test.skip)('meter timestamps', async t => { - +// eslint-disable-next-line ava/no-skip-test test.skip('meter timestamps', async t => { const kernelTimes = []; function addTimestamp(name) { @@ -205,7 +205,7 @@ test('high resolution timer', async t => { `); const [milliseconds] = opts.messages.map(s => JSON.parse(s)); t.log({ milliseconds, date: new Date(milliseconds) }); - t.is('number', typeof milliseconds); + t.is(typeof milliseconds, 'number'); }); test('metering can be switched off / on at run-time', async t => { @@ -255,7 +255,7 @@ test('metering switch - start compartment only', async t => { } `); await vat.close(); - t.deepEqual(['no meteringSwitch in Compartment'], opts.messages); + t.deepEqual(opts.messages, ['no meteringSwitch in Compartment']); }); /** @param {number} logn */ @@ -299,6 +299,7 @@ function dataStructurePerformance(logn) { // Rather than have a very low-probability failing test, we skip this, but // retain the benchmark for future verification in the unlikely event that the // performance character of XS collections regresses. +// eslint-disable-next-line ava/no-skip-test test.skip('Array, Map, Set growth is O(log(n))', async t => { const opts = options(io); const vat = await xsnap({ ...opts, meteringLimit: 0 }); diff --git a/packages/xsnap/test/test-xsnap.js b/packages/xsnap/test/test-xsnap.js index 8b827bbca9b..6c4a834d48c 100644 --- a/packages/xsnap/test/test-xsnap.js +++ b/packages/xsnap/test/test-xsnap.js @@ -1,15 +1,15 @@ -/* global setTimeout, FinalizationRegistry, setImmediate, process */ -import '@endo/init/debug.js'; +/* global setTimeout, WeakRef, setImmediate, process */ + +import '@endo/init'; // eslint-disable-next-line import/no-extraneous-dependencies import test from 'ava'; import * as proc from 'child_process'; import * as os from 'os'; -import fs from 'fs'; -import path from 'path'; +import fs, { unlinkSync } from 'fs'; // eslint-disable-next-line import/no-extraneous-dependencies -import { tmpName } from 'tmp'; +import tmp from 'tmp'; import { xsnap } from '../src/xsnap.js'; import { recordXSnap } from '../src/replay.js'; @@ -17,46 +17,46 @@ import { ExitCode, ErrorCode } from '../api.js'; import { options, decode, encode, loader } from './message-tools.js'; -const io = { spawn: proc.spawn, os: os.type(), fs, tmpName }; // WARNING: ambient +const io = { spawn: proc.spawn, os: os.type() }; // WARNING: ambient const ld = loader(import.meta.url); test('evaluate and issueCommand', async t => { const opts = options(io); - const vat = await xsnap(opts); + const vat = xsnap(opts); await vat.evaluate( `issueCommand(new TextEncoder().encode("Hello, World!").buffer);`, ); await vat.close(); - t.deepEqual(['Hello, World!'], opts.messages); + t.deepEqual(opts.messages, ['Hello, World!']); }); test('evaluate until idle', async t => { const opts = options(io); - const vat = await xsnap(opts); + const vat = xsnap(opts); await vat.evaluate(` (async () => { issueCommand(new TextEncoder().encode("Hello, World!").buffer); })(); `); await vat.close(); - t.deepEqual(['Hello, World!'], opts.messages); + t.deepEqual(opts.messages, ['Hello, World!']); }); test('evaluate infinite loop', async t => { const opts = options(io); - const vat = await xsnap(opts); + const vat = xsnap(opts); t.teardown(vat.terminate); await t.throwsAsync(vat.evaluate(`for (;;) {}`), { code: ExitCode.E_TOO_MUCH_COMPUTATION, instanceOf: ErrorCode, }); - t.deepEqual([], opts.messages); + t.deepEqual(opts.messages, []); }); -// TODO: Re-enable when this doesn't take 3.6 seconds. +// TODO: Reenable when this doesn't take 3.6 seconds. test('evaluate promise loop', async t => { const opts = options(io); - const vat = await xsnap(opts); + const vat = xsnap(opts); t.teardown(vat.terminate); await t.throwsAsync( vat.evaluate(` @@ -70,12 +70,12 @@ test('evaluate promise loop', async t => { instanceOf: ErrorCode, }, ); - t.deepEqual([], opts.messages); + t.deepEqual(opts.messages, []); }); test('evaluate and report', async t => { const opts = options(io); - const vat = await xsnap(opts); + const vat = xsnap(opts); const result = await vat.evaluate(`(() => { const report = {}; Promise.resolve('hi').then(v => { @@ -85,12 +85,12 @@ test('evaluate and report', async t => { })()`); await vat.close(); const { reply } = result; - t.deepEqual('hi', decode(reply)); + t.is(decode(reply), 'hi'); }); test('evaluate error', async t => { const opts = options(io); - const vat = await xsnap(opts); + const vat = xsnap(opts); await vat .evaluate(`***`) .then(_ => { @@ -108,7 +108,7 @@ test('evaluate does not throw on unhandled rejections', async t => { // It's important that we can observe them using xsbug. // We can confirm this by running xsbug while running this test. for await (const debug of [false, true]) { - const vat = await xsnap({ ...opts, debug }); + const vat = xsnap({ ...opts, debug }); t.teardown(() => vat.terminate()); await t.notThrowsAsync(vat.evaluate(`Promise.reject(1)`)); } @@ -116,7 +116,7 @@ test('evaluate does not throw on unhandled rejections', async t => { test('idle includes setImmediate too', async t => { const opts = options(io); - const vat = await xsnap(opts); + const vat = xsnap(opts); await vat.evaluate(` const send = it => issueCommand(new TextEncoder().encode(it).buffer); setImmediate(() => send("end of crank")); @@ -124,56 +124,48 @@ test('idle includes setImmediate too', async t => { send("turn 1"); `); await vat.close(); - t.deepEqual(['turn 1', 'turn 2', 'end of crank'], opts.messages); + t.deepEqual(opts.messages, ['turn 1', 'turn 2', 'end of crank']); }); test('print - start compartment only', async t => { const opts = options(io); - const vat = await xsnap(opts); + const vat = xsnap(opts); await vat.evaluate(` const send = it => issueCommand(new TextEncoder().encode(it).buffer); print('print:', 123); try { - (new Compartment()).evaluate('print("456")'); - } catch (err) { - send('err:' + err); + (new Compartment()).evalate('print("456")'); + } catch (_err) { + send('no print in Compartment'); } `); await vat.close(); - t.is(opts.messages.length, 1); - t.regex( - opts.messages[0], - /^err:ReferenceError: [^:]+: get print: undefined variable$/, - ); + t.deepEqual(opts.messages, ['no print in Compartment']); }); test('gc - start compartment only', async t => { const opts = options(io); - const vat = await xsnap(opts); + const vat = xsnap(opts); await vat.evaluate(` gc(); const send = it => issueCommand(new TextEncoder().encode(it).buffer); gc(); try { - (new Compartment()).evaluate('gc()'); - } catch (err) { - send('err:' + err); + (new Compartment()).evalate('gc()'); + } catch (_err) { + send('no gc in Compartment'); } `); await vat.close(); - t.is(opts.messages.length, 1); - t.regex( - opts.messages[0], - /^err:ReferenceError: [^:]+: get gc: undefined variable$/, - ); + t.deepEqual(opts.messages, ['no gc in Compartment']); }); test('run script until idle', async t => { const opts = options(io); - const vat = await xsnap(opts); + const vat = xsnap(opts); await vat.execute(ld.resolve('fixture-xsnap-script.js')); await vat.close(); - t.deepEqual(['Hello, World!'], opts.messages); + t.deepEqual(opts.messages, ['Hello, World!']); }); test('issueCommand is synchronous inside, async outside', async t => { @@ -185,14 +177,14 @@ test('issueCommand is synchronous inside, async outside', async t => { await Promise.resolve(null); return encode(`${number + 1}`); } - const vat = await xsnap({ ...options(io), handleCommand }); + const vat = xsnap({ ...options(io), handleCommand }); await vat.evaluate(` const response = issueCommand(new TextEncoder().encode('0').buffer); const number = +new TextDecoder().decode(response); issueCommand(new TextEncoder().encode(String(number + 1)).buffer); `); await vat.close(); - t.deepEqual([0, 2], messages); + t.deepEqual(messages, [0, 2]); }); test('deliver a message', async t => { @@ -201,7 +193,7 @@ test('deliver a message', async t => { messages.push(+decode(message)); return new Uint8Array(); } - const vat = await xsnap({ ...options(io), handleCommand }); + const vat = xsnap({ ...options(io), handleCommand }); await vat.evaluate(` function handleCommand(message) { const number = +new TextDecoder().decode(message); @@ -212,7 +204,7 @@ test('deliver a message', async t => { await vat.issueStringCommand('1'); await vat.issueStringCommand('2'); await vat.close(); - t.deepEqual([1, 2, 3], messages); + t.deepEqual(messages, [1, 2, 3]); }); test('receive a response', async t => { @@ -221,16 +213,16 @@ test('receive a response', async t => { messages.push(+decode(message)); return new Uint8Array(); } - const vat = await xsnap({ ...options(io), handleCommand }); + const vat = xsnap({ ...options(io), handleCommand }); await vat.evaluate(` function handleCommand(message) { const number = +new TextDecoder().decode(message); return new TextEncoder().encode(String(number + 1)).buffer; }; `); - t.is('1', (await vat.issueStringCommand('0')).reply); - t.is('2', (await vat.issueStringCommand('1')).reply); - t.is('3', (await vat.issueStringCommand('2')).reply); + t.is((await vat.issueStringCommand('0')).reply, '1'); + t.is((await vat.issueStringCommand('1')).reply, '2'); + t.is((await vat.issueStringCommand('2')).reply, '3'); await vat.close(); }); @@ -246,7 +238,7 @@ test('serialize concurrent messages', async t => { messages.push(+decode(message)); return new Uint8Array(); } - const vat = await xsnap({ ...options(io), handleCommand }); + const vat = xsnap({ ...options(io), handleCommand }); await vat.evaluate(` globalThis.handleCommand = message => { const number = +new TextDecoder().decode(message); @@ -258,79 +250,33 @@ test('serialize concurrent messages', async t => { t.deepEqual([...count(101, 1)], messages); }); -const writeAndReadSnapshot = async (t, snapshotUseFs) => { +test('write and read snapshot', async t => { + const work = tmp.fileSync({ postfix: '.xss' }); + t.teardown(() => work.removeCallback()); + const messages = []; async function handleCommand(message) { messages.push(decode(message)); return new Uint8Array(); } - const vat0 = await xsnap({ ...options(io), handleCommand, snapshotUseFs }); + const snapshot = work.name; + t.log({ snapshot }); + + const vat0 = xsnap({ ...options(io), handleCommand }); await vat0.evaluate(` globalThis.hello = "Hello, World!"; `); + await vat0.snapshot(snapshot); + await vat0.close(); - const vat1 = await xsnap({ - ...options(io), - handleCommand, - snapshotStream: vat0.makeSnapshotStream(), - snapshotUseFs: true, - }); + const vat1 = xsnap({ ...options(io), handleCommand, snapshot }); await vat1.evaluate(` issueCommand(new TextEncoder().encode(hello).buffer); `); await vat1.close(); - await vat0.evaluate(` - globalThis.hello += " Bienvenue!"; - `); - - const snapshotStream2 = vat0.makeSnapshotStream(); - const vat2 = await xsnap({ - ...options(io), - handleCommand, - snapshotStream: snapshotStream2, - }); - await vat2.evaluate(` - issueCommand(new TextEncoder().encode(hello).buffer); - `); - await vat2.close(); - - await vat0.close(); - t.deepEqual(['Hello, World!', 'Hello, World! Bienvenue!'], messages); -}; -test('write and read snapshot (use FS)', writeAndReadSnapshot, true); -test('write and read snapshot (use stream)', writeAndReadSnapshot, false); - -test('execute immediately after makeSnapshotStream', async t => { - const messages = []; - async function handleCommand(message) { - messages.push(decode(message)); - return new Uint8Array(); - } - - const vat0 = await xsnap({ ...options(io), handleCommand }); - void vat0.evaluate(` - globalThis.when = 'before'; - `); - const snapshotStream = vat0.makeSnapshotStream(); - - void vat0.evaluate(` - globalThis.when = 'after'; - `); - - const vat1 = await xsnap({ - ...options(io), - handleCommand, - snapshotStream, - }); - await vat0.close(); - void vat1.evaluate(` - issueCommand(new TextEncoder().encode(when).buffer); - `); - await vat1.close(); - - t.deepEqual(['before'], messages); + t.deepEqual(messages, ['Hello, World!']); }); function delay(ms) { @@ -338,7 +284,7 @@ function delay(ms) { } test('fail to send command to already-closed xsnap worker', async t => { - const vat = await xsnap({ ...options(io) }); + const vat = xsnap({ ...options(io) }); await vat.close(); await vat.evaluate(``).catch(err => { t.is(err.message, 'xsnap test worker exited'); @@ -346,7 +292,7 @@ test('fail to send command to already-closed xsnap worker', async t => { }); test('fail to send command to already-terminated xsnap worker', async t => { - const vat = await xsnap({ ...options(io) }); + const vat = xsnap({ ...options(io) }); await vat.terminate(); await vat.evaluate(``).catch(err => { t.is(err.message, 'xsnap test worker exited due to signal SIGTERM'); @@ -354,7 +300,7 @@ test('fail to send command to already-terminated xsnap worker', async t => { }); test('fail to send command to terminated xsnap worker', async t => { - const vat = await xsnap({ ...options(io), meteringLimit: 0 }); + const vat = xsnap({ ...options(io), meteringLimit: 0 }); const hang = t.throwsAsync(vat.evaluate(`for (;;) {}`), { instanceOf: Error, message: /^(write EPIPE|xsnap test worker exited due to signal SIGTERM)$/, @@ -365,7 +311,7 @@ test('fail to send command to terminated xsnap worker', async t => { }); test('abnormal termination', async t => { - const vat = await xsnap({ ...options(io), meteringLimit: 0 }); + const vat = xsnap({ ...options(io), meteringLimit: 0 }); const hang = t.throwsAsync(vat.evaluate(`for (;;) {}`), { instanceOf: Error, message: 'xsnap test worker exited due to signal SIGTERM', @@ -378,7 +324,7 @@ test('abnormal termination', async t => { }); test('normal close of pathological script', async t => { - const vat = await xsnap({ ...options(io), meteringLimit: 0 }); + const vat = xsnap({ ...options(io), meteringLimit: 0 }); const hang = vat.evaluate(`for (;;) {}`).then( () => t.fail('command should not complete'), err => { @@ -395,18 +341,15 @@ test('normal close of pathological script', async t => { }); async function runToGC() { - let collected = false; - const fr = new FinalizationRegistry(() => { - collected = true; - }); - fr.register({}, undefined); - const trashCan = []; + const trashCan = [{}]; + const wr = new WeakRef(trashCan[0]); + trashCan[0] = undefined; let qty; - for (qty = 0; !collected; qty += 1) { + for (qty = 0; wr.deref(); qty += 1) { // eslint-disable-next-line no-await-in-loop await new Promise(setImmediate); - trashCan.push(Array(10_000).map(() => ({}))); + trashCan[1] = Array(10_000).map(() => ({})); } return qty; } @@ -418,8 +361,7 @@ function pickXSnap(env = process.env) { console.log('SwingSet xs-worker tracing:', { XSNAP_TEST_RECORD }); let serial = 0; doXSnap = opts => { - const workerTrace = - path.resolve(XSNAP_TEST_RECORD, String(serial)) + path.sep; + const workerTrace = `${XSNAP_TEST_RECORD}/${serial}/`; serial += 1; fs.mkdirSync(workerTrace, { recursive: true }); return recordXSnap(opts, workerTrace, { @@ -434,7 +376,7 @@ test('GC after snapshot vs restore', async t => { const xsnapr = pickXSnap(); const opts = { ...options(io), name: 'original', meteringLimit: 0 }; - const worker = await xsnapr(opts); + const worker = xsnapr(opts); t.teardown(worker.terminate); await worker.evaluate(` @@ -454,12 +396,13 @@ test('GC after snapshot vs restore', async t => { const beforeClone = await nextGC(worker, opts); - const snapshotStream = worker.makeSnapshotStream(); + const snapshot = './bloated.xss'; + await worker.snapshot(snapshot); + t.teardown(() => unlinkSync(snapshot)); - const optClone = { ...options(io), name: 'clone', snapshotStream }; - const clone = await xsnapr(optClone); - await clone.isReady(); - t.log('cloned'); + const optClone = { ...options(io), name: 'clone', snapshot }; + const clone = xsnapr(optClone); + t.log('cloned', { snapshot }); t.teardown(clone.terminate); let workerGC = beforeClone; @@ -476,10 +419,3 @@ test('GC after snapshot vs restore', async t => { t.log({ beforeClone, workerGC, cloneGC, iters }); t.is(workerGC, cloneGC); }); - -test('bad option.name', async t => { - const opts = Object.freeze({ ...options(io), name: '--sneaky' }); - await t.throwsAsync(() => xsnap(opts), { - message: /cannot start with hyphen/, - }); -}); diff --git a/packages/zoe/test/swingsetTests/zoe/test-zoe.js b/packages/zoe/test/swingsetTests/zoe/test-zoe.js index 278c20d2eba..c06089364bb 100644 --- a/packages/zoe/test/swingsetTests/zoe/test-zoe.js +++ b/packages/zoe/test/swingsetTests/zoe/test-zoe.js @@ -322,7 +322,7 @@ const expectedBadTimerLog = [ ]; // TODO: Unskip. See https://github.com/Agoric/agoric-sdk/issues/1625 -test.skip('zoe - bad timer', async t => { +test.failing('zoe - bad timer', async t => { const startingValues = [ [3, 0, 0], [0, 0, 0],