Skip to content

Commit

Permalink
Merge pull request #8237 from Agoric/agoric-upgrade-11-js
Browse files Browse the repository at this point in the history
Agoric Upgrade 11 Tests -> JS
  • Loading branch information
mergify[bot] authored and mhofman committed Nov 9, 2023
2 parents 1b7e73f + 0a3ac9a commit a852db9
Show file tree
Hide file tree
Showing 37 changed files with 846 additions and 948 deletions.
23 changes: 19 additions & 4 deletions packages/deployment/upgrade-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ ARG BOOTSTRAP_MODE
ENV THIS_NAME=agoric-upgrade-10 USE_JS=1 BOOTSTRAP_MODE=${BOOTSTRAP_MODE}

WORKDIR /usr/src/agoric-sdk/
COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./package.json ./*.mjs ./upgrade-test-scripts/
COPY ./bash_entrypoint.sh ./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}/
COPY --from=agoric-upgrade-9 /root/.agoric /root/.agoric
RUN chmod +x ./upgrade-test-scripts/*.sh
Expand All @@ -97,6 +100,9 @@ ARG BOOTSTRAP_MODE UPGRADE_INFO_11
ENV THIS_NAME=propose-agoric-upgrade-11 UPGRADE_TO=agoric-upgrade-11 UPGRADE_INFO=${UPGRADE_INFO_11} BOOTSTRAP_MODE=${BOOTSTRAP_MODE}
WORKDIR /usr/src/agoric-sdk/
COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./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}/
COPY --from=agoric-upgrade-10 /root/.agoric /root/.agoric
RUN chmod +x ./upgrade-test-scripts/*.sh
Expand All @@ -108,10 +114,13 @@ RUN . ./upgrade-test-scripts/start_to_to.sh
ARG DEST_IMAGE
FROM ghcr.io/agoric/agoric-sdk:36 as agoric-upgrade-11
ARG BOOTSTRAP_MODE
ENV THIS_NAME=agoric-upgrade-11 BOOTSTRAP_MODE=${BOOTSTRAP_MODE}
ENV THIS_NAME=agoric-upgrade-11 BOOTSTRAP_MODE=${BOOTSTRAP_MODE} USE_JS=1
# start-chain boilerplate
WORKDIR /usr/src/agoric-sdk/
COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./upgrade-test-scripts/
COPY ./bash_entrypoint.sh ./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}/
COPY --from=propose-agoric-upgrade-11 /root/.agoric /root/.agoric
RUN chmod +x ./upgrade-test-scripts/*.sh
Expand All @@ -128,6 +137,9 @@ COPY --from=agoric-upgrade-11 /root/.agoric /root/.agoric
# start-chain boilerplate
WORKDIR /usr/src/agoric-sdk/
COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./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}/
RUN chmod +x ./upgrade-test-scripts/*.sh
SHELL ["/bin/bash", "-c"]
Expand All @@ -142,7 +154,10 @@ ENV THIS_NAME=agoric-upgrade-12 BOOTSTRAP_MODE=${BOOTSTRAP_MODE}
COPY --from=propose-agoric-upgrade-12 /root/.agoric /root/.agoric
# start-chain boilerplate
WORKDIR /usr/src/agoric-sdk/
COPY ./bash_entrypoint.sh ./env_setup.sh ./start_to_to.sh ./package.json ./*.mjs ./upgrade-test-scripts/
COPY ./bash_entrypoint.sh ./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}/
RUN apt install -y tmux
SHELL ["/bin/bash", "-c"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { promises as fs } from 'fs';
import assert from 'assert';

import {
waitForBlock,
provisionSmartWallet,
getUser,
executeOffer,
} from './upgradeHelpers.mjs';
import {
agd,
agoric,
agops,
agopsLocation,
executeCommand,
} from '../cliHelper.mjs';
} from '../cliHelper.js';
import {
HOME,
ATOM_DENOM,
GOV1ADDR,
GOV2ADDR,
GOV3ADDR,
} from '../constants.mjs';
} from '../constants.js';
import {
waitForBlock,
executeOffer,
getUser,
provisionSmartWallet,
} from '../commonUpgradeHelpers.js';

const govAccounts = [GOV1ADDR, GOV2ADDR, GOV3ADDR];

Expand Down Expand Up @@ -265,58 +265,6 @@ export const raiseDebtCeiling = async address => {
await new Promise(r => setTimeout(r, 65000));
};

export const openVault = (address, mint, collateral) => {
return executeOffer(
address,
agops.vaults('open', '--wantMinted', mint, '--giveCollateral', collateral),
);
};

export const adjustVault = (address, vaultId, vaultParams) => {
let params = [
'adjust',
'--vaultId',
vaultId,
'--from',
address,
' --keyring-backend=test',
];

if ('wantCollateral' in vaultParams) {
params = [...params, '--wantCollateral', vaultParams.wantCollateral];
}

if ('wantMinted' in vaultParams) {
params = [...params, '--wantMinted', vaultParams.wantMinted];
}

if ('giveCollateral' in vaultParams) {
params = [...params, '--giveCollateral', vaultParams.giveCollateral];
}

if ('giveMinted' in vaultParams) {
params = [...params, '--giveMinted', vaultParams.giveMinted];
}

return executeOffer(address, agops.vaults(...params));
};

export const closeVault = (address, vaultId, mint) => {
return executeOffer(
address,
agops.vaults(
'close',
'--vaultId',
vaultId,
'--giveMinted',
mint,
'--from',
address,
'--keyring-backend=test',
),
);
};

export const pushPrice = (oracles, price = 10.0) => {
console.log(`ACTIONS pushPrice ${price}`);
const promiseArray = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import test from 'ava';

import {
waitForBlock,
submitDeliverInbound,
getUser,
newOfferId,
} from './upgradeHelpers.mjs';
import {
provisionWallet,
implementNewAuctionParams,
raiseDebtCeiling,
openVault,
adjustVault,
closeVault,
pushPrice,
} from './actions.mjs';
import { agd, agoric, agops } from '../cliHelper.mjs';
import { GOV1ADDR, GOV2ADDR } from '../constants.mjs';
} from './actions.js';
import { agd, agoric, agops } from '../cliHelper.js';
import { GOV1ADDR, GOV2ADDR } from '../constants.js';
import { getUser, newOfferId, waitForBlock } from '../commonUpgradeHelpers.js';
import { submitDeliverInbound } from './upgradeHelpers.js';
import { openVault, adjustVault, closeVault } from '../econHelpers.js';

const START_FREQUENCY = 600; // StartFrequency: 600s (auction runs every 10m)
const CLOCK_STEP = 20; // ClockStep: 20s (ensures auction completes in time)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'ava';

import { agd, agoric } from '../cliHelper.mjs';
import { GOV1ADDR, GOV2ADDR, GOV3ADDR, USER1ADDR } from '../constants.mjs';
import { calculateWalletState } from './upgradeHelpers.mjs';
import { agd, agoric } from '../cliHelper.js';
import { GOV1ADDR, GOV2ADDR, GOV3ADDR, USER1ADDR } from '../constants.js';
import { calculateWalletState } from '../commonUpgradeHelpers.js';

test('DeliverInbound from un-provisioned account is discarded', async t => {
const result = await agd.query('swingset', 'mailbox', USER1ADDR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import test from 'ava';

import { promises as fs } from 'fs';

import { waitForBlock, getUser } from './upgradeHelpers.mjs';
import { agd, agoric, agops } from '../cliHelper.mjs';
import { agd, agoric, agops } from '../cliHelper.js';

import {
GOV1ADDR,
GOV2ADDR,
GOV3ADDR,
BOOTSTRAP_MODE,
PSM_PAIR,
} from '../constants.mjs';

import { openVault } from './actions.mjs';
} from '../constants.js';
import { openVault } from '../econHelpers.js';
import { getUser, waitForBlock } from '../commonUpgradeHelpers.js';

test.before(async () => {
console.log('Wait for upgrade to settle');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@ import {
VALIDATORADDR,
USER1ADDR,
CHAINID,
HOME,
} from '../constants.mjs';
} from '../constants.js';

import { agd, agops } from '../cliHelper.mjs';

export * from '../coreUpgradeHelpers.mjs';

export const getUser = async user => {
return agd.keys('show', user, '-a', '--keyring-backend=test');
};
import { agd } from '../cliHelper.js';
import { getUser } from '../commonUpgradeHelpers.js';

export const printKeys = async () => {
console.log('========== GOVERNANCE KEYS ==========');
Expand Down
Empty file.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import test from 'ava';

import { agoric, agops } from '../cliHelper.js';
import { GOV1ADDR } from '../constants.js';
import { openVault, adjustVault, closeVault } from '../econHelpers.js';

test.serial('Open Vaults', async t => {
const currentVaults = await agops.vaults('list', '--from', GOV1ADDR);
t.is(currentVaults.length, 2);

await openVault(GOV1ADDR, 7, 11);
await adjustVault(GOV1ADDR, 'vault3', { giveMinted: 1.5 });
await adjustVault(GOV1ADDR, 'vault3', { giveCollateral: 2.0 });
await closeVault(GOV1ADDR, 'vault3', 5.75);

const vault3 = await agoric.follow(
'-lF',
':published.vaultFactory.managers.manager0.vaults.vault3',
);
t.is(vault3.vaultState, 'closed');
t.is(vault3.locked.value, '0');
t.is(vault3.debtSnapshot.debt.value, '0');
});
Loading

0 comments on commit a852db9

Please sign in to comment.