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 index 6ce8bbfc1822..94af68fdb129 100644 --- 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 @@ -2,12 +2,26 @@ import { promises as fs } from 'fs'; import * as path from 'path'; import { dirname } from 'path'; import { fileURLToPath } from 'url'; -import { voteLatestProposalAndWait } from '../commonUpgradeHelpers.js'; -import { CHAINID, GOV1ADDR, VALIDATORADDR } from '../constants.js'; +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 = {}; diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/actions.test.js b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/actions.test.js index 823296571d06..3ebc09f7f10c 100644 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/actions.test.js +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/actions.test.js @@ -1,21 +1,45 @@ import test from 'ava'; -import { agops } from '../cliHelper.js'; -import { GOV1ADDR } from '../constants.js'; -import { adjustVault, closeVault, mintIST, openVault } from '../econHelpers.js'; +import { agd } from '../cliHelper.js'; +import { ATOM_DENOM, CHAINID, GOV1ADDR } from '../constants.js'; +import { addUser, getISTBalance } from './actions.js'; +import { mintIST, openVault } from '../econHelpers.js'; +import { waitForBlock } from '../commonUpgradeHelpers.js'; test.before(async t => { await mintIST(GOV1ADDR, 12340000000, 10000, 2000); + + await waitForBlock(2); + const userAddress = await addUser('user-auto'); + await agd.tx( + 'bank', + 'send', + 'gov1', + userAddress, + `1000000uist,2100000000${ATOM_DENOM}`, + '--from', + GOV1ADDR, + '--chain-id', + CHAINID, + '--keyring-backend', + 'test', + '--yes', + ); + t.context = { userAddress }; + await waitForBlock(2); }); -test.skip('Open Vaults', async t => { - const currentVaults = await agops.vaults('list', '--from', GOV1ADDR); - t.is(currentVaults.length, 5); +test('Open Vaults with auto-provisioned wallet', async t => { + const { userAddress } = /** @type {{userAddress: string}} */ (t.context); + t.is(await getISTBalance(userAddress), 1); + + const ATOMGiven = 2000; + const ISTWanted = 400; + await openVault(userAddress, ISTWanted, ATOMGiven); + + await waitForBlock(2); - // TODO get as return value from openVault - const vaultId = 'vault6'; - await openVault(GOV1ADDR, 7, 11); - await adjustVault(GOV1ADDR, vaultId, { giveMinted: 1.5 }); - await adjustVault(GOV1ADDR, vaultId, { giveCollateral: 2.0 }); - await closeVault(GOV1ADDR, vaultId, 5.75); + const newISTBalance = await getISTBalance(userAddress); + console.log('New IST Balance in u13 account:', newISTBalance); + t.true(newISTBalance >= ISTWanted, 'Got the wanted IST'); }); diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/econHelpers.js b/packages/deployment/upgrade-test/upgrade-test-scripts/econHelpers.js index ced1dff0bb8e..c4dbf759efd3 100644 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/econHelpers.js +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/econHelpers.js @@ -69,5 +69,5 @@ export const mintIST = async (addr, sendValue, giveCollateral, wantMinted) => { 'test', '--yes', ); - await openVault(addr, giveCollateral, wantMinted); + await openVault(addr, wantMinted, giveCollateral); }; diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/env_setup.sh b/packages/deployment/upgrade-test/upgrade-test-scripts/env_setup.sh index e1b2ee402c59..c250fa020c56 100755 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/env_setup.sh +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/env_setup.sh @@ -192,16 +192,11 @@ newOfferId() { printKeys() { echo "========== GOVERNANCE KEYS ==========" - echo "gov1: $GOV1ADDR" - cat ~/.agoric/gov1.key || true - echo "gov2: $GOV2ADDR" - cat ~/.agoric/gov2.key || true - echo "gov3: $GOV3ADDR" - cat ~/.agoric/gov3.key || true - echo "validator: $VALIDATORADDR" - cat ~/.agoric/validator.key || true - echo "user1: $USER1ADDR" - cat ~/.agoric/user1.key || true + for i in ~/.agoric/*.key; do + name=$(basename $i .key) + echo "$name:"$'\t'$(agd keys add $name --dry-run --recover --keyring-backend=test --output=json < $i | jq -r .address) || true + echo $'\t'$(cat $i) + done echo "========== GOVERNANCE KEYS ==========" }