diff --git a/packages/vats/test/bootstrapTests/liquidationVisibility/init-old-vaultFactory.js b/packages/vats/test/bootstrapTests/liquidationVisibility/init-old-vaultFactory.js deleted file mode 100644 index 3a5b3e98d6ab..000000000000 --- a/packages/vats/test/bootstrapTests/liquidationVisibility/init-old-vaultFactory.js +++ /dev/null @@ -1,203 +0,0 @@ -/* global process */ -/** - * @file can be run with `agoric deploy` after a chain is running (depends on chain state) - * Only works with "local" chain and not sim-chain b/c it needs governance votes (n/a on sim-chain). - */ -import { makeHelpers } from '@agoric/deploy-script-support'; -import { objectMap } from '@agoric/internal'; - -import { - getManifestForInterProtocol, - getManifestForEconCommittee, - getManifestForMain, -} from '@agoric/inter-protocol/src/proposals/core-proposal.js'; -import { makeInstallCache } from '@agoric/inter-protocol/src/proposals/utils.js'; - -/** @type {Record>} */ -const installKeyGroups = { - econCommittee: { - contractGovernor: [ - '@agoric/governance/src/contractGovernor.js', - '../../../../governance/bundles/bundle-contractGovernor.js', - ], - committee: [ - '@agoric/governance/src/committee.js', - '../../../../governance/bundles/bundle-committee.js', - ], - binaryVoteCounter: [ - '@agoric/governance/src/binaryVoteCounter.js', - '../../../../governance/bundles/bundle-binaryVoteCounter.js', - ], - }, - main: { - auctioneer: [ - '@agoric/inter-protocol/src/auction/auctioneer.js', - '../../../../inter-protocol/bundles/bundle-auctioneer.js', - ], - vaultFactory: [ - '@agoric/vats/test/bootstrapTests/liquidationVisibility/vaultFactory/vaultFactory.js', - '@agoric/vats/test/bootstrapTests/liquidationVisibility/bundles/bundle-vaultFactory.js', - ], - feeDistributor: [ - '@agoric/inter-protocol/src/feeDistributor.js', - '../../../../inter-protocol/bundles/bundle-feeDistributor.js', - ], - reserve: [ - '@agoric/inter-protocol/src/reserve/assetReserve.js', - '../../../../inter-protocol/bundles/bundle-reserve.js', - ], - }, -}; - -/** - * @param {object} opts - * @param {(i: I) => R} opts.publishRef - * @param {(m: string, b: string, opts?: any) => I} opts.install - * @param {(f: T) => T} [opts.wrapInstall] - * - * @param {object} [options] - * @param {{ committeeName?: string, committeeSize?: number}} [options.econCommitteeOptions] - * @template I - * @template R - */ -export const committeeProposalBuilder = async ( - { publishRef, install: install0, wrapInstall }, - { econCommitteeOptions } = {}, -) => { - const install = wrapInstall ? wrapInstall(install0) : install0; - - /** @param {Record} group */ - const publishGroup = group => - objectMap(group, ([mod, bundle]) => - publishRef(install(mod, bundle, { persist: true })), - ); - return harden({ - sourceSpec: '@agoric/inter-protocol/src/proposals/core-proposal.js', - getManifestCall: [ - getManifestForEconCommittee.name, - { - econCommitteeOptions, - installKeys: { - ...publishGroup(installKeyGroups.econCommittee), - }, - }, - ], - }); -}; - -/** - * @param {object} opts - * @param {(i: I) => R} opts.publishRef - * @param {(m: string, b: string, opts?: any) => I} opts.install - * @param {(f: T) => T} [opts.wrapInstall] - * - * @template I - * @template R - */ -export const mainProposalBuilder = async ({ - publishRef, - install: install0, - wrapInstall, -}) => { - const { VAULT_FACTORY_CONTROLLER_ADDR } = process.env; - - const install = wrapInstall ? wrapInstall(install0) : install0; - - const persist = true; - /** @param {Record} group */ - const publishGroup = group => - objectMap(group, ([mod, bundle]) => - publishRef(install(mod, bundle, { persist })), - ); - return harden({ - sourceSpec: '@agoric/inter-protocol/src/proposals/core-proposal.js', - getManifestCall: [ - getManifestForMain.name, - { - vaultFactoryControllerAddress: VAULT_FACTORY_CONTROLLER_ADDR, - installKeys: { - ...publishGroup(installKeyGroups.main), - }, - }, - ], - }); -}; - -// Build proposal for sim-chain etc. -/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */ -export const defaultProposalBuilder = async ( - { publishRef, install }, - options = {}, - { env = process.env } = {}, -) => { - /** @param {string|undefined} s */ - const optBigInt = s => s && BigInt(s); - const { - vaultFactoryControllerAddress = env.VAULT_FACTORY_CONTROLLER_ADDR, - minInitialPoolLiquidity = env.MIN_INITIAL_POOL_LIQUIDITY, - referencedUi, - anchorOptions: { - anchorDenom = env.ANCHOR_DENOM, - anchorDecimalPlaces = '6', - anchorKeyword = 'AUSD', - anchorProposedName = anchorKeyword, - initialPrice = undefined, - } = {}, - econCommitteeOptions: { - committeeSize: econCommitteeSize = env.ECON_COMMITTEE_SIZE || '3', - } = {}, - } = options; - - /** @param {Record} group */ - const publishGroup = group => - objectMap(group, ([mod, bundle]) => publishRef(install(mod, bundle))); - - const anchorOptions = anchorDenom && { - denom: anchorDenom, - decimalPlaces: parseInt(anchorDecimalPlaces, 10), - initialPrice, - keyword: anchorKeyword, - proposedName: anchorProposedName, - }; - - const econCommitteeOptions = { - committeeSize: parseInt(econCommitteeSize, 10), - }; - - return harden({ - sourceSpec: '@agoric/inter-protocol/src/proposals/core-proposal.js', - getManifestCall: [ - getManifestForInterProtocol.name, - { - vaultFactoryControllerAddress, - minInitialPoolLiquidity: optBigInt(minInitialPoolLiquidity), - referencedUi, - anchorOptions, - econCommitteeOptions, - installKeys: { - ...publishGroup(installKeyGroups.econCommittee), - ...publishGroup(installKeyGroups.main), - }, - }, - ], - }); -}; - -export default async (homeP, endowments) => { - const { writeCoreProposal } = await makeHelpers(homeP, endowments); - - const tool = await makeInstallCache(homeP, { - loadBundle: spec => import(spec), - }); - await Promise.all([ - writeCoreProposal('gov-econ-committee', opts => - // @ts-expect-error XXX makeInstallCache types - committeeProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }), - ), - writeCoreProposal('gov-amm-vaults-etc', opts => - // @ts-expect-error XXX makeInstallCache types - mainProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }), - ), - ]); - await tool.saveCache(); -}; diff --git a/packages/vats/test/bootstrapTests/liquidationVisibility/liquidation-test-utils.js b/packages/vats/test/bootstrapTests/liquidationVisibility/liquidation-test-utils.js index b3b494042412..4dce762fd7c5 100644 --- a/packages/vats/test/bootstrapTests/liquidationVisibility/liquidation-test-utils.js +++ b/packages/vats/test/bootstrapTests/liquidationVisibility/liquidation-test-utils.js @@ -3,29 +3,10 @@ /** * @file Bootstrap test vaults liquidation visibility */ -import * as processAmbient from 'child_process'; -import * as fsAmbient from 'fs'; -import { Fail, NonNullish } from '@agoric/assert'; +import { NonNullish } from '@agoric/assert'; import { Offers } from '@agoric/inter-protocol/src/clientSupport.js'; import { TimeMath } from '@agoric/time'; -import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js'; -import { - SECONDS_PER_HOUR, - SECONDS_PER_MINUTE, -} from '@agoric/inter-protocol/src/proposals/econ-behaviors.js'; import { scale6 } from '../liquidation.js'; -import { makeAgoricNamesRemotesFromFakeStorage } from '../../../tools/board-utils.js'; -import { makeSwingsetTestKit } from '../supports.js'; -import { - makeGovernanceDriver, - makePriceFeedDriver, - makeWalletFactoryDriver, -} from '../drivers.js'; - -const PLATFORM_CONFIG = - '@agoric/vats/test/bootstrapTests/liquidationVisibility/vaults-liquidation-config.json'; - -const DebtLimitValue = scale6(100_000); //#region Product spec const setup = /** @type {const} */ ({ @@ -265,299 +246,3 @@ export const checkVisibility = async ({ t.log('postAuction', postAuction); t.log('auctionResult', auctionResult); }; - -export const checkVMChildNodes = async ({ - t, - managerIndex, - collateralBrandKey, - liquidation, - base = 0, -}) => { - const { storage, advanceTimeBy, runUtils } = t.context; - - await addNewVaults({ t, collateralBrandKey, base }); - await runAuction(runUtils, advanceTimeBy); - - const managerPath = `published.vaultFactory.managers.manager${managerIndex}`; - const childNodes = storage.toStorage({ - method: 'children', - args: [`${managerPath}`], - }); - t.log('VaultManager child nodes: ', childNodes); - - let expectedChildNodes = ['governance', 'metrics', 'quotes', 'vaults']; - if (liquidation) { - expectedChildNodes = [...expectedChildNodes, 'liquidations']; - } - - t.deepEqual(childNodes, expectedChildNodes); -}; - -/** - * @param {object} powers - * @param {Pick} powers.childProcess - * @param {typeof import('node:fs/promises')} powers.fs - */ -const makeProposalExtractor = ({ childProcess, fs }) => { - const getPkgPath = (pkg, fileName = '') => - new URL(`../../../../${pkg}/${fileName}`, import.meta.url).pathname; - - const runPackageScript = async (pkg, name, env) => { - console.warn(pkg, 'running package script:', name); - const pkgPath = getPkgPath(pkg); - return childProcess.execFileSync('yarn', ['run', name], { - cwd: pkgPath, - env, - }); - }; - - const loadJSON = async filePath => - harden(JSON.parse(await fs.readFile(filePath, 'utf8'))); - - // XXX parses the output to find the files but could write them to a path that can be traversed - /** @param {string} txt */ - const parseProposalParts = txt => { - const evals = [ - ...txt.matchAll(/swingset-core-eval (?\S+) (?