Skip to content

Commit

Permalink
Merge pull request #8208 from Agoric/ta/test-bfile
Browse files Browse the repository at this point in the history
misc test cleanup
  • Loading branch information
turadg authored Aug 16, 2023
2 parents c644795 + 825c0d5 commit 38329c2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 42 deletions.
5 changes: 3 additions & 2 deletions packages/boot/test/bootstrapTests/liquidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ export const makeLiquidationTestContext = async t => {

// has to be late enough for agoricNames data to have been published
/** @type {import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes} */
const agoricNamesRemotes = {};
const agoricNamesRemotes = makeAgoricNamesRemotesFromFakeStorage(
swingsetTestKit.storage,
);
const refreshAgoricNamesRemotes = () => {
Object.assign(
agoricNamesRemotes,
makeAgoricNamesRemotesFromFakeStorage(swingsetTestKit.storage),
);
};
refreshAgoricNamesRemotes();
agoricNamesRemotes.brand.ATOM || Fail`ATOM missing from agoricNames`;
console.timeLog('DefaultTestContext', 'agoricNamesRemotes');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ test('exit bid', async t => {
giveCollateral: 9.0,
});

wd.sendOfferMaker(Offers.auction.Bid, {
await wd.sendOfferMaker(Offers.auction.Bid, {
offerId: 'bid',
maxBuy: '1.23ATOM',
give: '0.1IST',
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/test/bootstrapTests/test-zcf-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ test('run restart-vats proposal', async t => {
await buildAndExecuteProposal(zcfPackageSpec);

t.log('upgrade zoe&zcf proposal executed');
zoeDriver.upgradeProbe(zcfProbeBundle);
await zoeDriver.upgradeProbe(zcfProbeBundle);
const nextDucats = beforeResult.leftoverPayments.Ducats;
const nextAmount = await EV(issuer).getAmountOf(nextDucats);

Expand Down
25 changes: 4 additions & 21 deletions packages/boot/test/upgrading/test-upgrade-contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,15 @@ import { test as anyTest } from '@agoric/swingset-vat/tools/prepare-test-env-ava
import { buildVatController } from '@agoric/swingset-vat';

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

/**
* WARNING: uses ambient authority of import.meta.url
*
* We aim to use ambient authority only in test.before(); splitting out
* makeTestContext() lets us type t.context.
*/
const makeTestContext = async () => {
const bfile = name => new URL(name, import.meta.url).pathname;
const importSpec = spec =>
importMetaResolve(spec, import.meta.url).then(u => new URL(u).pathname);
return { bfile, importSpec };
};

test.before(async t => {
t.context = await makeTestContext();
});
const bfile = name => new URL(name, import.meta.url).pathname;
const importSpec = spec =>
importMetaResolve(spec, import.meta.url).then(u => new URL(u).pathname);

test('upgrade mintHolder', async t => {
const { bfile, importSpec } = t.context;

/** @type {SwingSetConfig} */
const config = harden({
bootstrap: 'bootstrap',
Expand Down
18 changes: 2 additions & 16 deletions packages/boot/test/upgrading/test-upgrade-vats.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,21 @@ import { buildVatController } from '@agoric/swingset-vat';
import { makeRunUtils } from '../bootstrapTests/supports.js';

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

const { Fail } = assert;

const bfile = name => new URL(name, import.meta.url).pathname;
const importSpec = spec =>
importMetaResolve(spec, import.meta.url).then(u => new URL(u).pathname);

const makeTestContext = async metaUrl => {
const bfile = name => new URL(name, metaUrl).pathname;

return { bfile };
};

const makeCallOutbound = t => (srcID, obj) => {
t.log(`callOutbound(${srcID}, ${obj})`);
return obj;
};

/** NOTE: limit ambient authority such as import.meta.url to test.before() */
test.before(async t => {
t.context = await makeTestContext(import.meta.url);
});

/**
* @param {any} t
* @param {Partial<SwingSetConfig>} [kernelConfigOverrides]
Expand Down Expand Up @@ -133,7 +121,6 @@ test.failing('upgrade bootstrap vat', async t => {
});

test('upgrade vat-bridge', async t => {
const { bfile } = t.context;
const bundles = {
bridge: { sourceSpec: await importSpec('@agoric/vats/src/vat-bridge.js') },
};
Expand Down Expand Up @@ -244,7 +231,6 @@ test('upgrade vat-bridge', async t => {
});

test('upgrade vat-bank', async t => {
const { bfile } = t.context;
const bundles = {
bank: { sourceSpec: await importSpec('@agoric/vats/src/vat-bank.js') },
bridge: { sourceSpec: await importSpec('@agoric/vats/src/vat-bridge.js') },
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"checkJs": false,
"checkJs": true,
"maxNodeModuleJsDepth": 2,
},
"include": [
Expand Down

0 comments on commit 38329c2

Please sign in to comment.