Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jun 1, 2022
1 parent c062f1a commit 9cc9451
Show file tree
Hide file tree
Showing 47 changed files with 55 additions and 48 deletions.
2 changes: 1 addition & 1 deletion packages/SwingSet/test/test-xsnap-errors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global setTimeout */
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/order
import { test } from '../tools/prepare-test-env-ava.js';
import { spawn } from 'child_process';
Expand Down
1 change: 1 addition & 0 deletions packages/SwingSet/test/vat-warehouse/test-warehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { makeLRU } from '../../src/kernel/vat-warehouse.js';

async function makeController(managerType, runtimeOptions) {
const config = await loadBasedir(new URL('./', import.meta.url).pathname);
assert(config.vats);
config.vats.target.creationOptions = { managerType, enableDisavow: true };
config.vats.target2 = config.vats.target;
config.vats.target3 = config.vats.target;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// @ts-check
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';

import { assertOfferResult } from '../../src/assertOfferResult.js';

test('assertOfferResult', async t => {
/** @type {UserSeat} */
const mockSeat = {
// @ts-expect-error mock
getOfferResult: () => 'result',
};
await t.notThrowsAsync(() => assertOfferResult(mockSeat, 'result'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { E } from '@endo/far';
import '@agoric/vats/src/core/types.js';
import { runModuleBehaviors } from '@agoric/vats/src/core/utils.js';
import { makeCoreProposalBehavior } from '../../src/coreProposalBehavior.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { makeIssuerKit, AssetKind, AmountMath } from '@agoric/ertp';
Expand All @@ -25,7 +25,6 @@ test('findInvitationAmount', async t => {
walletAdmin,
zoe,
zoeInvitationPurse,
brand,
);

const notFoundResult = await findInvitationAmount({
Expand Down
1 change: 0 additions & 1 deletion packages/run-protocol/test/test-gov-collateral.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ const makeScenario = async (t, { env = process.env } = {}) => {
},
getBankForAddress: () => assert.fail('not impl'),
});
// @ts-ignore mock doesn't have all the methods
space.produce.bankManager.resolve(bankManager);

space.installation.produce.mintHolder.resolve(
Expand Down
2 changes: 1 addition & 1 deletion packages/store/test/test-encodePassable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
/* eslint-disable no-bitwise */

import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/store/test/test-rankOrder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
import { Far, makeTagged } from '@endo/marshal';
import fc from 'fast-check';
Expand Down
1 change: 1 addition & 0 deletions packages/xsnap/test/message-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function loader(url, readFile = undefined) {
return freeze({
resolve,
/** @param { string } ref */
// @ts-expect-error possibly undefined
asset: async ref => readFile(resolve(ref), 'utf-8'),
});
}
Expand Down
4 changes: 3 additions & 1 deletion packages/xsnap/test/test-xs-perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ test('meter details are still available with no limit', async t => {
t.log(meters);
t.is(typeof meters.compute, 'number');
t.is(typeof meters.allocate, 'number');
// @ts-expect-error until ava assertion types
t.true(meters.compute > 0);
// @ts-expect-error until ava assertion types
t.true(meters.allocate > 0);
});

Expand Down Expand Up @@ -185,7 +187,6 @@ test('metering switch - start compartment only', async t => {
function dataStructurePerformance(logn) {
// eslint-disable-next-line no-bitwise
const n = 1 << logn;
// @ts-expect-error
const send = it => {
// eslint-disable-next-line no-undef
return issueCommand(new TextEncoder().encode(JSON.stringify(it)).buffer);
Expand Down Expand Up @@ -234,6 +235,7 @@ test.skip('Array, Map, Set growth is O(log(n))', async t => {
const {
meterUsage: { compute },
} = await vat.evaluate(`dataStructurePerformance(${size})`);
// @ts-expect-error pop() may return undefined
const r = JSON.parse(opts.messages.pop());
t.log({ compute, r });
return { compute, r };
Expand Down
1 change: 1 addition & 0 deletions packages/xsnap/test/test-xsnap.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ test('normal close of pathological script', async t => {
async function runToGC() {
const trashCan = [{}];
const wr = new WeakRef(trashCan[0]);
// @ts-expect-error
trashCan[0] = undefined;

let qty;
Expand Down
1 change: 1 addition & 0 deletions packages/zoe/test/privateArgsUsageContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const start = (_zcf, privateArgs) => {
const creatorFacet = Far('creatorFacet', {
usePrivateArgs: () => E(privateArgs.myArg).doTest(),
});
// @ts-expect-error missing publicFacet for ContractStartFn
return harden({ creatorFacet });
};
harden(start);
Expand Down
5 changes: 4 additions & 1 deletion packages/zoe/test/runMintContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';
import { AmountMath } from '@agoric/ertp';

/** @param {ZCF} zcf */
/**
* @param {ZCF} zcf
* @param {{feeMintAccess: FeeMintAccess}} privateArgs
*/
const start = async (zcf, privateArgs) => {
const runMint = await zcf.registerFeeMint('RUN', privateArgs.feeMintAccess);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const start = zcf => {

const creatorInvitation = makeSafeInvitation();

// @ts-expect-error missing creatorFacet of ContractStartFn
return harden({ creatorInvitation, publicFacet });
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck

// eslint-disable-next-line import/no-extraneous-dependencies
import '@endo/init';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck

import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/swingsetTests/zoe/test-zoe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/no-extraneous-dependencies
import '@endo/init';
// eslint-disable-next-line import/no-extraneous-dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/no-extraneous-dependencies
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/no-extraneous-dependencies
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ function makeMockTradingZcfBuilder() {
return Far('mockTradingZcfBuilder', {
addOffer: (keyword, offer) => offers.init(keyword, offer),
addAllocation: (keyword, alloc) => allocs.init(keyword, alloc),
/** @returns {ZCF} */
build: () =>
Far('mockZCF', {
// @ts-expect-error mock
getZoeService: () => {},
reallocate: (...seatStagings) => {
reallocatedStagings.push(...seatStagings);
Expand All @@ -46,8 +48,6 @@ test('ZoeHelpers satisfies blank proposal', t => {
getProposal: () => harden({}),
});
const mockZCFBuilder = makeMockTradingZcfBuilder();
/** @type {ZCF} */
// @ts-expect-error cast
const mockZCF = mockZCFBuilder.build();
t.truthy(
satisfies(mockZCF, fakeZcfSeat, { Gift: moola(3n) }),
Expand All @@ -63,8 +63,7 @@ test('ZoeHelpers satisfies simple proposal', t => {
getCurrentAllocation: () => harden({ Asset: moola(10n) }),
getProposal: () => harden({ want: { Desire: moola(30n) } }),
});
/** @type {ZCF} */
// @ts-expect-error cast
const mockZCFBuilder = makeMockTradingZcfBuilder();
const mockZCF = mockZCFBuilder.build();
t.falsy(
satisfies(mockZCF, fakeZcfSeat, { Desire: moola(3n) }),
Expand Down Expand Up @@ -101,8 +100,6 @@ test('ZoeHelpers satisfies() with give', t => {
harden({ give: { Charge: moola(30n) }, want: { Desire: bucks(5n) } }),
});
const mockZCFBuilder = makeMockTradingZcfBuilder();
/** @type {ZCF} */
// @ts-expect-error cast
const mockZCF = mockZCFBuilder.build();
t.falsy(
satisfies(mockZCF, fakeZcfSeat, { Charge: moola(0n), Desire: bucks(1n) }),
Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/escrowToVote.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-check

// @ts-nocheck
import { assert, details as X, q } from '@agoric/assert';
import { Far } from '@endo/marshal';
import { makeStore } from '@agoric/store';
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/unitTests/contracts/loan/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/no-extraneous-dependencies
import '@agoric/zoe/tools/prepare-test-env.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/no-extraneous-dependencies
import '@agoric/zoe/tools/prepare-test-env-ava.js';
// eslint-disable-next-line import/no-extraneous-dependencies
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/unitTests/contracts/loan/test-borrow.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/no-extraneous-dependencies
import '@agoric/zoe/tools/prepare-test-env-ava.js';
// eslint-disable-next-line import/no-extraneous-dependencies
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/unitTests/contracts/loan/test-close.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/no-extraneous-dependencies
import '@agoric/zoe/tools/prepare-test-env-ava.js';
// eslint-disable-next-line import/no-extraneous-dependencies
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/unitTests/contracts/loan/test-lend.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/no-extraneous-dependencies
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import '../../../../exported.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/no-extraneous-dependencies
import '@agoric/zoe/tools/prepare-test-env-ava.js';
// eslint-disable-next-line import/no-extraneous-dependencies
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/unitTests/contracts/test-atomicSwap.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ test('zoe - non-fungible atomicSwap', async t => {
// Alice makes an instance and makes her offer.
const installation = await alice.installCode();

const vorpalSword = createRpgItem('Vorpal Sword', 38);
const vorpalSword = createRpgItem('Vorpal Sword', 'vorping');
const vorpalAmount = rpgItems(vorpalSword);
const bobRpgPayment = await E(rpgMint).mintPayment(vorpalAmount);
const bob = await makeBob(installation, bobRpgPayment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ test('zoe with automaticRefund', async t => {
const exclusBobInvitation = await E(invitationIssuer).claim(bobInvitation);

const {
// @ts-expect-error poor typing of Payment
value: [bobInvitationValue],
} = await E(invitationIssuer).getAmountOf(exclusBobInvitation);
t.is(bobInvitationValue.installation, installation);
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/unitTests/contracts/test-coveredCall.js
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ test('zoe - coveredCall non-fungible', async t => {
// Setup Bob
const aGloriousShield = createRpgItem(
'Glorious Shield',
25,
'blinding',
'a Glorious Shield, burnished to a blinding brightness',
);
const aGloriousShieldAmount = rpgItems(aGloriousShield);
Expand Down
1 change: 1 addition & 0 deletions packages/zoe/test/unitTests/contracts/test-escrowToVote.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ test('zoe - escrowToVote', async t => {

// Voter3 exits before the election is closed. Voter3's vote will
// not be counted.
assert(seat.tryExit);
seat.tryExit();

return { voter, seat };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/no-extraneous-dependencies
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

Expand Down
2 changes: 2 additions & 0 deletions packages/zoe/test/unitTests/contracts/test-simpleExchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ test('simpleExchange with non-fungible assets', async t => {
// Assert that the correct payout were received.
// Alice has an empty RPG purse, and the Cheshire Cat.
// Bob has an empty CryptoCat purse, and the Spell of Binding he wanted.
// @ts-expect-error get may fail
const noCats = AmountMath.makeEmpty(brands.get('cc'), AssetKind.SET);
// @ts-expect-error get may fail
const noRpgItems = AmountMath.makeEmpty(brands.get('rpg'), AssetKind.SET);
await assertPayoutAmount(t, rpgIssuer, aliceRpgPayout, noRpgItems);
const cheshireCatAmount = cryptoCats(harden(['Cheshire Cat']));
Expand Down
1 change: 1 addition & 0 deletions packages/zoe/test/unitTests/contracts/test-useObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ test('zoe - useObj', async t => {
`use of use object works`,
);

assert(aliceSeat.tryExit);
aliceSeat.tryExit();

const aliceMoolaPayoutPayment = await E(aliceSeat).getPayout('Pixels');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { depositToSeat } from '../../../src/contractSupport/index.js';
* This is a a broken contact to test that
* errors in offerHandlers are appropriately handled
*
* @type {ContractStartFn<undefined, {makeThrowInOfferHandlerInvitation: unknown, makeThrowInDepositToSeatInvitation: unknown}>}
* @param {ZCF} zcf
*/
const start = zcf => {
const throwInOfferHandler = _seat => {
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/unitTests/contracts/useObjExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
/**
* Give a use object when a payment is escrowed
*
* @type {ContractStartFn}
* @param {ZCF} zcf
*/
const start = zcf => {
const {
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/unitTests/setupNonFungibleMints.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const setupNonFungible = () => {
/**
*
* @param {string} name
* @param {number} power
* @param {string} power
* @param {string} [desc]
*/
function createRpgItem(name, power, desc) {
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/unitTests/test-instanceStorage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck

// eslint-disable-next-line import/no-extraneous-dependencies
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
Expand Down
6 changes: 2 additions & 4 deletions packages/zoe/test/unitTests/test-scriptedOracle.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/no-extraneous-dependencies
import { test as unknownTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';
/** @type {import('ava').TestInterface<any>} */
const test = unknownTest;
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import path from 'path';

Expand Down
2 changes: 0 additions & 2 deletions packages/zoe/test/unitTests/test-zoe-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ test('harden from SES is in the zoe contract environment', t => {
});

test('(mock) kind makers from SwingSet are in the zoe contract environment', t => {
// @ts-expect-error testing existence of function only
VatData.defineKind('x', () => {}, {});
VatData.defineKindMulti('x', () => {}, { x: {}, y: {} });
const kh = VatData.makeKindHandle();
Expand All @@ -19,7 +18,6 @@ test('(mock) kind makers from SwingSet are in the zoe contract environment', t =
});

test('(mock) store makers from SwingSet are in the zoe contract environment', t => {
// @ts-expect-error testing existence of function only
VatData.makeScalarBigMapStore();
VatData.makeScalarBigWeakMapStore();
VatData.makeScalarBigSetStore();
Expand Down
1 change: 0 additions & 1 deletion packages/zoe/test/unitTests/zcf/test-reallocate-empty.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ test(`zcf.reallocate unstaged`, async t => {
const { brand } = zcfMint.getIssuerRecord();
const empty = AmountMath.makeEmpty(brand, AssetKind.NAT);
zcfSeat1.incrementBy(harden({ RUN: empty }));
// @ts-expect-error Deliberate wrong type for testing
t.throws(() => zcf.reallocate(zcfSeat1, zcfSeat2), {
message:
'Reallocate failed because a seat had no staged allocation. Please add or subtract from the seat and then reallocate.',
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/unitTests/zcf/test-zcf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/no-extraneous-dependencies
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/unitTests/zcf/test-zcfSeat-exit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
// eslint-disable-next-line import/no-extraneous-dependencies
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

Expand Down

0 comments on commit 9cc9451

Please sign in to comment.