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

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
13 changes: 5 additions & 8 deletions a3p-integration/proposals/n:upgrade-next/.gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
replaceFeeDistributor/
addCollateral/
addUsdLemons/
addUsdOlives/
upgradeProvisionPool/
upgradeAgoricNames/
publishTestInfo/
upgrade-mintHolder/
upgradeAssetReserve/
upgradePSM/
agoricNamesCoreEvals/
depositUSD-LEMONS/
nullUpgradePP/
swapAnchorForMintedSeat/
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
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 DEPOSIT_USD_OLIVES_DIR = 'agoricNamesCoreEvals/depositUsdOlives';
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/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
10 changes: 3 additions & 7 deletions a3p-integration/proposals/n:upgrade-next/assetReserve.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import {
waitUntilContractDeployed,
} from '@agoric/client-utils';

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

const ambientAuthority = {
Expand Down Expand Up @@ -51,12 +49,12 @@ 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);
// USD_LEMONS introduced in provisionPool test
turadg marked this conversation as resolved.
Show resolved Hide resolved
// 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
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
2 changes: 1 addition & 1 deletion a3p-integration/proposals/n:upgrade-next/initial.test.js
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 },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how did this number go down?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know for sure how the test passed with this number. My guess would be that the code last ran in an environment where a Zoe upgrade was included with U18 or the proto U19.

The lower number is correct following U18, and in a U19 that doesn't upgrade Zoe.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because upgrade.go somehow kept some u18 proposals around when it was rebased on top of u18.

// 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}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems useful but you'd know better since you've been debugging


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;
8 changes: 4 additions & 4 deletions a3p-integration/proposals/n:upgrade-next/mintHolder.test.js
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';

test('mintHolder contract is upgraded', async t => {
test('verify mintHolder contract upgrade', async t => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "test" is already a verb

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I read the string argument as the name of the test, rather than a noun phrase describing what is to be tested. In this case the test used to perform the upgrade (because the proposal was a coreEval), and now only verifies it (because it's now a software upgrade).

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);
// FastUSDC doesn't have a contractKit indexed by its label
turadg marked this conversation as resolved.
Show resolved Hide resolved
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
9 changes: 1 addition & 8 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/publish-test-info.js agoricNamesCoreEvals/publishTestInfo"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these proposals for testing should be under test/ so they don't invalidate the "use" image. see,

Making that change affects .gitignore and .tsconfig but if you put them under a path like test/submissions then you can use that pathname for those files and not have to manage a list of submissions.

We'll make this easier eventually,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually they should be in host, and their core eval output should be in test

Something like

Suggested change
"testing/publish-test-info.js agoricNamesCoreEvals/publishTestInfo"
"host/testing/publish-test-info.js test/agoricNamesCoreEvals/publishTestInfo"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @Chris-Hibbert , the host thing hasn't landed in a3p. Up to you whether to wait for it to be merged and released to NPM so you can include that synthetic-chain lib version in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your test/generated approach. It still copies to the image unnecessarily, but it's only the test image so it doesn't invalid any extra. (If the proposal changes its build would anyway). I think it's better to keep test stuff together than to spread it into another path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're right, a change in the proposal building would likely invalidate everything anyway, but collocating test files together is cleaner.

I got confused about the host stuff however, I forgot these first argument is relative to the SDK packages.

]
},
"type": "module",
Expand Down
22 changes: 2 additions & 20 deletions a3p-integration/proposals/n:upgrade-next/provisionPool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* - https://github.com/Agoric/agoric-sdk/issues/8724
*
* The test scenario is as follows;
* 1. Upgrade provisionPool. This upgrade overrides provisionWalletBridgerManager with a durable one
* 1. Upgrade provisionPool in upgrade.go. This upgrade overrides
* provisionWalletBridgerManager with a durable one
* 2. Add a new account and successfully provision it
* - Observe new account's address under `published.wallet.${address}`
* 3. Send some USDC_axl to provisionPoolAddress and observe its IST balances increases accordingly
Expand Down Expand Up @@ -56,7 +57,6 @@ const PROVISIONING_POOL_ADDR = 'agoric1megzytg65cyrgzs6fvzxgrcqvwwl7ugpt62346';

const ADD_PSM_DIR = 'addUsdLemons';
const DEPOSIT_USD_LEMONS_DIR = 'depositUSD-LEMONS';
const UPGRADE_PP_DIR = 'upgradeProvisionPool';
const NULL_UPGRADE_PP_DIR = 'nullUpgradePP';

const USDC_DENOM = NonNullish(process.env.USDC_DENOM);
Expand Down Expand Up @@ -87,24 +87,6 @@ test.before(async t => {
};
});

