Skip to content

Commit

Permalink
7747 distinguish Zoe's manual timer (#9428)
Browse files Browse the repository at this point in the history
refs: #7747

## Description

As a stopgap to unifying the manual timer, this
1. fixes the types of ZoeManualTimer
2. gives it a named export that is different from the SwingSet one, so
it is more clear in context which is available

### Security Considerations

None, tests
### Scaling Considerations

None, tests

### Documentation Considerations

Not documented

### Testing Considerations

CI
### Upgrade Considerations

None, tests
  • Loading branch information
mergify[bot] authored May 30, 2024
2 parents 22cbfe3 + 797d5f3 commit b395841
Show file tree
Hide file tree
Showing 31 changed files with 110 additions and 107 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js';
import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';

Expand Down Expand Up @@ -240,7 +240,7 @@ const makeBootstrap = (argv, cb, vatPowers) => async (vats, devices) => {
E(zoe).install(cb.committee),
E(zoe).install(cb.binaryVoteCounter),
]);
const timer = buildManualTimer(log);
const timer = buildZoeManualTimer(log);

const installations = { committee, binaryVoteCounter };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js';
import { observeIteration, subscribeEach } from '@agoric/notifier';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js';
import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';

Expand Down Expand Up @@ -280,7 +280,7 @@ const makeBootstrap = (argv, cb, vatPowers) => async (vats, devices) => {
'zcf',
);
const installations = await installContracts(zoe, cb);
const timer = buildManualTimer(log);
const timer = buildZoeManualTimer(log);
const voterCreator = E(vats.voter).build(zoe);
const firstElectorateTerms = {
committeeName: 'TwentyCommittee',
Expand Down
4 changes: 2 additions & 2 deletions packages/governance/test/unitTests/ballotBuilder.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';

import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js';
import {
coerceQuestionSpec,
ChoiceMethod,
Expand All @@ -10,7 +10,7 @@ import {

const issue = harden({ text: 'will it blend?' });
const positions = [harden({ text: 'yes' }), harden({ text: 'no' })];
const timer = buildManualTimer(console.log);
const timer = buildZoeManualTimer(console.log);
const closingRule = { timer, deadline: 37n };

test('good QuestionSpec', t => {
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
@@ -1,7 +1,7 @@
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { E } from '@endo/eventual-send';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js';
import { makeHandle } from '@agoric/zoe/src/makeHandle.js';
import { Far } from '@endo/marshal';
import { makeStoredPublishKit } from '@agoric/notifier';
Expand Down Expand Up @@ -40,7 +40,7 @@ const PARAM_CHANGE_ISSUE = harden({
});

const FAKE_CLOSING_RULE = {
timer: buildManualTimer(console.log),
timer: buildZoeManualTimer(console.log),
deadline: 3n,
};

Expand Down
6 changes: 3 additions & 3 deletions packages/governance/test/unitTests/committee.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 { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js';
import { makeZoeForTest } from '@agoric/zoe/tools/setup-zoe.js';
import bundleSource from '@endo/bundle-source';
import { E } from '@endo/eventual-send';
Expand Down Expand Up @@ -83,7 +83,7 @@ test('committee-open question:one', async t => {
maxChoices: 1,
maxWinners: 1,
closingRule: {
timer: buildManualTimer(t.log),
timer: buildZoeManualTimer(t.log),
deadline: 2n,
},
quorumRule: QuorumRule.MAJORITY,
Expand Down Expand Up @@ -139,7 +139,7 @@ test('committee-open question:mixed, with snapshot', async t => {
mockChainStorageRoot,
} = await setupContract();

const timer = buildManualTimer(t.log);
const timer = buildZoeManualTimer(t.log);
const positions = [harden({ text: 'because' }), harden({ text: 'why not?' })];
const questionSpec = coerceQuestionSpec(
harden({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@agoric/notifier/tools/testSupports.js';
import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js';
import { makeHandle } from '@agoric/zoe/src/makeHandle.js';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js';
import { E } from '@endo/eventual-send';
import {
ChoiceMethod,
Expand All @@ -32,7 +32,7 @@ const MUTTON = harden({ text: 'Mutton' });
const GOAT = harden({ text: 'Goat' });

const FAKE_CLOSING_RULE = {
timer: buildManualTimer(console.log),
timer: buildZoeManualTimer(console.log),
deadline: 3n,
};

Expand Down
12 changes: 6 additions & 6 deletions packages/governance/test/unitTests/paramGovernance.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 { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js';
import { makeNotifierFromAsyncIterable } from '@agoric/notifier';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js';
import { makeZoeForTest } from '@agoric/zoe/tools/setup-zoe.js';
import bundleSource from '@endo/bundle-source';
import { E } from '@endo/eventual-send';
Expand Down Expand Up @@ -119,7 +119,7 @@ const setUpVoterAndVote = async (committeeCreator, zoe, qHandle, choice) => {

test('governParam no votes', async t => {
const zoe = await makeZoeForTest();
const timer = buildManualTimer(t.log);
const timer = buildZoeManualTimer(t.log);
const { governorFacets, installs, invitationAmount } =
await setUpGovernedContract(
zoe,
Expand Down Expand Up @@ -173,7 +173,7 @@ test('governParam no votes', async t => {

test('multiple params bad change', async t => {
const zoe = await makeZoeForTest();
const timer = buildManualTimer(t.log);
const timer = buildZoeManualTimer(t.log);
const { governorFacets, installs } = await setUpGovernedContract(
zoe,
{ committeeName: 'Demos', committeeSize: 1 },
Expand Down Expand Up @@ -204,7 +204,7 @@ test('multiple params bad change', async t => {

test('change multiple params', async t => {
const zoe = await makeZoeForTest();
const timer = buildManualTimer(t.log);
const timer = buildZoeManualTimer(t.log);
const { governorFacets, installs, invitationAmount, committeeCreator } =
await setUpGovernedContract(
zoe,
Expand Down Expand Up @@ -289,7 +289,7 @@ test('change multiple params', async t => {

test('change multiple params used invitation', async t => {
const zoe = await makeZoeForTest();
const timer = buildManualTimer(t.log);
const timer = buildZoeManualTimer(t.log);
const { governorFacets, installs, invitationAmount, committeeCreator } =
await setUpGovernedContract(
zoe,
Expand Down Expand Up @@ -360,7 +360,7 @@ test('change multiple params used invitation', async t => {

test('change param continuing invitation', async t => {
const zoe = await makeZoeForTest();
const timer = buildManualTimer(t.log);
const timer = buildZoeManualTimer(t.log);
const { governorFacets, installs, committeeCreator } =
await setUpGovernedContract(
zoe,
Expand Down
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 { makeNotifierFromAsyncIterable } from '@agoric/notifier';
import { makeZoeForTest } from '@agoric/zoe/tools/setup-zoe.js';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js';
import bundleSource from '@endo/bundle-source';
import { E } from '@endo/eventual-send';
import { resolve as importMetaResolve } from 'import-meta-resolve';
Expand Down Expand Up @@ -38,7 +38,7 @@ const governedTerms = {

test('multiple params bad change', async t => {
const zoe = await makeZoeForTest();
const timer = buildManualTimer(t.log);
const timer = buildZoeManualTimer(t.log);
const { governorFacets } = await setUpGovernedContract(
zoe,
E(zoe).install(governedBundleP),
Expand All @@ -65,7 +65,7 @@ test('multiple params bad change', async t => {

test('change a param', async t => {
const zoe = await makeZoeForTest();
const timer = buildManualTimer(t.log);
const timer = buildZoeManualTimer(t.log);
const { governorFacets, getFakeInvitation } = await setUpGovernedContract(
zoe,
E(zoe).install(governedBundleP),
Expand Down Expand Up @@ -125,7 +125,7 @@ test('change a param', async t => {

test('set offer Filter directly', async t => {
const zoe = await makeZoeForTest();
const timer = buildManualTimer(t.log);
const timer = buildZoeManualTimer(t.log);
const { governorFacets } = await setUpGovernedContract(
zoe,
E(zoe).install(governedBundleP),
Expand All @@ -142,7 +142,7 @@ test('set offer Filter directly', async t => {

test('call API directly', async t => {
const zoe = await makeZoeForTest();
const timer = buildManualTimer(t.log);
const timer = buildZoeManualTimer(t.log);
const { governorFacets } = await setUpGovernedContract(
zoe,
E(zoe).install(governedBundleP),
Expand All @@ -166,7 +166,7 @@ test('call API directly', async t => {
test('add issuerKeywordRecord', async t => {
const zoe = await makeZoeForTest();
const issuerKit = makeIssuerKit('Food', AssetKind.COPY_BAG);
const timer = buildManualTimer(t.log);
const timer = buildZoeManualTimer(t.log);
const { governorFacets } = await setUpGovernedContract(
zoe,
E(zoe).install(governedBundleP),
Expand Down
6 changes: 3 additions & 3 deletions packages/inter-protocol/test/feeDistributor.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';

import { AmountMath } from '@agoric/ertp';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import { setup } from '@agoric/zoe/test/unitTests/setupBasicMints.js';

Expand Down Expand Up @@ -73,7 +73,7 @@ const makeScenario = async t => {
stableMint.mintPayment(AmountMath.makeEmpty(brand));
const vaultFactory = makeFakeFeeProducer(makeEmptyPayment);
const amm = makeFakeFeeProducer(makeEmptyPayment);
const timerService = buildManualTimer(t.log);
const timerService = buildZoeManualTimer(t.log);
const { publicFacet, creatorFacet } = await makeFeeDistributor(issuer, {
timerService,
collectionInterval: 1n,
Expand Down Expand Up @@ -196,7 +196,7 @@ test('fee distribution, leftovers', async t => {
stableMint.mintPayment(AmountMath.makeEmpty(brand));
const vaultFactory = makeFakeFeeProducer(makeEmptyPayment);
const amm = makeFakeFeeProducer(makeEmptyPayment);
const timerService = buildManualTimer(t.log);
const timerService = buildZoeManualTimer(t.log);
const { creatorFacet } = await makeFeeDistributor(issuer, {
timerService,
collectionInterval: 1n,
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 @@ -12,7 +12,7 @@ import {
} from '@agoric/notifier/tools/testSupports.js';
import { makeScalarBigMapStore } from '@agoric/vat-data';
import { setupZCFTest } from '@agoric/zoe/test/unitTests/zcf/setupZcfTest.js';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js';
import { TimeMath } from '@agoric/time';
import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/recorder.js';
import { documentStorageSchema } from '@agoric/governance/tools/storageDoc.js';
Expand Down Expand Up @@ -44,7 +44,7 @@ const makeContext = async () => {
const mockStorageRoot = makeMockChainStorageRoot();
const storageNode = E(mockStorageRoot).makeChildNode('priceAggregator');

const manualTimer = buildManualTimer(() => {});
const manualTimer = buildZoeManualTimer(() => {});
const timerBrand = manualTimer.getTimerBrand();
const toTS = val => TimeMath.coerceTimestampRecord(val, timerBrand);

Expand Down
10 changes: 5 additions & 5 deletions packages/inter-protocol/test/psm/governedPsm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { makeFakeStorageKit } from '@agoric/internal/src/storage-test-utils.js';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import { makeFakeMarshaller } from '@agoric/notifier/tools/testSupports.js';
import { unsafeMakeBundleCache } from '@agoric/swingset-vat/tools/bundleTool.js';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js';
import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';
import { setupPsm } from './setupPsm.js';
Expand All @@ -16,7 +16,7 @@ test.before(async t => {

test('psm block offers w/Governance', async t => {
const electorateTerms = { committeeName: 'EnBancPanel', committeeSize: 3 };
const timer = buildManualTimer(t.log, 0n, { eventLoopIteration });
const timer = buildZoeManualTimer(t.log, 0n, { eventLoopIteration });

const { knut, zoe, psm, committeeCreator, governor, installs } =
await setupPsm(t, electorateTerms, timer);
Expand Down Expand Up @@ -59,7 +59,7 @@ test('psm block offers w/Governance', async t => {

test('psm block offers w/charter', async t => {
const electorateTerms = { committeeName: 'EnBancPanel', committeeSize: 3 };
const timer = buildManualTimer(t.log, 0n, { eventLoopIteration });
const timer = buildZoeManualTimer(t.log, 0n, { eventLoopIteration });

const { knut, zoe, psm, committeeCreator, econCharterCreatorFacet } =
await setupPsm(t, electorateTerms, timer);
Expand Down Expand Up @@ -114,7 +114,7 @@ test('psm block offers w/charter', async t => {

test('psm block offers w/charter via invitationMakers', async t => {
const electorateTerms = { committeeName: 'EnBancPanel', committeeSize: 3 };
const timer = buildManualTimer(t.log, 0n, { eventLoopIteration });
const timer = buildZoeManualTimer(t.log, 0n, { eventLoopIteration });

const { knut, zoe, psm, committeeCreator, econCharterCreatorFacet } =
await setupPsm(t, electorateTerms, timer);
Expand Down Expand Up @@ -168,7 +168,7 @@ test('psm block offers w/charter via invitationMakers', async t => {

test('replace electorate of Economic Committee', async t => {
const electorateTerms = { committeeName: 'EnBancPanel', committeeSize: 3 };
const timer = buildManualTimer(t.log, 0n, { eventLoopIteration });
const timer = buildZoeManualTimer(t.log, 0n, { eventLoopIteration });

const { zoe, governor, installs } = await setupPsm(t, electorateTerms, timer);

Expand Down
10 changes: 5 additions & 5 deletions packages/inter-protocol/test/psm/setupPsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { makeAgoricNamesAccess, makePromiseSpace } from '@agoric/vats';
import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js';
import { setUpZoeForTest } from '@agoric/zoe/tools/setup-zoe.js';
import { makeScalarMapStore } from '@agoric/vat-data';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js';
import { allValues } from '@agoric/internal';
import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js';
import { makeIssuerKit } from '@agoric/ertp';
Expand All @@ -22,7 +22,7 @@ import { startPSM, startEconCharter } from '../../src/proposals/startPSM.js';
const psmRoot = './src/psm/psm.js'; // package relative
const charterRoot = './src/econCommitteeCharter.js'; // package relative

/** @import {ManualTimer} from '@agoric/zoe/tools/manualTimer.js'; */
/** @import {ZoeManualTimer} from '@agoric/zoe/tools/manualTimer.js'; */

/** @typedef {ReturnType<typeof setUpZoeForTest>} FarZoeKit */

Expand All @@ -31,7 +31,7 @@ const charterRoot = './src/econCommitteeCharter.js'; // package relative
* @param {FarZoeKit} [farZoeKit]
*/
export const setupPsmBootstrap = async (
timer = buildManualTimer(console.log),
timer = buildZoeManualTimer(console.log),
farZoeKit,
) => {
const { zoe: wrappedZoe, feeMintAccessP } = await (farZoeKit ||
Expand Down Expand Up @@ -65,13 +65,13 @@ export const setupPsmBootstrap = async (
/**
* @param {any} t
* @param {{ committeeName: string; committeeSize: number }} electorateTerms
* @param {ManualTimer} [timer]
* @param {ZoeManualTimer} [timer]
* @param {FarZoeKit} [farZoeKit]
*/
export const setupPsm = async (
t,
electorateTerms = { committeeName: 'The Cabal', committeeSize: 1 },
timer = buildManualTimer(t.log),
timer = buildZoeManualTimer(t.log),
farZoeKit,
) => {
const knut = withAmountUtils(makeIssuerKit('KNUT'));
Expand Down
Loading

0 comments on commit b395841

Please sign in to comment.