Skip to content

Commit

Permalink
chore: comply with ava/recommended eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Aug 15, 2023
1 parent 701a131 commit 7347734
Show file tree
Hide file tree
Showing 34 changed files with 86 additions and 89 deletions.
6 changes: 3 additions & 3 deletions packages/SwingSet/test/test-bundle-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 => {
Expand Down
4 changes: 2 additions & 2 deletions packages/agoric-cli/test/test-inter-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,11 @@ test('diagnostic for agd ENOENT', async t => {
});

await t.throwsAsync(cmd.parseAsync(argv), { instanceOf: CommanderError });
t.deepEqual(
t.is(
diag.join('').trim(),
"error: option '--from <address>' argument 'gov1' is invalid. ENOENT: is agd in your $PATH?",
);
t.deepEqual(out.join('').trim(), '');
t.is(out.join('').trim(), '');
});

test.todo('agd ENOENT clue outside normalizeAddress');
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/test/test-publish-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ test('publish bundle with fake HTTP server ok', async t => {
t.deepEqual(bundle, request);
res.end('{"ok": true}');
})().catch(error => {
t.fail(error);
t.fail(`${error.message}`);
});
});
t.teardown(
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/test/upgrading/test-upgrade-vats.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,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 bundles = {
chain: {
sourceSpec: await importSpec('@agoric/vats/src/core/boot-chain.js'),
Expand Down
4 changes: 2 additions & 2 deletions packages/cosmic-swingset/test/test-export-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const makeBatchChainStorage = published => {
return { batchChainStorage, deleted };
};

test('exportStorage example', async t => {
test('exportStorage example', t => {
const exportStorageSubtrees = ['published.c.o'];
const expected = [
['published.c.o', 'top'],
Expand All @@ -82,7 +82,7 @@ test('exportStorage example', async t => {
t.deepEqual(actual, expected);
});

test('exportStorage clears crufty ToyUSD PSM', async t => {
test('exportStorage clears crufty ToyUSD PSM', t => {
const config = {
clearStorageSubtrees: ['published'],
exportStorageSubtrees: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* 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';
import { buildVatController, buildKernelBundles } from '@agoric/swingset-vat';
Expand Down
9 changes: 0 additions & 9 deletions packages/import-manager/test/unitTests/test-importsA.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,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"./,
});
});
2 changes: 1 addition & 1 deletion packages/internal/test/test-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions packages/internal/test/test-netstring.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test('encode', t => {
eq(emojiBuffer, expectedBuffer);
});

test('encode stream', async t => {
test('encode stream', t => {
const e = netstringEncoderStream();
const chunks = [];
e.on('data', data => chunks.push(data));
Expand Down Expand Up @@ -112,7 +112,7 @@ test('decode', t => {
bad('26:x', /size .* exceeds limit of 25/);
});

test('decode stream', async t => {
test('decode stream', t => {
const d = netstringDecoderStream();
function write(s) {
d.write(Buffer.from(s));
Expand Down
2 changes: 1 addition & 1 deletion packages/internal/test/test-priority-senders.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ test('normalization', async t => {
await manager.add('this,has,commas,', 'addr');

await writesSettled();
t.deepEqual(
t.is(
storage.data.get(`${HIGH_PRIORITY_SENDERS}.addr`),
'something_with_spaces,something_with_spaces_and___,this_has_commas_',
);
Expand Down
6 changes: 4 additions & 2 deletions packages/notifier/test/test-publish-kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,16 @@ 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,
name: 'vatUpgraded',
upgradeMessage: 'vat upgraded',
};
return p.then(
(...args) => t.deepEqual(args, undefined, `${label} must be rejected`),
// @ts-expect-error Argument of type 'undefined' is not assignable to parameter of type 'any[]'.
(...args) => t.is(args, undefined, `${label} must be rejected`),
failure =>
t.deepEqual(failure, expected, `${label} must indicate disconnection`),
);
Expand Down Expand Up @@ -458,7 +460,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,
Expand Down
2 changes: 1 addition & 1 deletion packages/solo/test/test-home.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,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));

Expand Down
4 changes: 2 additions & 2 deletions packages/swingset-liveslots/test/test-durabilityChecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion packages/swingset-liveslots/test/test-facetiousness.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ test('checkAndUpdateFacetiousness', t => {
t.deepEqual(cauf({}, barfoo), barfoo);

// a single Kind can only be redefined as another single
t.deepEqual(cauf(desc(), undefined), undefined);
t.is(cauf(desc(), undefined), undefined);
t.throws(() => cauf(desc(), foo), {
message: 'defineDurableKindMulti called for unfaceted KindHandle "tag"',
});
Expand Down
8 changes: 4 additions & 4 deletions packages/swingset-liveslots/test/test-handled-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ test('past-incarnation watched promises', async t => {
t.deepEqual(getDispatchLogs(), [
fulfillmentMessage(`p-${nextPImport()}`, 'created local promise: rejected'),
]);
t.deepEqual(
t.is(
lastPImport - firstPImport + 1,
4,
'imported 4 promises (1 per dispatch)',
);
t.deepEqual(lastPExport - firstPExport + 1, 1, 'exported 1 promise: first');
t.is(lastPExport - firstPExport + 1, 1, 'exported 1 promise: first');

await dispatchMessage('watchLocalPromise', 'orphaned');
t.deepEqual(getDispatchLogs(), [
Expand All @@ -259,12 +259,12 @@ test('past-incarnation watched promises', async t => {
fulfillmentMessage(`p-${nextPImport()}`, 'watched local promise: rejected'),
rejectionMessage(`p+${lastPExport}`, S),
]);
t.deepEqual(
t.is(
lastPImport - firstPImport + 1,
7,
'imported 7 promises (1 per dispatch)',
);
t.deepEqual(
t.is(
lastPExport - firstPExport + 1,
4,
'exported 4 promises: first, orphaned, fulfilled, rejected',
Expand Down
2 changes: 1 addition & 1 deletion packages/swingset-liveslots/test/test-initial-vrefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ test('vrefs', async t => {
const expectedStore1Vref = `o+v${initialKindIDs.scalarMapStore}/5`;
const store1Vref = (await run('getStore1')).slots[0];
t.is(store1Vref, expectedStore1Vref);
t.deepEqual(kunser(JSON.parse(fakestore.get(`vc.5.s${'key'}`))), 'value');
t.is(kunser(JSON.parse(fakestore.get(`vc.5.s${'key'}`))), 'value');
});
23 changes: 11 additions & 12 deletions packages/swingset-liveslots/test/test-liveslots.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,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']);
Expand All @@ -64,7 +64,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']);
Expand Down Expand Up @@ -100,7 +100,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,
Expand Down Expand Up @@ -657,8 +657,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',
Expand Down Expand Up @@ -907,7 +906,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, []);
});

Expand Down Expand Up @@ -968,27 +967,27 @@ 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();
t.truthy(l instanceof Error);
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',
isFailure: true,
});
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, []);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/swingset-liveslots/test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function buildDispatch(onDispatchCallback) {

/**
* @param {unknown} target
* @param {string} method
* @param {string | symbol} method
* @param {any[]} args
* @param {unknown} result
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function weakKeyCheck(t, log, vref) {
t.true(result === undefined || !result.startsWith(prefix), `ew:${result}`);
}

test('only enumerate virtual objects', async t => {
test('only enumerate virtual objects', t => {
const { log, vrm } = makeVRM();

// retiring a plain Remotable does a is-it-a-weak-key chck
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function attack2(mut1, immut2) {
Reflect.apply(mutableProto.set, immut2, [6]);
}

test('forbid cross-facet prototype attack', async t => {
test('forbid cross-facet prototype attack', t => {
const vom = makeFakeVirtualObjectManager();
const init = () => ({ value: 0 });
const behavior = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '@endo/init/debug.js';

import { makeFakeVirtualObjectManager } from '../../tools/fakeVirtualSupport.js';

test('non-object initial data message', async t => {
test('non-object initial data message', t => {
const vom = makeFakeVirtualObjectManager();
const goodInit = () => ({ value: 0 });
// 'badInit' is () => { value: 0 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '@endo/init/debug.js';

import { makeFakeVirtualObjectManager } from '../../tools/fakeVirtualSupport.js';

test('facets', async t => {
test('facets', t => {
const vom = makeFakeVirtualObjectManager();
const init = () => ({ value: 0 });
const behavior = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const init = () => ({});
const behavior = {};
const facets = { foo: {}, bar: {} };

test('representatives with label-instances', async t => {
test('representatives with label-instances', t => {
const { fakeStuff, vom } = makeFakeVirtualStuff();
const { getSlotForVal } = fakeStuff;
const makeThing = vom.defineKind('thing', init, behavior);
Expand All @@ -33,7 +33,7 @@ test('representatives with label-instances', async t => {
t.is(`${q(thing2)}`, `"[Alleged: thing#${thing2vref}]"`);
});

test('facets with label-instances', async t => {
test('facets with label-instances', t => {
const { fakeStuff, vom } = makeFakeVirtualStuff();
const { getSlotForVal } = fakeStuff;
const makeThings = vom.defineKindMulti('thing', init, facets);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '@endo/init/debug.js';

import { makeFakeVirtualObjectManager } from '../../tools/fakeVirtualSupport.js';

test('weakMap vref handling', async t => {
test('weakMap vref handling', t => {
const log = [];
const {
VirtualObjectAwareWeakMap,
Expand Down
2 changes: 1 addition & 1 deletion packages/time/test/test-timeMath.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test('timeMath one label', t => {
});

test('timeMath no labels', t => {
t.deepEqual(TimeMath.addAbsRel(100n, 3n), 103n);
t.is(TimeMath.addAbsRel(100n, 3n), 103n);
});

// TODO: < should fail
Loading

0 comments on commit 7347734

Please sign in to comment.