Skip to content

Commit

Permalink
Repair u19 tests in a3p-integration (#10947)
Browse files Browse the repository at this point in the history
closes: #10901

## Description

In clean-up after upgrade-18, the upgrade 19 tests were left in an incomplete state. This ensures they are running again.

### Security Considerations

Not a security issue.

### Scaling Considerations

No implications.

### Documentation Considerations

N/A

### Testing and Upgrade Considerations

Our practice is to have `a3p-integration` represent upcoming upgrades to test them in the context of previous upgrades on chain. There were issues getting the U19 tests in proper condition before U18, and so revising them once U18 had been added to the chain was a little wonky. After this PR, The tests demonstrate that U19 will succeed, and the acceptance tests will verify the state of the chain after the upgrade.
  • Loading branch information
mergify[bot] authored Feb 11, 2025
2 parents 6504dc6 + 05245ca commit 46061c3
Show file tree
Hide file tree
Showing 41 changed files with 283 additions and 464 deletions.
10 changes: 1 addition & 9 deletions a3p-integration/proposals/n:upgrade-next/.gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
replaceFeeDistributor/
addUsdLemons/
addUsdOlives/
upgradeProvisionPool/
upgradeAgoricNames/
publishTestInfo/
upgrade-mintHolder/
upgradeAssetReserve/
upgradePSM/
test/generated/
2 changes: 2 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/eval.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -euo pipefail

# evaluate the proposals in the /submission/ directory

echo "UPGRADE-19 Running proposal declared in package.json"
Expand Down
13 changes: 3 additions & 10 deletions a3p-integration/proposals/n:upgrade-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,9 @@
},
"type": "Software Upgrade Proposal",
"sdk-generate": [
"testing/replace-feeDistributor-short.js replaceFeeDistributor",
"testing/add-USD-LEMONS.js addUsdLemons",
"vats/upgrade-provisionPool.js upgradeProvisionPool",
"vats/upgrade-asset-reserve.js upgradeAssetReserve",
"vats/upgrade-psm.js upgradePSM",
"vats/upgrade-paRegistry.js",
"vats/upgrade-agoricNames.js agoricNamesCoreEvals/upgradeAgoricNames",
"testing/add-USD-OLIVES.js agoricNamesCoreEvals/addUsdOlives",
"testing/publish-test-info.js agoricNamesCoreEvals/publishTestInfo",
"vats/upgrade-mintHolder.js upgrade-mintHolder A3P_INTEGRATION"
"testing/add-USD-LEMONS.js test/generated/addUsdLemons",
"testing/add-USD-OLIVES.js test/generated/agoricNamesCoreEvals/addUsdOlives",
"testing/publish-test-info.js test/generated/agoricNamesCoreEvals/publishTestInfo"
]
},
"type": "module",
Expand Down
81 changes: 0 additions & 81 deletions a3p-integration/proposals/n:upgrade-next/psm.test.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
/* eslint-env node */

import {
agoric,
evalBundles,
getDetailsMatchingVats,
getISTBalance,
} from '@agoric/synthetic-chain';
import { makeVstorageKit, retryUntilCondition } from '@agoric/client-utils';
import { agoric, evalBundles, getISTBalance } from '@agoric/synthetic-chain';
import { makeVstorageKit } from '@agoric/client-utils';
import { readFile, writeFile } from 'node:fs/promises';
import { psmSwap, snapshotAgoricNames, tryISTBalances } from './psm-lib.js';

