Skip to content

Commit

Permalink
test(a3p): extend governance testing coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge-Lopes committed Dec 10, 2024
1 parent db0cd37 commit d17635f
Showing 1 changed file with 123 additions and 1 deletion.
124 changes: 123 additions & 1 deletion a3p-integration/proposals/z:acceptance/governance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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',
);
},
);

0 comments on commit d17635f

Please sign in to comment.