Skip to content

Commit

Permalink
refactor: makeFake* → fake*
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed May 23, 2024
1 parent 90906b1 commit e40225e
Show file tree
Hide file tree
Showing 104 changed files with 391 additions and 405 deletions.
14 changes: 7 additions & 7 deletions packages/SwingSet/test/timer-device.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function makeHandler() {
});
}

function makeFakeTimer(initialVal) {
function fakeTimer(initialVal) {
let fakeTime = initialVal;
return Far('fake timer', {
getLastPolled() {
Expand All @@ -83,7 +83,7 @@ function makeFakeTimer(initialVal) {

test('Timer schedule single event', t => {
const schedule = makeTimerMap();
const fakeTimer = makeFakeTimer(1n);
const fakeTimer = fakeTimer(1n);
const lastPolled = fakeTimer.getLastPolled;
const poll = curryPollFn(fakeSO, [], schedule, lastPolled, _ => {});
t.falsy(poll(1n)); // false when nothing is woken
Expand All @@ -97,7 +97,7 @@ test('Timer schedule single event', t => {

test('Timer schedule multiple events', t => {
const schedule = makeTimerMap();
const fakeTimer = makeFakeTimer(1);
const fakeTimer = fakeTimer(1);
const lastPolled = fakeTimer.getLastPolled;
const poll = curryPollFn(fakeSO, [], schedule, lastPolled, _ => {});
t.falsy(poll(1n)); // false when nothing is woken
Expand All @@ -117,7 +117,7 @@ test('Timer schedule multiple events', t => {
test('Timer schedule repeated event first', t => {
const repeaterIndex = 0;
const schedule = makeTimerMap();
const fakeTimer = makeFakeTimer(1n);
const fakeTimer = fakeTimer(1n);
const lastPolled = fakeTimer.getLastPolled;
const repeater = { startTime: 3n, interval: 4n };
const poll = curryPollFn(fakeSO, [repeater], schedule, lastPolled, _ => {});
Expand All @@ -138,7 +138,7 @@ test('multiMap remove repeater key', t => {
const repeaterIndex = 0;
const scheduleTime = 3n;
const schedule = makeTimerMap();
const fakeTimer = makeFakeTimer(1);
const fakeTimer = fakeTimer(1);
const lastPolled = fakeTimer.getLastPolled;
const repeater = { startTime: 2n, interval: 4n };
const poll = curryPollFn(fakeSO, [repeater], schedule, lastPolled, _ => {});
Expand All @@ -151,7 +151,7 @@ test('multiMap remove repeater key', t => {
test('Timer schedule repeated event, repeatedly', t => {
const repeaterIndex = 0;
const schedule = makeTimerMap();
const fakeTimer = makeFakeTimer(4n);
const fakeTimer = fakeTimer(4n);
const lastPolled = fakeTimer.getLastPolled;
const repeater = { startTime: 6n, interval: 3n };
const poll = curryPollFn(fakeSO, [repeater], schedule, lastPolled, _ => {});
Expand Down Expand Up @@ -179,7 +179,7 @@ test('Timer schedule multiple repeaters', t => {
const repeaterIndex1 = 1;
const repeaterIndex2 = 2;
const schedule = makeTimerMap();
const fakeTimer = makeFakeTimer(4);
const fakeTimer = fakeTimer(4);
const lastPolled = fakeTimer.getLastPolled;
const repeater0 = { startTime: 6n, interval: 3n };
const repeater1 = { startTime: 7n, interval: 5n };
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/test/bootstrapTests/net-ibc-upgrade.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file upgrade network / IBC vat at many points in state machine */
import { BridgeId } from '@agoric/internal';
import type { BridgeHandler } from '@agoric/vats';
import { makeFakeIbcBridge } from '@agoric/vats/tools/fake-bridge.js';
import { fakeIbcBridge } from '@agoric/vats/tools/fake-bridge.js';
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import { makeNodeBundleCache } from '@endo/bundle-source/cache.js';
import type { TestFn } from 'ava';
Expand Down
4 changes: 2 additions & 2 deletions packages/boot/tools/supports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Fail, NonNullish } from '@agoric/assert';
import { buildSwingset } from '@agoric/cosmic-swingset/src/launch-chain.js';
import { BridgeId, VBankAccount, makeTracer } from '@agoric/internal';
import { unmarshalFromVstorage } from '@agoric/internal/src/marshal.js';
import { makeFakeStorageKit } from '@agoric/internal/src/storage-test-utils.js';
import { fakeStorageKit } from '@agoric/internal/src/storage-test-utils.js';
import { krefOf } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';
import { loadSwingsetConfigFile } from '@agoric/swingset-vat';
Expand Down Expand Up @@ -255,7 +255,7 @@ export const makeSwingsetTestKit = async (
bundleDir = 'bundles',
{
configSpecifier = undefined as string | undefined,
storage = makeFakeStorageKit('bootstrapTests'),
storage = fakeStorageKit('bootstrapTests'),
verbose = false,
slogFile = undefined as string | undefined,
profileVats = [] as string[],
Expand Down
4 changes: 2 additions & 2 deletions packages/deploy-script-support/test/unitTests/install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { makeZoeForTest } from '@agoric/zoe/tools/setup-zoe.js';
import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js';
import { fakeBoard } from '@agoric/vats/tools/board-utils.js';
import bundleSource from '@endo/bundle-source';
import { resolve as importMetaResolve } from 'import-meta-resolve';

Expand All @@ -22,7 +22,7 @@ test('install', async t => {
},
};

const board = makeFakeBoard();
const board = fakeBoard();
const install = makeInstall(bundleSource, zoe, installationManager, board);

const resolvedUrl = await importMetaResolve(
Expand Down
4 changes: 2 additions & 2 deletions packages/governance/test/unitTests/binaryballotCount.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Far } from '@endo/marshal';
import { makeStoredPublishKit } from '@agoric/notifier';
import {
eventLoopIteration,
makeFakeMarshaller,
fakeMarshaller,
} from '@agoric/notifier/tools/testSupports.js';

import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js';
Expand Down Expand Up @@ -50,7 +50,7 @@ const FAKE_COUNTER_INSTANCE = makeHandle('Instance');

function makePublisherFromFakes() {
const storageRoot = makeMockChainStorageRoot();
const publishKit = makeStoredPublishKit(storageRoot, makeFakeMarshaller());
const publishKit = makeStoredPublishKit(storageRoot, fakeMarshaller());
return { publisher: publishKit.publisher, storageRoot };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import { makeStoredPublishKit } from '@agoric/notifier';
import {
eventLoopIteration,
makeFakeMarshaller,
fakeMarshaller,
} from '@agoric/notifier/tools/testSupports.js';
import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js';
import { makeHandle } from '@agoric/zoe/src/makeHandle.js';
Expand Down Expand Up @@ -41,7 +41,7 @@ const FAKE_COUNTER_INSTANCE = makeHandle('Instance');

function makePublisherFromFakes() {
const storageRoot = makeMockChainStorageRoot();
const publishKit = makeStoredPublishKit(storageRoot, makeFakeMarshaller());
const publishKit = makeStoredPublishKit(storageRoot, fakeMarshaller());
return { publisher: publishKit.publisher, storageRoot };
}

Expand Down
4 changes: 2 additions & 2 deletions packages/inter-protocol/test/auction/auctionBook.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AmountMath } from '@agoric/ertp';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import { buildManualTimer } from '@agoric/swingset-vat/tools/manual-timer.js';
import { makeScalarBigMapStore } from '@agoric/vat-data';
import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js';
import { fakeBoard } from '@agoric/vats/tools/board-utils.js';
import {
makeRatio,
makeRatioFromAmounts,
Expand Down Expand Up @@ -34,7 +34,7 @@ const setupBasics = async () => {
await zcf.saveIssuer(simoleanKit.issuer, 'Sim');
const baggage = makeScalarBigMapStore('zcfBaggage', { durable: true });

const marshaller = makeFakeBoard().getReadonlyMarshaller();
const marshaller = fakeBoard().getReadonlyMarshaller();

const { makeERecorderKit, makeRecorderKit } = prepareRecorderKitMakers(
baggage,
Expand Down
26 changes: 13 additions & 13 deletions packages/inter-protocol/test/auction/scheduler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { subscriptionTracker } from '../metrics.js';
import {
getInvitation,
makeDefaultParams,
makeFakeAuctioneer,
fakeAuctioneer,
makeGovernancePublisherFromFakes,
setUpInstallations,
} from './tools.js';
Expand All @@ -34,7 +34,7 @@ test('schedule start to finish', async t => {
const timer = buildManualTimer();
const timerBrand = await timer.getTimerBrand();

const fakeAuctioneer = makeFakeAuctioneer();
const fakeAuctioneer = fakeAuctioneer();
const { fakeInvitationPayment } = await getInvitation(zoe, installations);

const { makeRecorderKit, storageNode } = prepareMockRecorderKitMakers();
Expand Down Expand Up @@ -265,7 +265,7 @@ test('lowest >= starting', async t => {
const timer = buildManualTimer();
const timerBrand = await timer.getTimerBrand();

const fakeAuctioneer = makeFakeAuctioneer();
const fakeAuctioneer = fakeAuctioneer();
const { fakeInvitationPayment } = await getInvitation(zoe, installations);
const { makeRecorderKit, storageNode } = prepareMockRecorderKitMakers();
const recorderKit = makeRecorderKit(storageNode);
Expand Down Expand Up @@ -313,7 +313,7 @@ test('zero time for auction', async t => {
const timer = buildManualTimer();
const timerBrand = await timer.getTimerBrand();

const fakeAuctioneer = makeFakeAuctioneer();
const fakeAuctioneer = fakeAuctioneer();
const { fakeInvitationPayment } = await getInvitation(zoe, installations);
const publisherKit = makeGovernancePublisherFromFakes();
const { makeRecorderKit, storageNode } = prepareMockRecorderKitMakers();
Expand Down Expand Up @@ -362,7 +362,7 @@ test('discountStep 0', async t => {
const timer = buildManualTimer();
const timerBrand = await timer.getTimerBrand();

const fakeAuctioneer = makeFakeAuctioneer();
const fakeAuctioneer = fakeAuctioneer();
const { fakeInvitationPayment } = await getInvitation(zoe, installations);
const publisherKit = makeGovernancePublisherFromFakes();

Expand Down Expand Up @@ -408,7 +408,7 @@ test('discountStep larger than starting rate', async t => {
const timer = buildManualTimer();
const timerBrand = await timer.getTimerBrand();

const fakeAuctioneer = makeFakeAuctioneer();
const fakeAuctioneer = fakeAuctioneer();
const { fakeInvitationPayment } = await getInvitation(zoe, installations);
const publisherKit = makeGovernancePublisherFromFakes();

Expand Down Expand Up @@ -455,7 +455,7 @@ test('start Freq 0', async t => {
const timer = buildManualTimer();
const timerBrand = await timer.getTimerBrand();

const fakeAuctioneer = makeFakeAuctioneer();
const fakeAuctioneer = fakeAuctioneer();
const { fakeInvitationPayment } = await getInvitation(zoe, installations);
const publisherKit = makeGovernancePublisherFromFakes();

Expand Down Expand Up @@ -501,7 +501,7 @@ test('delay > freq', async t => {
const timer = buildManualTimer();
const timerBrand = await timer.getTimerBrand();

const fakeAuctioneer = makeFakeAuctioneer();
const fakeAuctioneer = fakeAuctioneer();
const { fakeInvitationPayment } = await getInvitation(zoe, installations);
const publisherKit = makeGovernancePublisherFromFakes();

Expand Down Expand Up @@ -548,7 +548,7 @@ test('lockPeriod > freq', async t => {
const timer = buildManualTimer();
const timerBrand = await timer.getTimerBrand();

const fakeAuctioneer = makeFakeAuctioneer();
const fakeAuctioneer = fakeAuctioneer();
const { fakeInvitationPayment } = await getInvitation(zoe, installations);
const publisherKit = makeGovernancePublisherFromFakes();

Expand Down Expand Up @@ -597,7 +597,7 @@ test('duration = freq', async t => {
const timer = buildManualTimer();
const timerBrand = await timer.getTimerBrand();

const fakeAuctioneer = makeFakeAuctioneer();
const fakeAuctioneer = fakeAuctioneer();
const { fakeInvitationPayment } = await getInvitation(zoe, installations);
const publisherKit = makeGovernancePublisherFromFakes();

Expand Down Expand Up @@ -685,7 +685,7 @@ test('change Schedule', async t => {
const startDelay = TimeMath.coerceRelativeTimeRecord(startDelayT, timerBrand);
const clockStep = 60n;

const fakeAuctioneer = makeFakeAuctioneer();
const fakeAuctioneer = fakeAuctioneer();
const { fakeInvitationPayment } = await getInvitation(zoe, installations);
const publisherKit = makeGovernancePublisherFromFakes();

Expand Down Expand Up @@ -878,7 +878,7 @@ test('change Schedule late', async t => {
const startDelay = TimeMath.coerceRelativeTimeRecord(startDelayT, timerBrand);
const clockStep = 60n;

const fakeAuctioneer = makeFakeAuctioneer();
const fakeAuctioneer = fakeAuctioneer();
const { fakeInvitationPayment } = await getInvitation(zoe, installations);
const publisherKit = makeGovernancePublisherFromFakes();

Expand Down Expand Up @@ -1096,7 +1096,7 @@ test('schedule anomalies', async t => {
const timestamp = time => TimeMath.coerceTimestampRecord(time, timerBrand);
const relative = time => TimeMath.coerceRelativeTimeRecord(time, timerBrand);

const fakeAuctioneer = makeFakeAuctioneer();
const fakeAuctioneer = fakeAuctioneer();
const { fakeInvitationPayment } = await getInvitation(zoe, installations);

const { makeRecorderKit, storageNode } = prepareMockRecorderKitMakers();
Expand Down
6 changes: 3 additions & 3 deletions packages/inter-protocol/test/auction/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { E } from '@endo/eventual-send';
import { makeStoredPublisherKit } from '@agoric/notifier';
import { objectMap, allValues } from '@agoric/internal';
import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js';
import { makeFakeMarshaller } from '@agoric/notifier/tools/testSupports.js';
import { fakeMarshaller } from '@agoric/notifier/tools/testSupports.js';
import { GOVERNANCE_STORAGE_KEY } from '@agoric/governance/src/contractHelper.js';
import contractGovernorBundle from '@agoric/governance/bundles/bundle-contractGovernor.js';
import { unsafeMakeBundleCache } from '@agoric/swingset-vat/tools/bundleTool.js';
Expand Down Expand Up @@ -56,7 +56,7 @@ export const makeDefaultParams = (invitation, timerBrand) =>
TimerBrand: timerBrand,
});

export const makeFakeAuctioneer = () => {
export const fakeAuctioneer = () => {
const state = { step: 0, final: false, capturedPrices: false };
const startRounds = [];

Expand Down Expand Up @@ -101,7 +101,7 @@ export const makeGovernancePublisherFromFakes = () => {

return makeStoredPublisherKit(
storageRoot,
makeFakeMarshaller(),
fakeMarshaller(),
GOVERNANCE_STORAGE_KEY,
);
};
18 changes: 9 additions & 9 deletions packages/inter-protocol/test/feeDistributor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { mustMatch } from '@agoric/store';
import { makeFeeDistributor, meta } from '../src/feeDistributor.js';

/** @param {Issuer} feeIssuer */
const makeFakeFeeDepositFacetKit = feeIssuer => {
const fakeFeeDepositFacetKit = feeIssuer => {
const depositPayments = [];

const feeDepositFacet = {
Expand All @@ -28,7 +28,7 @@ const makeFakeFeeDepositFacetKit = feeIssuer => {
return { feeDepositFacet, getPayments };
};

const makeFakeFeeProducer = (makeEmptyPayment = () => {}) => {
const fakeFeeProducer = (makeEmptyPayment = () => {}) => {
const feePayments = [];
return Far('feeCollector', {
collectFees: () => feePayments.shift() || makeEmptyPayment(),
Expand Down Expand Up @@ -68,11 +68,11 @@ const assertPaymentArray = async (
const makeScenario = async t => {
const { brands, moolaIssuer: issuer, moolaMint: stableMint } = setup();
const brand = brands.get('moola');
const { feeDepositFacet, getPayments } = makeFakeFeeDepositFacetKit(issuer);
const { feeDepositFacet, getPayments } = fakeFeeDepositFacetKit(issuer);
const makeEmptyPayment = () =>
stableMint.mintPayment(AmountMath.makeEmpty(brand));
const vaultFactory = makeFakeFeeProducer(makeEmptyPayment);
const amm = makeFakeFeeProducer(makeEmptyPayment);
const vaultFactory = fakeFeeProducer(makeEmptyPayment);
const amm = fakeFeeProducer(makeEmptyPayment);
const timerService = buildManualTimer(t.log);
const { publicFacet, creatorFacet } = await makeFeeDistributor(issuer, {
timerService,
Expand Down Expand Up @@ -158,7 +158,7 @@ test('setKeywordShares', async t => {
);

const { feeDepositFacet: deposit2, getPayments: getPayments2 } =
makeFakeFeeDepositFacetKit(issuer);
fakeFeeDepositFacetKit(issuer);
const rewardsDestination =
creatorFacet.makeDepositFacetDestination(feeDepositFacet);
const reserveDestination = creatorFacet.makeDepositFacetDestination(deposit2);
Expand Down Expand Up @@ -191,11 +191,11 @@ test('setKeywordShares', async t => {
test('fee distribution, leftovers', async t => {
const { brands, moolaIssuer: issuer, moolaMint: stableMint } = setup();
const brand = brands.get('moola');
const { feeDepositFacet, getPayments } = makeFakeFeeDepositFacetKit(issuer);
const { feeDepositFacet, getPayments } = fakeFeeDepositFacetKit(issuer);
const makeEmptyPayment = () =>
stableMint.mintPayment(AmountMath.makeEmpty(brand));
const vaultFactory = makeFakeFeeProducer(makeEmptyPayment);
const amm = makeFakeFeeProducer(makeEmptyPayment);
const vaultFactory = fakeFeeProducer(makeEmptyPayment);
const amm = fakeFeeProducer(makeEmptyPayment);
const timerService = buildManualTimer(t.log);
const { creatorFacet } = await makeFeeDistributor(issuer, {
timerService,
Expand Down
4 changes: 2 additions & 2 deletions packages/inter-protocol/test/price/fluxAggregatorKit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-util
import { subscribeEach } from '@agoric/notifier';
import {
eventLoopIteration,
makeFakeMarshaller,
fakeMarshaller,
} from '@agoric/notifier/tools/testSupports.js';
import { makeScalarBigMapStore } from '@agoric/vat-data';
import { setupZCFTest } from '@agoric/zoe/test/unitTests/zcf/setupZcfTest.js';
Expand Down Expand Up @@ -40,7 +40,7 @@ const makeContext = async () => {
const zcfTestKit = await setupZCFTest(undefined, terms);

// ??? why do we need the Far here and not in VaultFactory tests?
const marshaller = Far('fake marshaller', { ...makeFakeMarshaller() });
const marshaller = Far('fake marshaller', { ...fakeMarshaller() });
const mockStorageRoot = makeMockChainStorageRoot();
const storageNode = E(mockStorageRoot).makeChildNode('priceAggregator');

Expand Down
Loading

0 comments on commit e40225e

Please sign in to comment.