Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair u19 tests in a3p-integration #10947

Merged
merged 15 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

turadg marked this conversation as resolved.
Show resolved Hide resolved
# 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 @@
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('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 Expand Up @@ -155,7 +152,7 @@
const agoricNamesAfter = await getAgoricNames();
t.like(agoricNamesAfter, agoricNamesBefore);

agoricNamesChildren.forEach(child =>

Check warning on line 155 in a3p-integration/proposals/n:upgrade-next/test/agoricNames.test.js

View workflow job for this annotation

GitHub Actions / lint-rest

Prefer for...of instead of Array.forEach
assert(
agoricNamesAfter[child][`test${child}`],
'we should be able to add new value',
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
Loading