Skip to content

Commit

Permalink
test: inline dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed May 17, 2024
1 parent 3cf87b7 commit 48f6896
Show file tree
Hide file tree
Showing 53 changed files with 53 additions and 106 deletions.
3 changes: 1 addition & 2 deletions packages/agoric-cli/src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ const REQUIRED_AGORIC_START_PACKAGES = [
'@agoric/cosmic-swingset',
];

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

export default async function installMain(progname, rawArgs, powers, opts) {
const { anylogger, fs, spawn } = powers;
Expand Down
3 changes: 1 addition & 2 deletions packages/boot/test/bootstrapTests/zcf-upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { TestFn } from 'ava';
import { matchAmount, makeSwingsetTestKit } from '../../tools/supports.ts';
import { makeZoeDriver } from '../../tools/drivers.ts';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const ZCF_PROBE_SRC = './zcfProbe.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import path from 'path';

const CONTRACT_FILES = ['committee', 'binaryVoteCounter'];

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

test.before(async t => {
const start = Date.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ const CONTRACT_FILES = [
},
];

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

test.before(async t => {
const start = Date.now();
Expand Down
3 changes: 1 addition & 2 deletions packages/governance/test/unitTests/committee.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import { remoteNullMarshaller } from '../swingsetTests/utils.js';
* @import {SimpleIssue} from '../../src/types.js';
*/

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const electorateRoot = `${dirname}/../../src/committee.js`;
const counterRoot = `${dirname}/../../src/binaryVoteCounter.js`;
Expand Down
3 changes: 1 addition & 2 deletions packages/pegasus/test/peg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import { makePromiseKit } from '@endo/promise-kit';
import { makeScalarMapStore } from '@agoric/vat-data';
import { makeDurableZone } from '@agoric/zone/durable.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const contractPath = `${dirname}/../src/contract.js`;

Expand Down
3 changes: 1 addition & 2 deletions packages/solo/src/init-basedir.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const console = anylogger('ag-solo:init');

const DEFAULT_WALLET = '@agoric/wallet';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

/**
* @param {string} basedir
Expand Down
3 changes: 1 addition & 2 deletions packages/solo/src/pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { parse, stringify } from '@endo/marshal';

import { makeShutdown } from '@agoric/internal/src/node/shutdown.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

export const connectToPipe = async ({ method, args, deliverInboundToMbx }) => {
// console.log('connectToPipe', method, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import {
loadBasedir,
} from '@agoric/swingset-vat';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

test.before(async t => {
const kernelBundles = await buildKernelBundles();
Expand Down
3 changes: 1 addition & 2 deletions packages/telemetry/src/slog-sender-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { makeQueue } from '@endo/stream';

import { makeShutdown } from '@agoric/internal/src/node/shutdown.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const logger = anylogger('slog-sender-pipe');

Expand Down
3 changes: 1 addition & 2 deletions packages/wallet/api/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { E } from '@endo/eventual-send';
import { Fail } from '@agoric/assert';
import path from 'path';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

export default async function deployWallet(
homePromise,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { loadBasedir, buildVatController } from '@agoric/swingset-vat';
import bundleSource from '@endo/bundle-source';
import zcfBundle from '../../../bundles/bundle-contractFacet.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const CONTRACT_FILES = ['crashingAutoRefund'];
const contractBundles = {};
Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/swingsetTests/makeKind/makeKind.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import zcfBundle from '../../../bundles/bundle-contractFacet.js';

const CONTRACT_FILES = ['minimalMakeKindContract'];

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

/** @type {import('ava').TestFn<{ data: { kernelBundles: any, config: any } }>} */
const test = anyTest;
Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/swingsetTests/offerArgs/offerArgs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import zcfBundle from '../../../bundles/bundle-contractFacet.js';

const CONTRACT_FILES = ['offerArgsUsageContract'];

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

/** @type {import('ava').TestFn<{ data: { kernelBundles: any, config: any } }>} */
const test = anyTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import zcfBundle from '../../../bundles/bundle-contractFacet.js';

const CONTRACT_FILES = ['privateArgsUsageContract'];

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

/** @type {import('ava').TestFn<{ data: { kernelBundles: any, config: any } }>} */
const test = anyTest;
Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/swingsetTests/runMint/runMint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import zcfBundle from '../../../bundles/bundle-contractFacet.js';
// feeBrand is made
const CONTRACT_FILES = ['runMintContract', 'offerArgsUsageContract'];

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

/** @type {import('ava').TestFn<{ data: { kernelBundles: any, config: any } }>} */
const test = anyTest;
Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/swingsetTests/zoe/zoe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { buildVatController, buildKernelBundles } from '@agoric/swingset-vat';
import bundleSource from '@endo/bundle-source';
import zcfBundle from '../../../bundles/bundle-contractFacet.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const CONTRACT_FILES = [
'automaticRefund',
Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/blockedOffers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
import { assertPayoutAmount } from '../zoeTestHelpers.js';
import { makeOffer } from './makeOffer.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const contractRoot = `${dirname}/zcf/zcfTesterContract.js`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { makeFakeVatAdmin } from '../../../tools/fakeVatAdmin.js';
import { depositToSeat } from '../../../src/contractSupport/zoeHelpers.js';
import { makeOffer } from '../makeOffer.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const contractRoot = `${dirname}/../zcf/zcfTesterContract.js`;

Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contractSupport/offerTo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { makeFakeVatAdmin } from '../../../tools/fakeVatAdmin.js';
import { offerTo, swapExact } from '../../../src/contractSupport/zoeHelpers.js';
import { makeOffer } from '../makeOffer.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const contractRoot = `${dirname}/../zcf/zcfTesterContract.js`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
import { assertPayoutAmount } from '../../zoeTestHelpers.js';
import { makeOffer } from '../makeOffer.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const contractRoot = `${dirname}/../zcf/zcfTesterContract.js`;

Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/atomicSwap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { setup } from '../setupBasicMints.js';
import { setupNonFungible } from '../setupNonFungibleMints.js';
import { assertAmountsEqual } from '../../zoeTestHelpers.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const atomicSwapRoot = `${dirname}/../../../src/contracts/atomicSwap.js`;

Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/auction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import buildManualTimer from '../../../tools/manualTimer.js';
import { setup } from '../setupBasicMints.js';
import { setupMixed } from '../setupMixedMints.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const auctionRoot = `${dirname}/../../../src/contracts/auction/index.js`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { claim, splitMany } from '@agoric/ertp/src/legacy-payment-helpers.js';
import { setup } from '../setupBasicMints.js';
import { setupNonFungible } from '../setupNonFungibleMints.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const automaticRefundRoot = `${dirname}/../../../src/contracts/automaticRefund.js`;

Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/autoswap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import { setup } from '../setupBasicMints.js';
import { installationPFromSource } from '../installFromSource.js';
import { assertOfferResult, assertPayoutAmount } from '../../zoeTestHelpers.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const autoswap = `${dirname}/../../../src/contracts/autoswap.js`;

Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/barter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { setup } from '../setupBasicMints.js';
import { installationPFromSource } from '../installFromSource.js';
import { assertPayoutAmount, assertOfferResult } from '../../zoeTestHelpers.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const barter = `${dirname}/../../../src/contracts/barterExchange.js`;

Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/brokenContract.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { makeZoeForTest } from '../../../tools/setup-zoe.js';
import { setup } from '../setupBasicMints.js';
import { makeFakeVatAdmin } from '../../../tools/fakeVatAdmin.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const automaticRefundRoot = `${dirname}/brokenAutoRefund.js`;

Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/callSpread.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
} from '../../zoeTestHelpers.js';
import { makeFakePriceAuthority } from '../../../tools/fakePriceAuthority.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const fundedCallSpread = `${dirname}/../../../src/contracts/callSpread/fundedCallSpread.js`;
const pricedCallSpread = `${dirname}/../../../src/contracts/callSpread/pricedCallSpread.js`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { TimeMath } from '@agoric/time';
import buildManualTimer from '../../../tools/manualTimer.js';
import { setup } from '../setupBasicMints.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const coveredCallRoot = `${dirname}/../../../src/contracts/coveredCall.js`;
const atomicSwapRoot = `${dirname}/../../../src/contracts/atomicSwap.js`;
Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/coveredCall.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import { setup } from '../setupBasicMints.js';
import { setupNonFungible } from '../setupNonFungibleMints.js';
import { assertAmountsEqual } from '../../zoeTestHelpers.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const coveredCallRoot = `${dirname}/../../../src/contracts/coveredCall.js`;
const atomicSwapRoot = `${dirname}/../../../src/contracts/atomicSwap.js`;
Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/escrowToVote.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { makeZoeForTest } from '../../../tools/setup-zoe.js';
import { setup } from '../setupBasicMints.js';
import { makeFakeVatAdmin } from '../../../tools/fakeVatAdmin.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const contractRoot = `${dirname}/escrowToVote.js`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { AmountMath } from '@agoric/ertp';
import { makeZoeForTest } from '../../../tools/setup-zoe.js';
import { makeFakeVatAdmin } from '../../../tools/fakeVatAdmin.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const root = `${dirname}/two-invitations.js`;

Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/loan/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { setupZCFTest } from '../../zcf/setupZcfTest.js';
import { makeRatio } from '../../../../src/contractSupport/index.js';
import { assertAmountsEqual } from '../../../zoeTestHelpers.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

/**
* @param {import("ava").ExecutionContext<unknown>} t
Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/loan/loan-e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import { makeFakePriceAuthority } from '../../../../tools/fakePriceAuthority.js'
import buildManualTimer from '../../../../tools/manualTimer.js';
import { makeRatio } from '../../../../src/contractSupport/index.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const loanRoot = `${dirname}/../../../../src/contracts/loan/`;
const autoswapRoot = `${dirname}/../../../../src/contracts/autoswap`;
Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/mintPayments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { makeFakeVatAdmin } from '../../../tools/fakeVatAdmin.js';

import { makeZoeForTest } from '../../../tools/setup-zoe.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const mintPaymentsRoot = `${dirname}/../../../src/contracts/mintPayments.js`;

Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/oracle.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import '../../../src/contracts/exported.js';
* @typedef {import('ava').ExecutionContext<TestContext>} ExecutionContext
*/

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const contractPath = `${dirname}/../../../src/contracts/oracle.js`;

Expand Down
3 changes: 1 addition & 2 deletions packages/zoe/test/unitTests/contracts/otcDesk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { setup } from '../setupBasicMints.js';
import buildManualTimer from '../../../tools/manualTimer.js';
import { assertPayoutAmount } from '../../zoeTestHelpers.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const root = `${dirname}/../../../src/contracts/otcDesk.js`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { GET_METHOD_NAMES } from '@endo/marshal';
import { makeZoeForTest } from '../../../tools/setup-zoe.js';
import { makeFakeVatAdmin } from '../../../tools/fakeVatAdmin.js';

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const root = `${dirname}/ownable-counter.js`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ const testStartFn = (zcf, privateArgs) => start(zcf, privateArgs);
* @property {IssuerKit} link
*/

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const oraclePath = `${dirname}/../../../src/contracts/oracle.js`;
const aggregatorPath = `${dirname}/../../../src/contracts/priceAggregator.js`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import '../../../src/contracts/exported.js';

const test = /** @type {import('ava').TestFn<TestContext>} */ (unknownTest);

const filename = new URL(import.meta.url).pathname;
const dirname = path.dirname(filename);
const dirname = path.dirname(new URL(import.meta.url).pathname);

const scaledPricePath = `${dirname}/../../../src/contracts/scaledPriceAuthority.js`;

Expand Down
Loading

0 comments on commit 48f6896

Please sign in to comment.