test.serial('upgrade provisionPool', async t => {
// @ts-expect-error casting
const { currentVatIncarnations } = t.context;
console.log(currentVatIncarnations);
await evalBundles(UPGRADE_PP_DIR);

for await (const vatName of upgradedVats) {
const incarnationAfterUpgrade = await getIncarnationFromDetails(vatName);
const previousIncarnation = currentVatIncarnations[vatName];

t.is(
incarnationAfterUpgrade,
previousIncarnation + 1,
`${vatName} does not meet the expected incarnation number`,
);
}
});

test.serial(
`check provisionPool can recover purse and asset subscribers after upgrade`,
async t => {
Expand Down
53 changes: 16 additions & 37 deletions a3p-integration/proposals/n:upgrade-next/psm.test.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
/* eslint-env node */
/**
* @file The goal of this file is to make sure all the PSM contacts are upgrade. Each set of vats are different
* per chain, but for mainnet, we expect this to be: V37-V42, V73, V76
* @file The goal of this file is to make sure all the PSM contacts were
* upgraded. Each set of vats are different per chain, but for mainnet, we
* expect this to be: V37-V42, V73, V76
*
* The test scenario is as follows;
* 1. Simulate trade of IST and USDC
* 2. Upgrade all PSMs
* 3. Verify metrics are the same after the upgrade
* 4. Verify trading is still possible after the upgrade
* 1. Verify metrics before the upgrade
* 2. Verify trading is possible after the upgrade
*/

import '@endo/init';
import test from 'ava';
import { evalBundles } from '@agoric/synthetic-chain';
import { makeVstorageKit } from '@agoric/client-utils';

const UPGRADE_PSM_DIR = 'upgradePSM';
const SWAP_ANCHOR = 'swapAnchorForMintedSeat';

test.before(async t => {
Expand All @@ -29,38 +27,19 @@ test.before(async t => {
};
});

test.serial('simulate trade of IST and USDC', async t => {
test.serial('check stats pre-swap', async t => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't block on this, but we've been abusing test.serial. Its only guarantee is "not serial" and we've been relying on it being sequential.

Consider factoring into one test() call. If the function is unwieldy you can use a driver model to abstract the steps. Or just put a log message for each stage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't block on this, but we've been abusing test.serial. Its only guarantee is "not serial" and we've been relying on it being sequential.

You mean "not concurrent". I honestly didn't realize it didn't guarantee sequential.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// @ts-expect-error casting
const { vstorageKit } = t.context;

await evalBundles(SWAP_ANCHOR);

const metrics = await vstorageKit.readLatestHead(
'published.psm.IST.USDC.metrics',
);

t.is(metrics.anchorPoolBalance.value, 500000n);
t.is(metrics.feePoolBalance.value, 0n);
t.is(metrics.mintedPoolBalance.value, 500000n);
t.is(metrics.totalAnchorProvided.value, 0n);
t.is(metrics.totalMintedProvided.value, 500000n);
});

test.serial('upgrade PSMs', async t => {
// @ts-expect-error casting
const { vstorageKit } = t.context;

await evalBundles(UPGRADE_PSM_DIR);

const metrics = await vstorageKit.readLatestHead(
'published.psm.IST.USDC.metrics',
);

t.is(metrics.anchorPoolBalance.value, 500000n);
t.is(metrics.feePoolBalance.value, 0n);
t.is(metrics.mintedPoolBalance.value, 500000n);
t.is(metrics.totalAnchorProvided.value, 0n);
t.is(metrics.totalMintedProvided.value, 500000n);
t.is(metrics.anchorPoolBalance.value, 0n, 'anchorPool empty');
t.is(metrics.feePoolBalance.value, 0n, 'feePool empty');
t.is(metrics.mintedPoolBalance.value, 0n, 'mintedPool 500K');
t.is(metrics.totalAnchorProvided.value, 0n, 'totalAnchor empty');
t.is(metrics.totalMintedProvided.value, 0n, 'totalMinted 500K');
turadg marked this conversation as resolved.
Show resolved Hide resolved
});

test.serial('verify trading after upgrade', async t => {
Expand All @@ -73,9 +52,9 @@ test.serial('verify trading after upgrade', async t => {
'published.psm.IST.USDC.metrics',
);

t.is(metrics.anchorPoolBalance.value, 1000000n);
t.is(metrics.feePoolBalance.value, 0n);
t.is(metrics.mintedPoolBalance.value, 1000000n);
t.is(metrics.totalAnchorProvided.value, 0n);
t.is(metrics.totalMintedProvided.value, 1000000n);
t.is(metrics.anchorPoolBalance.value, 500_000n, 'AnchorPool +500K');
t.is(metrics.feePoolBalance.value, 0n, 'feePool empty');
t.is(metrics.mintedPoolBalance.value, 500_000n, 'mintedPool +500K');
t.is(metrics.totalAnchorProvided.value, 0n, 'totalAnchor empty');
t.is(metrics.totalMintedProvided.value, 500_000n, 'totalMinted +500K');
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@

import '@endo/init/debug.js';
import test from 'ava';
import {
retryUntilCondition,
makeVstorageKit,
sleep,
} from '@agoric/client-utils';
import { retryUntilCondition, makeVstorageKit } from '@agoric/client-utils';
import {
ATOM_DENOM,
bankSend,
evalBundles,
openVault,
USER1ADDR,
} from '@agoric/synthetic-chain';
Expand All @@ -50,7 +45,6 @@ import { floorMultiplyBy } from '@agoric/zoe/src/contractSupport/ratio.js';
*/

const config = {
coreEvalDir: 'replaceFeeDistributor',
mintValue: '100.0',
collateralValue: '200.0',
managerIndex: 0,
Expand Down Expand Up @@ -85,6 +79,7 @@ const produceFeesAndWait = async (vstorage, feeAmount) => {
const metricsBefore = /** @type {ReserveAllocations} */ (
await vstorage.readLatestHead('published.reserve.metrics')
);

// XXX Probably better to not rely on synthetic-chain for opening a vault as per https://github.com/Agoric/agoric-sdk/pull/10396.
// But to make the switch also requires either copying z:acceptance/test-lib here (which is not wanted) or creating a root level
// lib and link it here which requires an all around work across all proposals. Probably a better idea to do it as a separate work.
Expand All @@ -96,6 +91,7 @@ const produceFeesAndWait = async (vstorage, feeAmount) => {
() => vstorage.readLatestHead('published.reserve.metrics'),
metrics =>
AmountMath.isEqual(
// @ts-expect-error metrics has these fields.
metrics.allocations.Fee,
AmountMath.add(metricsBefore.allocations.Fee, feeAmount),
),
Expand Down Expand Up @@ -142,7 +138,6 @@ test.before(async t => {
);
const vstorage = await makeVstorageKit({ fetch }, config.networkConfig);
const toAmount = (value, brandKeyword) =>
// @ts-expect-error casting
AmountMath.make(vstorage.agoricNames.brand[brandKeyword], value);

t.context = {
Expand All @@ -151,14 +146,10 @@ test.before(async t => {
};
});

test('replace feeDistributor', async t => {
test('test feeDistributor', async t => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test('test feeDistributor', async t => {
test('feeDistributor', async t => {

// @ts-expect-error type
const { vstorage, toAmount } = t.context;
const { collectionInterval, vaultCount, coreEvalDir } = config;

await evalBundles(coreEvalDir);
// Wait for a round to give the new feeDistributor time to clear out outstanding fees, if any.
await sleep(collectionInterval + 5000, { log: console.log, setTimeout });
const { vaultCount } = config;

const feeAmount = await calculateFee(
config.managerIndex,
Expand Down
Loading
Loading