From d17635f55e70edb0f41ab2ac3b966ff3d8f2fbbd Mon Sep 17 00:00:00 2001 From: Jorge-Lopes Date: Tue, 10 Dec 2024 11:38:59 +0000 Subject: [PATCH] test(a3p): extend governance testing coverage --- .../proposals/z:acceptance/governance.test.js | 124 +++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/a3p-integration/proposals/z:acceptance/governance.test.js b/a3p-integration/proposals/z:acceptance/governance.test.js index 24fc7b24796..3bbb2f83f76 100644 --- a/a3p-integration/proposals/z:acceptance/governance.test.js +++ b/a3p-integration/proposals/z:acceptance/governance.test.js @@ -5,11 +5,12 @@ import test from 'ava'; import { GOV1ADDR, GOV2ADDR } from '@agoric/synthetic-chain'; import { makeGovernanceDriver } from './test-lib/governance.js'; import { networkConfig, walletUtils } from './test-lib/index.js'; +import { upgradeContract } from './test-lib/utils.js'; const GOV4ADDR = 'agoric1c9gyu460lu70rtcdp95vummd6032psmpdx7wdy'; const governanceAddresses = [GOV4ADDR, GOV2ADDR, GOV1ADDR]; -const { getLastUpdate } = walletUtils; +const { getLastUpdate, readLatestHead } = walletUtils; const governanceDriver = await makeGovernanceDriver(fetch, networkConfig); test.serial( @@ -62,3 +63,124 @@ test.serial( t.like(latestOutcome, { outcome: 'win' }); }, ); + +test.serial( + 'VaultFactory governed parameters are intact following contract upgrade', + async t => { + /** @type {any} */ + const vaultFactoryParamsBefore = await readLatestHead( + 'published.vaultFactory.governance', + ); + + /* + * At the previous test ('economic committee can make governance proposal and vote on it') + * The value of ChargingPeriod was updated to 400 + * The 'published.vaultFactory.governance' node should reflect that change. + */ + t.is( + vaultFactoryParamsBefore.current.ChargingPeriod.value, + 400n, + 'vaultFactory ChargingPeriod parameter value is not the expected ', + ); + + await upgradeContract('upgrade-vaultFactory', 'zcf-b1-6c08a-vaultFactory'); + + const vaultFactoryParamsAfter = await readLatestHead( + 'published.vaultFactory.governance', + ); + + t.deepEqual( + vaultFactoryParamsAfter, + vaultFactoryParamsBefore, + 'vaultFactory governed parameters did not match', + ); + }, +); + +test.serial( + 'economic committee can make governance proposal for ProvisionPool', + async t => { + const charterInvitation = await governanceDriver.getCharterInvitation( + governanceAddresses[0], + ); + + /** @type {any} */ + const brand = await readLatestHead(`published.agoricNames.brand`); + const brands = Object.fromEntries(brand); + + const params = { + PerAccountInitialAmount: { brand: brands.IST, value: 100_000n }, + }; + const path = { paramPath: { key: 'governedParams' } }; + const instanceName = 'provisionPool'; + + await governanceDriver.proposeParamChange( + governanceAddresses[0], + params, + path, + instanceName, + charterInvitation[0], + ); + + const questionUpdate = await getLastUpdate(governanceAddresses[0]); + t.like(questionUpdate, { + status: { numWantsSatisfied: 1 }, + }); + + for (const address of governanceAddresses) { + const committeeInvitationForVoter = + await governanceDriver.getCommitteeInvitation(address); + + await governanceDriver.voteOnProposedChanges( + address, + committeeInvitationForVoter[0], + ); + + const voteUpdate = await getLastUpdate(address); + t.like(voteUpdate, { + status: { numWantsSatisfied: 1 }, + }); + } + + const { latestOutcome } = await governanceDriver.getLatestQuestion(); + t.log('Verifying latest outcome', latestOutcome); + t.like(latestOutcome, { outcome: 'win' }); + }, +); + +test.serial( + 'ProvisionPool governed parameters are intact following contract upgrade', + async t => { + /** @type {any} */ + const provisionPoolParamsBefore = await readLatestHead( + 'published.provisionPool.governance', + ); + + /* + * At the previous test ('economic committee can make governance proposal and vote on it') + * The value of ChargingPeriod was updated to 400 + * The 'published.vaultFactory.governance' node should reflect that change. + */ + t.is( + provisionPoolParamsBefore.current.PerAccountInitialAmount.value.value, + 100_000n, + 'provisionPool PerAccountInitialAmount parameter value is not the expected ', + ); + + await upgradeContract( + 'upgrade-provisionPool', + 'zcf-b1-db93f-provisionPool', + ); + + /** @type {any} */ + const provisionPoolParamsAfter = await readLatestHead( + 'published.provisionPool.governance', + ); + + t.deepEqual( + provisionPoolParamsAfter.current.PerAccountInitialAmount, + provisionPoolParamsBefore.current.PerAccountInitialAmount, + 'provisionPool governed parameters did not match', + ); + }, +);