Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 31cb43d

Browse files
committed
Add test for migration to new governor
1 parent adbc7a0 commit 31cb43d

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

shared/Forking.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from '../typechain';
1414

1515
export type DeployedContracts = {
16+
governorV1: ArenaGovernor,
1617
governor: ArenaGovernor;
1718
timeLock: TimelockController;
1819
tokenLock: TokenLock;
@@ -23,12 +24,14 @@ export const getPolygonContracts = (signer: Signer): DeployedContracts => {
2324
if (!fs.existsSync(deploymentFilePath)) throw new Error(`File '${path.resolve(deploymentFilePath)}' does not exist.`);
2425

2526
const contents = fs.readFileSync(deploymentFilePath, `utf8`);
27+
let governorV1Address;
2628
let governorAddress;
2729
let arenaAddress;
2830
let timelockAddress;
2931
let tokenLockAddress;
3032
try {
3133
({
34+
governorV1: governorV1Address,
3235
governor: governorAddress,
3336
token: arenaAddress,
3437
tokenLock: tokenLockAddress,
@@ -43,6 +46,7 @@ export const getPolygonContracts = (signer: Signer): DeployedContracts => {
4346
if (!tokenLockAddress) throw new Error(`Deployment file did not include tokenLock address '${deploymentFilePath}'.`);
4447

4548
return {
49+
governorV1: ArenaGovernor__factory.connect(governorV1Address, signer),
4650
governor: ArenaGovernor__factory.connect(governorAddress, signer),
4751
arenaToken: ArenaToken__factory.connect(arenaAddress, signer),
4852
timeLock: TimelockController__factory.connect(timelockAddress, signer),

test/GovernanceSim.spec.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ chai.use(solidity);
1010
// can simulate poylgon mainnet governance proposals here, enable fork object in hardhat.config.ts
1111
describe.skip('Governance - Polygon mainnet proposal simulations', async () => {
1212
const [user] = waffle.provider.getWallets();
13-
const deployment = getPolygonContracts(user);
14-
const {arenaToken, timeLock} = deployment;
13+
let deployment = getPolygonContracts(user);
14+
const {governorV1, governor, arenaToken, timeLock} = deployment;
1515

1616
it('should allow governance to move tokens in timeLock contract', async () => {
1717
const treasuryAmount = await arenaToken.balanceOf(timeLock.address);
@@ -24,4 +24,34 @@ describe.skip('Governance - Polygon mainnet proposal simulations', async () => {
2424

2525
expect(await arenaToken.balanceOf(timeLock.address)).to.eq(ZERO);
2626
});
27+
28+
it('should migrate to new governor', async () => {
29+
// set to current existing governor for proposal creation
30+
deployment.governor = governorV1;
31+
const PROPOSER_ROLE = '0xb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1';
32+
let targets: string[] = [timeLock.address, timeLock.address];
33+
let values: string[] = [`0`, `0`];
34+
let calldatas: string[] = [
35+
timeLock.interface.encodeFunctionData('grantRole', [PROPOSER_ROLE, governor.address]),
36+
timeLock.interface.encodeFunctionData('revokeRole', [PROPOSER_ROLE, governorV1.address]),
37+
];
38+
await createAndExecuteProposal({targets, values, calldatas, user, ...deployment});
39+
40+
const treasuryAmount = await arenaToken.balanceOf(timeLock.address);
41+
targets = [arenaToken.address];
42+
values = [`0`];
43+
calldatas = [arenaToken.interface.encodeFunctionData('transfer', [user.address, treasuryAmount])];
44+
45+
// attempt to move funds through old governor, will fail
46+
try {
47+
await createAndExecuteProposal({targets, values, calldatas, user, ...deployment});
48+
} catch (e) {
49+
console.log(e);
50+
}
51+
52+
// attempt to move funds through new governor, should be successful
53+
deployment.governor = governor;
54+
await createAndExecuteProposal({targets, values, calldatas, user, ...deployment});
55+
expect(await arenaToken.balanceOf(timeLock.address)).to.eq(ZERO);
56+
});
2757
});

0 commit comments

Comments
 (0)