Skip to content

Commit

Permalink
Merge pull request #269 from fei-protocol/feat/check-proposal-cleanup
Browse files Browse the repository at this point in the history
check proposal cleanup
  • Loading branch information
Joeysantoro committed Oct 25, 2021
2 parents fd0f3ac + 38fe7f2 commit 514cf4d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
4 changes: 3 additions & 1 deletion proposals/dao/fip_34.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ValidateUpgradeFunc
} from '../../types/types';
import { FeiDAOTimelock } from '@custom-types/contracts';
import { getImpersonatedSigner } from '@test/helpers';

chai.use(CBN(ethers.BigNumber));

Expand Down Expand Up @@ -51,7 +52,8 @@ export const deploy: DeployUpgradeFunc = async (deployAddress, addresses, loggin
};

export const setup: SetupUpgradeFunc = async (addresses, oldContracts, contracts, logging) => {
await (await (contracts.feiDAOTimelock as FeiDAOTimelock).rollback()).wait();
const timelock: FeiDAOTimelock = contracts.feiDAOTimelock as FeiDAOTimelock;
await (await timelock.connect(await getImpersonatedSigner(addresses.multisig)).rollback()).wait();
};

export const teardown: TeardownUpgradeFunc = async (addresses, oldContracts, contracts, logging) => {
Expand Down
34 changes: 19 additions & 15 deletions scripts/utils/checkProposal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { getAllContracts } from '../../test/integration/setup/loadContracts';
import hre, { ethers } from 'hardhat';
import { time } from '@openzeppelin/test-helpers';
import { NamedContracts, namedContractsToNamedAddresses, UpgradeFuncs } from '../../types/types';
import { getAllContracts, getAllContractAddresses } from '@test/integration/setup/loadContracts';
import { getImpersonatedSigner, time } from '@test/helpers';
import { NamedContracts, UpgradeFuncs } from '@custom-types/types';

import * as dotenv from 'dotenv';

Expand All @@ -22,16 +21,26 @@ async function checkProposal() {
throw new Error('DEPLOY_FILE or PROPOSAL_NUMBER env variable not set');
}

// Get the upgrade setup, run and teardown scripts
const proposalFuncs: UpgradeFuncs = await import(`@proposals/dao/${proposalName}`);

const contracts = (await getAllContracts()) as NamedContracts;

const { feiDAO } = contracts;
const contractAddresses = await getAllContractAddresses();

await hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [voterAddress]
});
if (process.env.DO_SETUP) {
console.log('Setup');
await proposalFuncs.setup(
contractAddresses,
contracts as unknown as NamedContracts,
contracts as unknown as NamedContracts,
true
);
}

const voterSigner = await ethers.getSigner(voterAddress);
const { feiDAO } = contracts;

const voterSigner = await getImpersonatedSigner(voterAddress);

console.log(`Proposal Number: ${proposalNo}`);

Expand Down Expand Up @@ -76,11 +85,6 @@ async function checkProposal() {
await feiDAO['execute(uint256)'](proposalNo);
console.log('Success');

// Get the upgrade setup, run and teardown scripts
const proposalFuncs: UpgradeFuncs = await import(`../../proposals/dao/${proposalName}`);

const contractAddresses = namedContractsToNamedAddresses(contracts);

console.log('Teardown');
await proposalFuncs.teardown(
contractAddresses,
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/exec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import hre, { ethers } from 'hardhat';
import { time } from '@openzeppelin/test-helpers';
import { time } from '@test/helpers';

import * as dotenv from 'dotenv';

Expand Down
10 changes: 2 additions & 8 deletions test/unit/staking/feirari/RewardsDistributorAdmin.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { expectRevert, getAddresses, getCore } from '../../../helpers';
import { expectRevert, getAddresses, getCore, ZERO_ADDRESS } from '@test/helpers';
import { expect } from 'chai';
import hre, { ethers } from 'hardhat';
import { Signer, utils } from 'ethers';
import testHelpers from '@openzeppelin/test-helpers';
import { Core } from '../../../../types/contracts/Core';
import { RewardsDistributorAdmin } from '../../../../types/contracts/RewardsDistributorAdmin';
import { MockRewardsDistributor } from '../../../../types/contracts/MockRewardsDistributor';
import { Core, RewardsDistributorAdmin, MockRewardsDistributor } from '@custom-types/contracts';
import { keccak256 } from 'ethers/lib/utils';

const toBN = ethers.BigNumber.from;
const {
constants: { ZERO_ADDRESS }
} = testHelpers;

describe('RewardsDistributorAdmin', function () {
let governorAddress: string;
Expand Down

0 comments on commit 514cf4d

Please sign in to comment.