Expand Down Expand Up @@ -41,7 +36,10 @@ export const getAssetList = async labelList => {

// Determine the assets to consider based on labelList
const assetsToConsider =
labelList || Object.values(vbankAssets).map(asset => asset.issuerName);
labelList ||
Object.values(vbankAssets)
.map(asset => asset.issuerName)
.filter(Boolean); // testvbankAsset can be malformed.

for (const label of assetsToConsider) {
if (label === 'IST') {
Expand All @@ -67,6 +65,7 @@ export const mintPayment = async (t, address, assetList, value) => {

for (const asset of assetList) {
const { label, denom } = asset;

const scaled = BigInt(parseInt(value, 10) * 1_000_000).toString();

await replaceTemplateValuesInFile(`${SUBMISSION_DIR}/send-script`, {
Expand Down Expand Up @@ -137,40 +136,3 @@ export const swap = async (t, address, assetList, want) => {
t.is(anchorBalanceAfter, anchorBalanceBefore - want);
}
};

const getIncarnationForAllVats = async assetList => {
const vatsIncarnation = {};

for (const asset of assetList) {
const { label, mintHolderVat } = asset;
const matchingVats = await getDetailsMatchingVats(label);
const expectedVat = matchingVats.find(vat => vat.vatName === mintHolderVat);
vatsIncarnation[label] = expectedVat.incarnation;
}
assert(Object.keys(vatsIncarnation).length === assetList.length);

return vatsIncarnation;
};

const checkVatsUpgraded = (before, current) => {
for (const vatLabel in before) {
if (current[vatLabel] !== before[vatLabel] + 1) {
console.log(`${vatLabel} upgrade failed. `);
return false;
}
}
return true;
};

export const upgradeMintHolder = async (submissionPath, assetList) => {
const before = await getIncarnationForAllVats(assetList);

await evalBundles(submissionPath);

return retryUntilCondition(
async () => getIncarnationForAllVats(assetList),
current => checkVatsUpgraded(before, current),
`mintHolder upgrade not processed yet`,
{ setTimeout, retryIntervalMs: 5000, maxRetries: 15 },
);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-env node */
// from z:acceptance/test-lib/psm-lib.js
// from z:acceptance/lib/psm-lib.js

import { execa } from 'execa';
import { getNetworkConfig } from 'agoric/src/helpers.js';
Expand Down
15 changes: 8 additions & 7 deletions a3p-integration/proposals/n:upgrade-next/test.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash

yarn ava initial.test.js
yarn ava replaceFeeDistributor.test.js
yarn ava mintHolder.test.js
yarn ava provisionPool.test.js
set -euo pipefail

# segregate so changing these does not invalidate the proposal image
# à la https://github.com/Agoric/agoric-3-proposals/pull/213
cd test

yarn ava agoricNames.test.js
GLOBIGNORE=initial.test.js
yarn ava initial.test.js

yarn ava assetReserve.test.js
yarn ava psm.test.js
yarn ava *.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,14 @@ import {
extractBalance,
psmSwap,
tryISTBalances,
} from './test-lib/psm-lib.js';
import { getBalances, listVaults } from './test-lib/utils.js';
import { walletUtils } from './test-lib/index.js';
} from '../test-lib/psm-lib.js';
import { getBalances, listVaults } from '../test-lib/utils.js';
import { walletUtils } from '../test-lib/index.js';

const AGORIC_NAMES_UPGRADE_DIR = 'agoricNamesCoreEvals/upgradeAgoricNames';
const WRITE_AGORIC_NAMES_DIR = 'agoricNamesCoreEvals/writeToAgoricNames';
const ADD_USD_OLIVES_DIR = 'agoricNamesCoreEvals/addUsdOlives';
const ADD_USD_OLIVES_DIR = 'generated/agoricNamesCoreEvals/addUsdOlives';
const DEPOSIT_USD_OLIVES_DIR = 'agoricNamesCoreEvals/depositUsdOlives';
const PUBLISH_TEST_INFO_DIR = 'agoricNamesCoreEvals/publishTestInfo';
const PUBLISH_TEST_INFO_DIR = 'generated/agoricNamesCoreEvals/publishTestInfo';
const WRITE_TEST_INFO_DIR = 'agoricNamesCoreEvals/writeToTestInfo';

const makeWaitUntilKeyFound = (keyFinder, vstorage) => (path, targetKey) =>
Expand Down Expand Up @@ -118,9 +117,7 @@ test.serial('publish test info', async t => {
});
});

test.serial('upgrade agoricNames', async t => {
await evalBundles(AGORIC_NAMES_UPGRADE_DIR);

test.serial('verify incarnation', async t => {
const incarnation = await getIncarnation('agoricNames');
t.is(incarnation, 1, 'incorrect incarnation');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import {
waitUntilContractDeployed,
} from '@agoric/client-utils';

const ADD_PSM_DIR = 'addUsdLemons';
const UPGRADE_AR_DIR = 'upgradeAssetReserve';
const ADD_PSM_DIR = 'generated/addUsdLemons';
const ADD_COLLATERAL = 'addCollateral';

const ambientAuthority = {
Expand Down Expand Up @@ -51,11 +50,10 @@ test.before(async t => {
};
});

test.serial('add collatoral to reserve', async t => {
test.serial('add Collateral to reserve', async t => {
// @ts-expect-error casting
const { vstorageKit } = t.context;

// Introduce USD_LEMONS
await evalBundles(ADD_PSM_DIR);
await waitUntilContractDeployed('psm-IST-USD_LEMONS', ambientAuthority, {
errorMessage: 'psm-IST-USD_LEMONS instance not observed.',
Expand All @@ -75,8 +73,6 @@ test.serial('upgrade', async t => {
// @ts-expect-error casting
const { vstorageKit } = t.context;

await evalBundles(UPGRADE_AR_DIR);

const vatDetailsAfter = await getDetailsMatchingVats('reserve');
const { incarnation } = vatDetailsAfter.find(vat => vat.vatID === 'v36'); // assetReserve is v36

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const vats = {
orchestration: { incarnation: 1 },
transfer: { incarnation: 2 },
walletFactory: { incarnation: 6 },
zoe: { incarnation: 4 },
zoe: { incarnation: 3 },
// Terminated in a future proposal.
'-ATOM-USD_price_feed-governor': { incarnation: 0 },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ const sendBankAsset = async powers => {
const valueStr = '{{VALUE}}';
const value = BigInt(valueStr)

console.log(`Start sendBankAsset for ${label}`);

const contractKits = await contractKitsP;
const mintHolderKit = Array.from(contractKits.values()).filter(
kit => kit.label && kit.label === label,
Expand All @@ -49,8 +47,6 @@ const sendBankAsset = async powers => {
);

await E(receiverDepositFacet).receive(payment);

console.log(`Finished sendBankAsset for ${label}`);
};

sendBankAsset;
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import {
getAssetList,
swap,
getPSMChildren,
upgradeMintHolder,
} from './test-lib/mintHolder-helpers.js';
import { networkConfig } from './test-lib/index.js';
} from '../test-lib/mintHolder-helpers.js';
import { networkConfig } from '../test-lib/index.js';

test('mintHolder contract is upgraded', async t => {
test('verify mintHolder contract upgrade', async t => {
const receiver = await addUser('receiver');
await provisionSmartWallet(receiver, `20000000ubld`);

let assetList = await getAssetList();
t.log('List of mintHolder vats being upgraded: ', assetList);
await upgradeMintHolder(`upgrade-mintHolder`, assetList);
await mintPayment(t, receiver, assetList, 10);
// The FastLP mint is not in a mintHolder; it's a ZCFMint from the FastUSDC contract
const assetListNoFastUSDC = assetList.filter(x => x.label !== 'FastLP');
await mintPayment(t, receiver, assetListNoFastUSDC, 10);

const psmLabelList = await getPSMChildren(fetch, networkConfig);
assetList = await getAssetList(psmLabelList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,15 @@ const nullUpgradePP = async powers => {
},
} = powers;

console.log('awaiting powers');
const { adminFacet, instance } = await provisionPoolStartResultP;
const instancePrivateArgs = await instancePrivateArgsP;

console.log('get privateArgs');
const privateArgs = instancePrivateArgs.get(instance);
const [poolBank, poserInvitation] = await Promise.all([
privateArgs.poolBank,
E(economicCommitteeCreatorFacet).getPoserInvitation(),
]);

console.log('DEBUG', {
adminFacet,
instance,
privateArgs,
poserInvitation,
});

await E(adminFacet).restartContract({
...privateArgs,
poolBank,
Expand Down
Loading

0 comments on commit 46061c3

Please sign in to comment.