Skip to content

Commit

Permalink
chore: update types for Ava 4
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Aug 4, 2022
1 parent e09b8de commit 9828b03
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 33 deletions.
1 change: 1 addition & 0 deletions packages/agoric-cli/test/test-publish-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test('fake publish bundle ok', async t => {
t.is(hostname, 'localhost');
t.is(port, 8080);
t.is(path, '/publish-bundle?accessToken=TO%20KEN');
// @ts-expect-error unknown
t.is(bundle, receivedBundle);
return { ok: true };
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { setupAmmServices } from './setup.js';
/** @typedef {Record<string, any> & {
* bundleCache: Awaited<ReturnType<typeof unsafeMakeBundleCache>>,
* }} Context */
/** @type {import('ava').TestInterface<Context>} */
// @ts-expect-error cast
/** @type {import('ava').TestFn<Context>} */
const test = unknownTest;

test.before(async t => {
Expand Down
3 changes: 1 addition & 2 deletions packages/inter-protocol/test/psm/test-psm.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import {
subscriptionKey,
} from '../supports.js';

/** @type {import('ava').TestInterface<Awaited<ReturnType<makeTestContext>>>} */
// @ts-expect-error cast
/** @type {import('ava').TestFn<Awaited<ReturnType<makeTestContext>>>} */
const test = anyTest;

const pathname = new URL(import.meta.url).pathname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ const micro = harden({
* },
* }} StakeFactoryTestContext
*/
/** @type {import('ava').TestInterface<StakeFactoryTestContext>} */
// @ts-expect-error cast
/** @type {import('ava').TestFn<StakeFactoryTestContext>} */
const test = unknownTest;

test.before(async t => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ import { unsafeMakeBundleCache } from '@agoric/swingset-vat/tools/bundleTool.js'
import zcfBundle from '@agoric/zoe/bundles/bundle-contractFacet.js';
import bundleSource from '@endo/bundle-source';
import { E } from '@endo/eventual-send';
import rawTest from 'ava';
import anyTest from 'ava';

// import '../../../src/vaultFactory/vaultFactory.js';

const dirname = new URL('.', import.meta.url).pathname;

/** @type {import('ava').TestInterface<{ data: { kernelBundles: any, config: any } }>} */
// @ts-expect-error cast
const test = rawTest;
/** @type {import('ava').TestFn<{ data: { kernelBundles: any, config: any } }>} */
const test = anyTest;

test.before(async t => {
const kernelBundles = await buildKernelBundles();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// @ts-check

// eslint-disable-next-line import/no-extraneous-dependencies
import '@endo/init/debug.js';
// eslint-disable-next-line import/no-extraneous-dependencies
import rawTest from 'ava';
import anyTest from 'ava';
import path from 'path';
import { buildVatController, buildKernelBundles } from '@agoric/swingset-vat';
import bundleSource from '@endo/bundle-source';
Expand All @@ -17,9 +15,8 @@ import liquidateMinimumBundle from '../../../bundles/bundle-liquidateMinimum.js'
import ammBundle from '../../../bundles/bundle-amm.js';
import vaultFactoryBundle from '../../../bundles/bundle-vaultFactory.js';

/** @type {import('ava').TestInterface<{ data: { kernelBundles: any, config: any } }>} */
// @ts-expect-error cast
const test = rawTest;
/** @type {import('ava').TestFn<{ data: { kernelBundles: any, config: any } }>} */
const test = anyTest;

/**
*
Expand Down
3 changes: 1 addition & 2 deletions packages/inter-protocol/test/test-gov-collateral.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ import { setupBootstrap, setUpZoeForTest, mintRunPayment } from './supports.js';
const { details: X } = assert;
const dirname = url.fileURLToPath(new URL('.', import.meta.url));

/** @type {import('ava').TestInterface<Awaited<ReturnType<typeof makeTestContext>>>} */
// @ts-expect-error cast
/** @type {import('ava').TestFn<Awaited<ReturnType<typeof makeTestContext>>>} */
const test = anyTest;

const contractRoots = {
Expand Down
3 changes: 1 addition & 2 deletions packages/inter-protocol/test/test-interchainPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { setUpZoeForTest } from './supports.js';

/** @template T @typedef {import('@endo/promise-kit').PromiseKit<T>} PromiseKit */

/** @type {import('ava').TestInterface<Awaited<ReturnType<makeTestContext>>>} */
// @ts-expect-error cast
/** @type {import('ava').TestFn<Awaited<ReturnType<makeTestContext>>>} */
const test = anyTest;

const contractRoots = {
Expand Down
3 changes: 1 addition & 2 deletions packages/inter-protocol/test/vaultFactory/test-liquidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import {

/** @typedef {import('./driver.js').DriverContext & {
* }} Context */
/** @type {import('ava').TestInterface<Context>} */
// @ts-expect-error cast
/** @type {import('ava').TestFn<Context>} */
const test = unknownTest;

const trace = makeTracer('TestLiq');
Expand Down
3 changes: 1 addition & 2 deletions packages/inter-protocol/test/vaultFactory/test-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { makeDriverContext, makeManagerDriver } from './driver.js';

/** @typedef {import('./driver.js').DriverContext & {
* }} Context */
/** @type {import('ava').TestInterface<Context>} */
// @ts-expect-error cast
/** @type {import('ava').TestFn<Context>} */
const test = unknownTest;

const trace = makeTracer('TestLiq');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ for (const [debt, collat, vaultId, expectedKey, numberOut] of [
AmountMath.make(mockBrand, BigInt(collat)),
String(vaultId),
);
// @ts-expect-error TODO use macros
t.is(key, expectedKey);
t.deepEqual(StoreUtils.fromVaultKey(key), [numberOut, vaultId]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ import {
* loanTiming: LoanTiming,
* zoe: ZoeService,
* }} Context */
/** @type {import('ava').TestInterface<Context>} */
// @ts-expect-error cast
/** @type {import('ava').TestFn<Context>} */
const test = unknownTest;

// #region Support
Expand Down
3 changes: 1 addition & 2 deletions packages/wallet/contract/test/test-singleWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { E, Far } from '@endo/far';
import path from 'path';
import { makeTestSpace, subscriptionKey } from './supports.js';

/** @type {import('ava').TestInterface<Awaited<ReturnType<makeTestContext>>>} */
// @ts-expect-error cast
/** @type {import('ava').TestFn<Awaited<ReturnType<makeTestContext>>>} */
const test = anyTest;

const makeTestContext = async t => {
Expand Down
3 changes: 1 addition & 2 deletions packages/wallet/contract/test/test-walletFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { E, Far } from '@endo/far';
import path from 'path';
import { makeTestSpace, subscriptionKey } from './supports.js';

/** @type {import('ava').TestInterface<Awaited<ReturnType<makeTestContext>>>} */
// @ts-expect-error cast
/** @type {import('ava').TestFn<Awaited<ReturnType<makeTestContext>>>} */
const test = anyTest;

const mockAddress1 = 'mockAddress1';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ const makePublicationChecker = async (t, aggregatorPublicFacet) => {
};
};

/** @type {import('ava').TestInterface<TestContext>} */
// @ts-expect-error cast
/** @type {import('ava').TestFn<TestContext>} */
const test = unknownTest;

test.before('setup aggregator and oracles', async ot => {
Expand Down
4 changes: 4 additions & 0 deletions packages/zoe/test/unitTests/test-fakePriceAuthority.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ test('priceAuthority quoteWhenGTE', async t => {
.quoteWhenGTE(moola(1n), bucks(40n))
.then(quote => {
const quoteInAmount = quote.quoteAmount.value[0];
// @ts-expect-error could be TimestampRecord
t.is(4n, manualTimer.getCurrentTimestamp());
t.is(4n, quoteInAmount.timestamp);
assertAmountsEqual(t, bucks(40n), quoteInAmount.amountOut);
Expand All @@ -154,6 +155,7 @@ test('priceAuthority quoteWhenLT', async t => {
.quoteWhenLT(moola(1n), bucks(30n))
.then(quote => {
const quoteInAmount = quote.quoteAmount.value[0];
// @ts-expect-error could be TimestampRecord
t.is(3n, manualTimer.getCurrentTimestamp());
t.is(3n, quoteInAmount.timestamp);
assertAmountsEqual(t, bucks(29n), quoteInAmount.amountOut);
Expand All @@ -179,6 +181,7 @@ test('priceAuthority quoteWhenGT', async t => {
.quoteWhenGT(moola(1n), bucks(40n))
.then(quote => {
const quoteInAmount = quote.quoteAmount.value[0];
// @ts-expect-error could be TimestampRecord
t.is(3n, manualTimer.getCurrentTimestamp());
t.is(3n, quoteInAmount.timestamp);
assertAmountsEqual(t, bucks(41n), quoteInAmount.amountOut);
Expand All @@ -205,6 +208,7 @@ test('priceAuthority quoteWhenLTE', async t => {
.then(quote => {
const quoteInAmount = quote.quoteAmount.value[0];
t.is(4n, quoteInAmount.timestamp);
// @ts-expect-error could be TimestampRecord
t.is(4n, manualTimer.getCurrentTimestamp());
assertAmountsEqual(t, bucks(25n), quoteInAmount.amountOut);
assertAmountsEqual(t, moola(1n), quoteInAmount.amountIn);
Expand Down
1 change: 0 additions & 1 deletion packages/zoe/test/unitTests/zoe/test-createZCFVat.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ test('setupCreateZCFVat', async t => {
() => undefined, // getZoeService
)(undefined),
{
// @ts-expect-error fakeVatAdminSvc is mocked
adminNode: undefined,
root: undefined,
},
Expand Down

0 comments on commit 9828b03

Please sign in to comment.