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 May 4, 2023
1 parent 33da36e commit 6c2e3a4
Show file tree
Hide file tree
Showing 29 changed files with 164 additions and 249 deletions.
3 changes: 1 addition & 2 deletions packages/SwingSet/test/message-patterns.js
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/SwingSet/test/vat-admin/test-replay.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 1 addition & 7 deletions packages/cosmic-swingset/test/test-provision-smartwallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions packages/eslint-config/eslint-config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down
Original file line number Diff line number Diff line change
@@ -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';
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 @@ -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"./,
});
});
8 changes: 4 additions & 4 deletions packages/inter-protocol/test/test-gov-collateral.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
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
5 changes: 3 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,15 @@ 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`),
(...args) => t.is(args, undefined, `${label} must be rejected`),
failure =>
t.deepEqual(failure, expected, `${label} must indicate disconnection`),
);
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/solo/src/start.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-check
/* eslint-disable no-lone-blocks */
/* global process setTimeout */
import fs from 'fs';
import url from 'url';
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 @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
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);
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 @@ -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']);
Expand All @@ -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']);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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, []);
});

Expand Down Expand Up @@ -967,27 +966,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 @@ -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;
Expand Down
17 changes: 7 additions & 10 deletions packages/vats/test/test-dump.js
Original file line number Diff line number Diff line change
@@ -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' };
Expand All @@ -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],
Expand All @@ -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"
}
},
{}
}
]`,
);
});
Loading

0 comments on commit 6c2e3a4

Please sign in to comment.