Skip to content

Commit

Permalink
fix(a3p): add contingency for getIncarnation at upgradeContract
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge-Lopes committed Dec 6, 2024
1 parent 080d4c0 commit b1a07e6
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions a3p-integration/proposals/z:acceptance/test-lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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<number>}
*/
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 },
Expand Down

0 comments on commit b1a07e6

Please sign in to comment.