From 539fd938109adb61e4563b8c17fa58c4b67e9228 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Fri, 8 Dec 2023 14:54:37 -0800 Subject: [PATCH] chore: remove old upgrade-tests --- .eslintrc.cjs | 8 - packages/deployment/upgrade-test/Dockerfile | 33 -- packages/deployment/upgrade-test/Makefile | 41 --- packages/deployment/upgrade-test/Readme.md | 110 ------- .../agoric-upgrade-13/actions.js | 147 --------- .../agoric-upgrade-13/tools/vat-status.js | 92 ------ .../upgrade-test-scripts/cliHelper.js | 132 -------- .../commonUpgradeHelpers.js | 281 ------------------ .../upgrade-test-scripts/constants.js | 13 - .../upgrade-test-scripts/econHelpers.js | 73 ----- .../upgrade-test-scripts/env_setup.sh | 215 -------------- .../upgrade-test-scripts/package.json | 21 -- .../upgrade-test-scripts/start_to_to.sh | 67 ----- 13 files changed, 1233 deletions(-) delete mode 100644 packages/deployment/upgrade-test/Dockerfile delete mode 100644 packages/deployment/upgrade-test/Makefile delete mode 100644 packages/deployment/upgrade-test/Readme.md delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/actions.js delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/tools/vat-status.js delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/cliHelper.js delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/commonUpgradeHelpers.js delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/constants.js delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/econHelpers.js delete mode 100755 packages/deployment/upgrade-test/upgrade-test-scripts/env_setup.sh delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/package.json delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/start_to_to.sh diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 94fe2b48c345..e481b12e342d 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -120,13 +120,5 @@ module.exports = { project: false, }, }, - { - files: ['packages/**/upgrade-test-scripts/**/*.*js'], - rules: { - // NOTE: This rule is enabled for the repository in general. We turn it - // off for test code for now. - '@jessie.js/safe-await-separator': 'off', - }, - }, ], }; diff --git a/packages/deployment/upgrade-test/Dockerfile b/packages/deployment/upgrade-test/Dockerfile deleted file mode 100644 index 12120ca898b5..000000000000 --- a/packages/deployment/upgrade-test/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -# Defaults -ARG BASE_IMAGE=ghcr.io/agoric/agoric-3-proposals:pr-33 -ARG DEST_IMAGE=ghcr.io/agoric/agoric-sdk:dev - -# TODO different naming scheme for upgrade handler (in app.go) and the image name - -# UPGRADE -FROM ${BASE_IMAGE} as propose-agoric-upgrade-13 -ARG UPGRADE_INFO -ENV THIS_NAME= UPGRADE_TO="agoric-upgrade-13" UPGRADE_INFO=${UPGRADE_INFO} - -WORKDIR /usr/src/agoric-sdk/ -COPY --chmod=755 ./env_setup.sh ./start_to_to.sh ./upgrade-test-scripts/ -SHELL ["/bin/bash", "-c"] -RUN . ./upgrade-test-scripts/start_to_to.sh - -# DEST (TEST) -#this is agoric-upgrade-13 -ARG DEST_IMAGE -FROM ${DEST_IMAGE} as agoric-upgrade-13 -ENV THIS_NAME=agoric-upgrade-13 USE_JS=1 -COPY --from=propose-agoric-upgrade-13 /root/.agoric /root/.agoric -# start-chain boilerplate -WORKDIR /usr/src/agoric-sdk/ -COPY ./env_setup.sh ./start_to_to.sh ./package.json ./*.js ./upgrade-test-scripts/ -RUN cd upgrade-test-scripts && yarn -RUN echo '. /usr/src/agoric-sdk/upgrade-test-scripts/env_setup.sh' >> ~/.bashrc - -COPY ./${THIS_NAME} ./upgrade-test-scripts/${THIS_NAME}/ -SHELL ["/bin/bash", "-c"] -RUN chmod +x ./upgrade-test-scripts/*.sh -# enter image in interactive shell -ENTRYPOINT /usr/src/agoric-sdk/upgrade-test-scripts/start_to_to.sh diff --git a/packages/deployment/upgrade-test/Makefile b/packages/deployment/upgrade-test/Makefile deleted file mode 100644 index 9f85b6881a11..000000000000 --- a/packages/deployment/upgrade-test/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -REPOSITORY = agoric/upgrade-test -# use :dev (latest prerelease image) unless we build local sdk -DEST_IMAGE ?= $(if $(findstring local_sdk,$(MAKECMDGOALS)),ghcr.io/agoric/agoric-sdk:latest,ghcr.io/agoric/agoric-sdk:dev) -TARGET?=agoric-upgrade-13 -dockerLabel?=$(TARGET) -@echo target: $(TARGET) - -local_sdk: - (cd ../ && make docker-build-sdk) - -BUILD = docker build --progress=plain $(BUILD_OPTS) \ - --build-arg DEST_IMAGE=$(DEST_IMAGE) \ - -f Dockerfile upgrade-test-scripts - -propose-agoric-upgrade-13: - $(BUILD) --target propose-agoric-upgrade-13 -t $(REPOSITORY):propose-agoric-upgrade-13 - -agoric-upgrade-13: propose-agoric-upgrade-13 - $(BUILD) --target agoric-upgrade-13 -t $(REPOSITORY):agoric-upgrade-13 - -# build main bootstrap -build: $(TARGET) - -DEBUG ?= SwingSet:ls,SwingSet:vat -RUN = docker run --rm -it \ - -p 26656:26656 -p 26657:26657 -p 1317:1317 \ - -v "$${PWD}:/workspace" \ - -e "DEBUG=$(DEBUG)" - -run: - $(RUN) -e "DEST=1" \ - --entrypoint /usr/src/agoric-sdk/upgrade-test-scripts/start_to_to.sh \ - $(REPOSITORY):$(dockerLabel) - -run_test: - $(RUN) -e "DEST=0" $(REPOSITORY):$(dockerLabel) - -shell: - docker exec -it `docker ps --latest --format '{{json .}}' | jq -r .Names` bash - -.PHONY: local_sdk agoric-upgrade-13 build build_test run diff --git a/packages/deployment/upgrade-test/Readme.md b/packages/deployment/upgrade-test/Readme.md deleted file mode 100644 index 731e0f710c11..000000000000 --- a/packages/deployment/upgrade-test/Readme.md +++ /dev/null @@ -1,110 +0,0 @@ -# Dockerized Chain Upgrade Tester - -This will build an image upgrade of [agoric-3-proposals](https://github.com/Agoric/agoric-3-proposals), a Docker based environment simulating the agoric-3 mainnet chain, using the latest agoric-sdk. - -## Testing - -**To build the upgrade image** - -```shell -make build -``` - -By default pre-releases use the lastest image tagged `dev` in our [container repository](https://github.com/agoric/agoric-sdk/pkgs/container/agoric-sdk). To use -a specific build: - -```shell -DEST_IMAGE=ghcr.io/agoric/agoric-sdk:20230515033839-e56ae7 -``` -To use a build based on local changes: -```shell -# build ghcr.io/agoric/agoric-sdk:latest -make local_sdk build -# or DEST_IMAGE=ghcr.io/agoric/agoric-sdk:latest make build -``` - -**To run the upgrade interactively** - -```shell -make run -``` - -This will start a container with the output of chain start. - -To get a shell: `make shell` - - For more info: https://phase2.github.io/devtools/common-tasks/ssh-into-a-container/ - -The container and chain will halt once you detach from the session. - -### Troubleshooting -If you get an error about port 26656 already in use, you have a local chain running on your OS. - -If you run into other problems, you might have a local `agoric-sdk:latest` that -is stale. Either `make local_sdk` or delete your local image so Docker pulls -from the repository instead. - -If you lose the connection and want to get back, -```sh -# find the container id -docker ps -# reattach using the auto-generated goofy name -docker attach sweet_edison -``` - -**To pass specific `software-upgrade --upgrade-info`** - -```shell -json='{"some":"json","here":123}' -make build BUILD_OPTS="--build-arg UPGRADE_INFO='$json'" -``` - -Search this directory for `UPGRADE_INFO` if you want to see how it is plumbed -through. - -**To test CLI** - -You can point your local CLI tools to the chain running in Docker. Our Docker config binds on the same port (26656) as running a local chain. So you can use the agoric-cli commands on the Docker chain the same way. But note that the Cosmos account keys will be different from in your dev keyring. - -If when reattaching you get a log tail, you need to start a new TTY (with the container name). -```sh -docker exec -it sweet_edison bash -``` - -or just use this helper, -``` -make shell -``` - - -**To test GUI** - -To make the wallet ui talk to your local chain, set the network config to -`https://local.agoric.net/network-config` - -## Development - -When you exit and run again, the container will be a fresh state. - -By default targets that use "agoric-sdk:latest" will source from CI builds. To use your local checkout of agoric-sdk inside Docker run, - -```shell -make local_sdk -``` -Builds an image: ghcr.io/agoric/agoric-sdk:latest that will be used by all your builds. - -That will produce an image tagged agoric-sdk:latest in your local resolution. (Then run `make build run` again.) - -For more details about the docker upgrade test framework, refer to the [agoric-3-proposals](https://github.com/Agoric/agoric-3-proposals) repository. - -### IDE - -Some IDEs support connecting to a running container. For VS Code you can use [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) to connect to a run above. Then you can edit the filesystem using the IDE. Once the workspace opens, you have to add a folder. E.g. `/usr/src/agoric-sdk/packages/agoric-cli/` for tweaking agoric-cli (without a rebuild of SDK). -Note that whatever changes you make within the running container will be lost when you terminate it. Use this just for iterating and be sure to copy any changes you want back to your real workspace. - -# TODO -- [X] make the Docker test environment log verbosely (agd start is just printing "block N" begin, commit) -- [ ] a target like `local_sdk` that just copies the local filesystem, without a full rebuild -- [ ] alternately, mount the local agoric-sdk in the container -- [ ] provide a utility to import the Docker's GOV123 keys into a local keyring - diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/actions.js b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/actions.js deleted file mode 100644 index 94af68fdb129..000000000000 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/actions.js +++ /dev/null @@ -1,147 +0,0 @@ -import { promises as fs } from 'fs'; -import * as path from 'path'; -import { dirname } from 'path'; -import { fileURLToPath } from 'url'; -import { getUser, voteLatestProposalAndWait } from '../commonUpgradeHelpers.js'; -import { CHAINID, GOV1ADDR, HOME, VALIDATORADDR } from '../constants.js'; -import { agd, bundleSource } from '../cliHelper.js'; - -const directoryName = dirname(fileURLToPath(import.meta.url)); - -export const addUser = async user => { - const userKeyData = await agd.keys('add', user, '--keyring-backend=test'); - await fs.writeFile(`${HOME}/.agoric/${user}.key`, userKeyData.mnemonic); - - const userAddress = await getUser(user); - return userAddress; -}; - -export const getISTBalance = async (addr, denom = 'uist', unit = 1_000_000) => { - const coins = await agd.query('bank', 'balances', addr); - const coin = coins.balances.find(a => a.denom === denom); - return Number(coin.amount) / unit; -}; - -export const installBundles = async bundlesData => { - const bundleIds = {}; - - for (const bundleData of bundlesData) { - const bundleFilePath = await bundleSource( - bundleData.filePath, - bundleData.name, - ); - - const bundleJSONData = await fs.readFile(bundleFilePath, 'binary'); - - const bundle = JSON.parse(bundleJSONData); - bundleIds[bundleData.name] = bundle.endoZipBase64Sha512; - - await agd.tx( - 'swingset', - 'install-bundle', - `@${bundleFilePath}`, - '--from', - GOV1ADDR, - '--keyring-backend=test', - '--gas=auto', - '--chain-id', - CHAINID, - '-bblock', - '--yes', - ); - } - - return bundleIds; -}; - -export const prepForCoreEval = async (filePath, constants) => { - let sourceFileData = await fs.readFile(filePath, 'binary'); - - for (const constant in constants) { - if (Object.prototype.hasOwnProperty.call(constants, constant)) { - sourceFileData = sourceFileData.replace( - `##${constant}##`, - constants[constant], - ); - } - } - - const newFilePath = `/tmp/${path.basename(filePath)}`; - await fs.writeFile(newFilePath, sourceFileData); - return newFilePath; -}; - -export const runProber = async bundleId => { - const proberScriptPath = path.join( - directoryName, - 'zoe-full-upgrade', - 'run-prober-script.js', - ); - const proberUpgradePermitPath = path.join( - directoryName, - 'zoe-full-upgrade', - 'zcf-upgrade-permit.json', - ); - const filePath = await prepForCoreEval(proberScriptPath, { - PROBER_BUNDLE_ID: `b1-${bundleId}`, - }); - await agd.tx( - 'gov', - 'submit-proposal', - 'swingset-core-eval', - proberUpgradePermitPath, - filePath, - `--title="Run Prober"`, - `--description="run prober"`, - '--deposit=10000000ubld', - '--from', - VALIDATORADDR, - '--keyring-backend=test', - '--gas=auto', - '--gas-adjustment=1.2', - '--chain-id', - CHAINID, - '-bblock', - '--yes', - ); - - await voteLatestProposalAndWait(); -}; - -export const runZcfUpgrade = async (zcfBundleId, zoeBundleId) => { - const zcfScriptPath = path.join( - directoryName, - 'zoe-full-upgrade', - 'zcf-upgrade-script.js', - ); - const zcfUpgradePermitPath = path.join( - directoryName, - 'zoe-full-upgrade', - 'zcf-upgrade-permit.json', - ); - const filePath = await prepForCoreEval(zcfScriptPath, { - ZCF_BUNDLE_ID: `b1-${zcfBundleId}`, - ZOE_BUNDLE_ID: `b1-${zoeBundleId}`, - }); - await agd.tx( - 'gov', - 'submit-proposal', - 'swingset-core-eval', - zcfUpgradePermitPath, - filePath, - `--title="Run Prober"`, - `--description="run prober"`, - '--deposit=10000000ubld', - '--from', - VALIDATORADDR, - '--keyring-backend=test', - '--gas=auto', - '--gas-adjustment=1.2', - '--chain-id', - CHAINID, - '-bblock', - '--yes', - ); - - return voteLatestProposalAndWait(); -}; diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/tools/vat-status.js b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/tools/vat-status.js deleted file mode 100644 index 81518a536098..000000000000 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/tools/vat-status.js +++ /dev/null @@ -1,92 +0,0 @@ -// @ts-check -import dbOpenAmbient from 'better-sqlite3'; -import { HOME } from '../../constants.js'; - -/** - * @file look up vat incarnation from kernel DB - * @see {getIncarnation} - */ - -const swingstorePath = '~/.agoric/data/agoric/swingstore.sqlite'; - -/** - * SQL short-hand - * - * @param {import('better-sqlite3').Database} db - */ -const dbTool = db => { - const prepare = (strings, ...params) => { - const dml = strings.join('?'); - return { stmt: db.prepare(dml), params }; - }; - const sql = (strings, ...args) => { - const { stmt, params } = prepare(strings, ...args); - return stmt.all(...params); - }; - sql.get = (strings, ...args) => { - const { stmt, params } = prepare(strings, ...args); - return stmt.get(...params); - }; - return sql; -}; - -/** - * @param {import('better-sqlite3').Database} db - */ -const makeSwingstore = db => { - const sql = dbTool(db); - - /** @param {string} key */ - const kvGet = key => sql.get`select * from kvStore where key = ${key}`.value; - /** @param {string} key */ - const kvGetJSON = key => JSON.parse(kvGet(key)); - - /** @param {string} vatID */ - const lookupVat = vatID => { - return Object.freeze({ - source: () => kvGetJSON(`${vatID}.source`), - options: () => kvGetJSON(`${vatID}.options`), - currentSpan: () => - sql.get`select * from transcriptSpans where isCurrent = 1 and vatID = ${vatID}`, - }); - }; - - return Object.freeze({ - /** @param {string} vatName */ - findVat: vatName => { - /** @type {string[]} */ - const dynamicIDs = kvGetJSON('vat.dynamicIDs'); - const targetVat = dynamicIDs.find( - vatID => lookupVat(vatID).options().name === vatName, - ); - if (!targetVat) throw Error(vatName); - return targetVat; - }, - lookupVat, - }); -}; - -/** @type {(val: T | undefined) => T} */ -const NonNullish = val => { - if (!val) throw Error('required'); - return val; -}; - -/** - * @param {string} vatName - */ -export const getIncarnation = async vatName => { - const fullPath = swingstorePath.replace(/^~/, NonNullish(HOME)); - const kStore = makeSwingstore(dbOpenAmbient(fullPath, { readonly: true })); - - const vatID = kStore.findVat(vatName); - const vatInfo = kStore.lookupVat(vatID); - - const source = vatInfo.source(); - const { incarnation } = vatInfo.currentSpan(); - - // misc info to stderr - console.error(JSON.stringify({ vatName, vatID, incarnation, ...source })); - - return incarnation; -}; diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/cliHelper.js b/packages/deployment/upgrade-test/upgrade-test-scripts/cliHelper.js deleted file mode 100644 index 8a89a19241a5..000000000000 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/cliHelper.js +++ /dev/null @@ -1,132 +0,0 @@ -/* eslint-disable @jessie.js/safe-await-separator */ -import { $, execaCommand } from 'execa'; - -const BINARY = 'agd'; - -export const executeCommand = async (command, params, options = {}) => { - const { stdout } = await execaCommand( - `${command} ${params.join(' ')}`, - options, - ); - return stdout; -}; - -export const agd = { - query: async (...params) => { - const newParams = ['query', ...params, '-o json']; - const data = await executeCommand(BINARY, newParams); - return JSON.parse(data); - }, - tx: async (...params) => { - const newParams = ['tx', ...params, '-o json']; - const data = await executeCommand(BINARY, newParams, { shell: true }); - return JSON.parse(data); - }, - keys: async (...params) => { - let newParams = ['keys', ...params]; - let shouldParse = true; - - if (params.includes('show')) { - if (params.includes('-a') || params.includes('-address')) { - shouldParse = false; - } - } - - if (shouldParse) { - newParams = [...newParams, '--output json']; - } - - const data = await executeCommand(BINARY, newParams, { input: 'Y' }); - if (!shouldParse) { - return data; - } - - return JSON.parse(data); - }, - export: async (...params) => { - const newParams = ['export', ...params]; - const data = await executeCommand(BINARY, newParams); - return JSON.parse(data); - }, -}; - -export const agoric = { - follow: async (...params) => { - let newParams = ['follow', ...params]; - let parseJson = false; - - if (!params.includes('-o')) { - newParams = [...newParams, '-o json']; - parseJson = true; - } - const data = await executeCommand('agoric', newParams); - - if (parseJson) { - return JSON.parse(data); - } - - return data; - }, - wallet: async (...params) => { - const newParams = ['wallet', ...params]; - return executeCommand('agoric', newParams); - }, - run: async (...params) => { - const newParams = ['run', ...params]; - return executeCommand('agoric', newParams); - }, -}; - -export const { stdout: agopsLocation } = await $({ - shell: true, - cwd: '/usr/src/agoric-sdk', -})`yarn bin agops`; - -export const agops = { - vaults: async (...params) => { - const newParams = ['vaults', ...params]; - - const result = await executeCommand(agopsLocation, newParams); - - if (params[0] === 'list') { - if (result === '') return []; - - return result.split('\n'); - } - - return result; - }, - ec: async (...params) => { - const newParams = ['ec', ...params]; - return executeCommand(agopsLocation, newParams); - }, - oracle: async (...params) => { - const newParams = ['oracle', ...params]; - return executeCommand(agopsLocation, newParams); - }, - perf: async (...params) => { - const newParams = ['perf', ...params]; - return executeCommand(agopsLocation, newParams); - }, - auctioneer: async (...params) => { - const newParams = ['auctioneer', ...params]; - return executeCommand(agopsLocation, newParams); - }, -}; - -export const { stdout: bundleSourceLocation } = await $({ - shell: true, - cwd: '/usr/src/agoric-sdk', -})`yarn bin bundle-source`; - -/** - * @param {string} filePath - * @param {string} bundleName - * @returns {Promise} Returns the filepath of the bundle - */ -export const bundleSource = async (filePath, bundleName) => { - const output = - await $`${bundleSourceLocation} --cache-json /tmp ${filePath} ${bundleName}`; - console.log(output.stderr); - return `/tmp/bundle-${bundleName}.json`; -}; diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/commonUpgradeHelpers.js b/packages/deployment/upgrade-test/upgrade-test-scripts/commonUpgradeHelpers.js deleted file mode 100644 index 2c7945d520ae..000000000000 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/commonUpgradeHelpers.js +++ /dev/null @@ -1,281 +0,0 @@ -/* eslint-disable @jessie.js/safe-await-separator */ -import { $ } from 'execa'; -import { promises as fs } from 'fs'; -import * as path from 'path'; -import { agd, agoric, agops } from './cliHelper.js'; -import { CHAINID, VALIDATORADDR } from './constants.js'; - -const waitForBootstrap = async () => { - const endpoint = 'localhost'; - // eslint-disable-next-line no-constant-condition - while (true) { - const { stdout: json } = await $({ - reject: false, - })`curl -s --fail -m 15 ${`${endpoint}:26657/status`}`; - - if (json.length === 0) { - continue; - } - - const data = JSON.parse(json); - - if (data.jsonrpc !== '2.0') { - continue; - } - - const lastHeight = data.result.sync_info.latest_block_height; - - if (lastHeight !== '1') { - return lastHeight; - } - - // eslint-disable-next-line no-undef - await new Promise(r => setTimeout(r, 2000)); - } -}; - -export const waitForBlock = async (times = 1) => { - console.log(times); - let time = 0; - while (time < times) { - const block1 = await waitForBootstrap(); - // eslint-disable-next-line no-constant-condition - while (true) { - const block2 = await waitForBootstrap(); - - if (block1 !== block2) { - console.log('block produced'); - break; - } - - // eslint-disable-next-line no-undef - await new Promise(r => setTimeout(r, 1000)); - } - time += 1; - } -}; - -export const provisionSmartWallet = async (address, amount) => { - console.log(`funding ${address}`); - await agd.tx( - 'bank', - 'send', - 'validator', - address, - amount, - '-y', - '--keyring-backend=test', - `--chain-id="${CHAINID}"`, - ); - await waitForBlock(); - - console.log(`provisioning ${address}`); - await agd.tx( - 'swingset', - 'provision-one', - 'my-wallet', - address, - 'SMART_WALLET', - '--keyring-backend=test', - '-y', - `--chain-id="${CHAINID}"`, - `--from="${address}"`, - ); - - await waitForBlock(2); - console.log(await agoric.wallet('show', `--from ${address}`)); -}; - -export const newOfferId = async () => { - const { stdout: date } = await $`date +${'%s%3M'}`; - // eslint-disable-next-line no-undef - await new Promise(r => setTimeout(r, 1000)); - - return date; -}; - -export const mkTemp = async template => { - const { stdout: data } = await $({ - shell: true, - })`mktemp -t ${template}`; - return data; -}; - -export const calculateWalletState = async addr => { - const result = await agoric.follow( - '-lF', - `:published.wallet.${addr}`, - '-o', - 'text', - ); - - const body = JSON.parse(result).body; - let state = body; - - if (body.includes('@qclass')) { - state = 'old'; - } else if (body.includes('#{}')) { - state = 'upgraded'; - } else if (body.includes('#')) { - state = 'revived'; - } - - return state; -}; - -export const executeOffer = async (address, offerPromise) => { - const offerPath = await mkTemp('agops.XXX'); - const offer = await offerPromise; - await fs.writeFile(offerPath, offer); - - await agops.perf( - 'satisfaction', - '--from', - address, - '--executeOffer', - offerPath, - '--keyring-backend=test', - ); -}; - -export const getUser = async user => { - return agd.keys('show', user, '-a', '--keyring-backend=test'); -}; - -export const voteLatestProposalAndWait = async () => { - await waitForBlock(); - const proposalsData = await agd.query('gov', 'proposals'); - const lastProposalId = proposalsData.proposals.at(-1).proposal_id; - - await waitForBlock(); - - await agd.tx( - 'gov', - 'deposit', - lastProposalId, - '50000000ubld', - '--from', - VALIDATORADDR, - `--chain-id=${CHAINID}`, - '--yes', - '--keyring-backend', - 'test', - ); - - await waitForBlock(); - - await agd.tx( - 'gov', - 'vote', - lastProposalId, - 'yes', - '--from', - VALIDATORADDR, - `--chain-id=${CHAINID}`, - '--yes', - '--keyring-backend', - 'test', - ); - - let info = {}; - for ( - ; - info.status !== 'PROPOSAL_STATUS_REJECTED' && - info.status !== 'PROPOSAL_STATUS_PASSED'; - await waitForBlock() - ) { - info = await agd.query('gov', 'proposal', lastProposalId); - console.log( - `Waiting for proposal ${lastProposalId} to pass (status=${info.status})`, - ); - } - return info; -}; - -const Fail = (template, ...args) => { - throw Error(String.raw(template, ...args.map(val => String(val)))); -}; - -/** - * Parse output of `agoric run proposal-builder.js` - * - * @param {string} txt - * - * adapted from packages/boot/test/bootstrapTests/supports.js - */ -const parseProposalParts = txt => { - const evals = [ - ...txt.matchAll(/swingset-core-eval (?\S+) (?