diff --git a/a3p-integration/proposals/z:acceptance/test-lib/utils.js b/a3p-integration/proposals/z:acceptance/test-lib/utils.js index 607296794db..2f9b7e3d1bd 100644 --- a/a3p-integration/proposals/z:acceptance/test-lib/utils.js +++ b/a3p-integration/proposals/z:acceptance/test-lib/utils.js @@ -5,7 +5,7 @@ import { retryUntilCondition, } from '@agoric/client-utils'; import { readFile, writeFile } from 'node:fs/promises'; -import { evalBundles, getIncarnation } from '@agoric/synthetic-chain'; +import { evalBundles, getDetailsMatchingVats } from '@agoric/synthetic-chain'; import { networkConfig } from './rpc.js'; export const stargateClientP = makeStargateClient(networkConfig, { fetch }); @@ -96,12 +96,26 @@ export const makeTimerUtils = ({ setTimeout }) => { }; }; +/** + * This function solves the limitation of getIncarnation when multiple Vats + * are returned for the provided vatName and does not return the incarnation + * of the desired Vat (e.g. zcf-mintHolder-USDC) + * @param {string} vatName + * @returns {Promise} + */ +const getIncarnationFromDetails = async vatName => { + const matchingVats = await getDetailsMatchingVats(vatName); + const expectedVat = matchingVats.find(vat => vat.vatName === vatName); + console.log('Vat: ', expectedVat); + return expectedVat.incarnation; +}; + export const upgradeContract = async (submissionPath, vatName) => { - const incarnationBefore = await getIncarnation(vatName); + const incarnationBefore = await getIncarnationFromDetails(vatName); await evalBundles(submissionPath); return retryUntilCondition( - async () => getIncarnation(vatName), + async () => getIncarnationFromDetails(vatName), value => value === incarnationBefore + 1, `${vatName} upgrade not processed yet`, { setTimeout, retryIntervalMs: 5000, maxRetries: 15 },