Finalize test migration: remove legacy dependencies and test helpers (#4797)
This commit is contained in:
@ -4,8 +4,8 @@ const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');
|
||||
const { anyValue } = require('@nomicfoundation/hardhat-chai-matchers/withArgs');
|
||||
|
||||
const { GovernorHelper, timelockSalt } = require('../../helpers/governance');
|
||||
const { bigint: Enums } = require('../../helpers/enums');
|
||||
const { bigint: time } = require('../../helpers/time');
|
||||
const { OperationState, ProposalState, VoteType } = require('../../helpers/enums');
|
||||
const time = require('../../helpers/time');
|
||||
|
||||
const TOKENS = [
|
||||
{ Token: '$ERC20Votes', mode: 'blocknumber' },
|
||||
@ -95,12 +95,12 @@ describe('GovernorTimelockControl', function () {
|
||||
|
||||
it('post deployment check', async function () {
|
||||
expect(await this.mock.name()).to.equal(name);
|
||||
expect(await this.mock.token()).to.equal(this.token.target);
|
||||
expect(await this.mock.token()).to.equal(this.token);
|
||||
expect(await this.mock.votingDelay()).to.equal(votingDelay);
|
||||
expect(await this.mock.votingPeriod()).to.equal(votingPeriod);
|
||||
expect(await this.mock.quorum(0n)).to.equal(0n);
|
||||
|
||||
expect(await this.mock.timelock()).to.equal(this.timelock.target);
|
||||
expect(await this.mock.timelock()).to.equal(this.timelock);
|
||||
});
|
||||
|
||||
it('nominal', async function () {
|
||||
@ -109,10 +109,10 @@ describe('GovernorTimelockControl', function () {
|
||||
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.connect(this.voter1).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter2).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter3).vote({ support: Enums.VoteType.Against });
|
||||
await this.helper.connect(this.voter4).vote({ support: Enums.VoteType.Abstain });
|
||||
await this.helper.connect(this.voter1).vote({ support: VoteType.For });
|
||||
await this.helper.connect(this.voter2).vote({ support: VoteType.For });
|
||||
await this.helper.connect(this.voter3).vote({ support: VoteType.Against });
|
||||
await this.helper.connect(this.voter4).vote({ support: VoteType.Abstain });
|
||||
await this.helper.waitForDeadline();
|
||||
|
||||
expect(await this.mock.proposalNeedsQueuing(this.proposal.id)).to.be.true;
|
||||
@ -145,15 +145,15 @@ describe('GovernorTimelockControl', function () {
|
||||
it('if already queued', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.connect(this.voter1).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter1).vote({ support: VoteType.For });
|
||||
await this.helper.waitForDeadline();
|
||||
await this.helper.queue();
|
||||
await expect(this.helper.queue())
|
||||
.to.be.revertedWithCustomError(this.mock, 'GovernorUnexpectedProposalState')
|
||||
.withArgs(
|
||||
this.proposal.id,
|
||||
Enums.ProposalState.Queued,
|
||||
GovernorHelper.proposalStatesToBitMap([Enums.ProposalState.Succeeded]),
|
||||
ProposalState.Queued,
|
||||
GovernorHelper.proposalStatesToBitMap([ProposalState.Succeeded]),
|
||||
);
|
||||
});
|
||||
});
|
||||
@ -162,34 +162,34 @@ describe('GovernorTimelockControl', function () {
|
||||
it('if not queued', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.connect(this.voter1).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter1).vote({ support: VoteType.For });
|
||||
await this.helper.waitForDeadline(1n);
|
||||
|
||||
expect(await this.mock.state(this.proposal.id)).to.equal(Enums.ProposalState.Succeeded);
|
||||
expect(await this.mock.state(this.proposal.id)).to.equal(ProposalState.Succeeded);
|
||||
|
||||
await expect(this.helper.execute())
|
||||
.to.be.revertedWithCustomError(this.timelock, 'TimelockUnexpectedOperationState')
|
||||
.withArgs(this.proposal.timelockid, GovernorHelper.proposalStatesToBitMap(Enums.OperationState.Ready));
|
||||
.withArgs(this.proposal.timelockid, GovernorHelper.proposalStatesToBitMap(OperationState.Ready));
|
||||
});
|
||||
|
||||
it('if too early', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.connect(this.voter1).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter1).vote({ support: VoteType.For });
|
||||
await this.helper.waitForDeadline();
|
||||
await this.helper.queue();
|
||||
|
||||
expect(await this.mock.state(this.proposal.id)).to.equal(Enums.ProposalState.Queued);
|
||||
expect(await this.mock.state(this.proposal.id)).to.equal(ProposalState.Queued);
|
||||
|
||||
await expect(this.helper.execute())
|
||||
.to.be.revertedWithCustomError(this.timelock, 'TimelockUnexpectedOperationState')
|
||||
.withArgs(this.proposal.timelockid, GovernorHelper.proposalStatesToBitMap(Enums.OperationState.Ready));
|
||||
.withArgs(this.proposal.timelockid, GovernorHelper.proposalStatesToBitMap(OperationState.Ready));
|
||||
});
|
||||
|
||||
it('if already executed', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.connect(this.voter1).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter1).vote({ support: VoteType.For });
|
||||
await this.helper.waitForDeadline();
|
||||
await this.helper.queue();
|
||||
await this.helper.waitForEta();
|
||||
@ -199,15 +199,15 @@ describe('GovernorTimelockControl', function () {
|
||||
.to.be.revertedWithCustomError(this.mock, 'GovernorUnexpectedProposalState')
|
||||
.withArgs(
|
||||
this.proposal.id,
|
||||
Enums.ProposalState.Executed,
|
||||
GovernorHelper.proposalStatesToBitMap([Enums.ProposalState.Succeeded, Enums.ProposalState.Queued]),
|
||||
ProposalState.Executed,
|
||||
GovernorHelper.proposalStatesToBitMap([ProposalState.Succeeded, ProposalState.Queued]),
|
||||
);
|
||||
});
|
||||
|
||||
it('if already executed by another proposer', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.connect(this.voter1).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter1).vote({ support: VoteType.For });
|
||||
await this.helper.waitForDeadline();
|
||||
await this.helper.queue();
|
||||
await this.helper.waitForEta();
|
||||
@ -222,8 +222,8 @@ describe('GovernorTimelockControl', function () {
|
||||
.to.be.revertedWithCustomError(this.mock, 'GovernorUnexpectedProposalState')
|
||||
.withArgs(
|
||||
this.proposal.id,
|
||||
Enums.ProposalState.Executed,
|
||||
GovernorHelper.proposalStatesToBitMap([Enums.ProposalState.Succeeded, Enums.ProposalState.Queued]),
|
||||
ProposalState.Executed,
|
||||
GovernorHelper.proposalStatesToBitMap([ProposalState.Succeeded, ProposalState.Queued]),
|
||||
);
|
||||
});
|
||||
});
|
||||
@ -233,28 +233,28 @@ describe('GovernorTimelockControl', function () {
|
||||
it('cancel before queue prevents scheduling', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.connect(this.voter1).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter1).vote({ support: VoteType.For });
|
||||
await this.helper.waitForDeadline();
|
||||
|
||||
await expect(this.helper.cancel('internal'))
|
||||
.to.emit(this.mock, 'ProposalCanceled')
|
||||
.withArgs(this.proposal.id);
|
||||
|
||||
expect(await this.mock.state(this.proposal.id)).to.equal(Enums.ProposalState.Canceled);
|
||||
expect(await this.mock.state(this.proposal.id)).to.equal(ProposalState.Canceled);
|
||||
|
||||
await expect(this.helper.queue())
|
||||
.to.be.revertedWithCustomError(this.mock, 'GovernorUnexpectedProposalState')
|
||||
.withArgs(
|
||||
this.proposal.id,
|
||||
Enums.ProposalState.Canceled,
|
||||
GovernorHelper.proposalStatesToBitMap([Enums.ProposalState.Succeeded]),
|
||||
ProposalState.Canceled,
|
||||
GovernorHelper.proposalStatesToBitMap([ProposalState.Succeeded]),
|
||||
);
|
||||
});
|
||||
|
||||
it('cancel after queue prevents executing', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.connect(this.voter1).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter1).vote({ support: VoteType.For });
|
||||
await this.helper.waitForDeadline();
|
||||
await this.helper.queue();
|
||||
|
||||
@ -262,31 +262,31 @@ describe('GovernorTimelockControl', function () {
|
||||
.to.emit(this.mock, 'ProposalCanceled')
|
||||
.withArgs(this.proposal.id);
|
||||
|
||||
expect(await this.mock.state(this.proposal.id)).to.equal(Enums.ProposalState.Canceled);
|
||||
expect(await this.mock.state(this.proposal.id)).to.equal(ProposalState.Canceled);
|
||||
|
||||
await expect(this.helper.execute())
|
||||
.to.be.revertedWithCustomError(this.mock, 'GovernorUnexpectedProposalState')
|
||||
.withArgs(
|
||||
this.proposal.id,
|
||||
Enums.ProposalState.Canceled,
|
||||
GovernorHelper.proposalStatesToBitMap([Enums.ProposalState.Succeeded, Enums.ProposalState.Queued]),
|
||||
ProposalState.Canceled,
|
||||
GovernorHelper.proposalStatesToBitMap([ProposalState.Succeeded, ProposalState.Queued]),
|
||||
);
|
||||
});
|
||||
|
||||
it('cancel on timelock is reflected on governor', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.connect(this.voter1).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter1).vote({ support: VoteType.For });
|
||||
await this.helper.waitForDeadline();
|
||||
await this.helper.queue();
|
||||
|
||||
expect(await this.mock.state(this.proposal.id)).to.equal(Enums.ProposalState.Queued);
|
||||
expect(await this.mock.state(this.proposal.id)).to.equal(ProposalState.Queued);
|
||||
|
||||
await expect(this.timelock.connect(this.owner).cancel(this.proposal.timelockid))
|
||||
.to.emit(this.timelock, 'Cancelled')
|
||||
.withArgs(this.proposal.timelockid);
|
||||
|
||||
expect(await this.mock.state(this.proposal.id)).to.equal(Enums.ProposalState.Canceled);
|
||||
expect(await this.mock.state(this.proposal.id)).to.equal(ProposalState.Canceled);
|
||||
});
|
||||
});
|
||||
|
||||
@ -303,7 +303,7 @@ describe('GovernorTimelockControl', function () {
|
||||
.relay(this.token, 0n, this.token.interface.encodeFunctionData('transfer', [this.other.address, 1n])),
|
||||
)
|
||||
.to.be.revertedWithCustomError(this.mock, 'GovernorOnlyExecutor')
|
||||
.withArgs(this.owner.address);
|
||||
.withArgs(this.owner);
|
||||
});
|
||||
|
||||
it('can be executed through governance', async function () {
|
||||
@ -323,7 +323,7 @@ describe('GovernorTimelockControl', function () {
|
||||
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.connect(this.voter1).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter1).vote({ support: VoteType.For });
|
||||
await this.helper.waitForDeadline();
|
||||
await this.helper.queue();
|
||||
await this.helper.waitForEta();
|
||||
@ -332,7 +332,7 @@ describe('GovernorTimelockControl', function () {
|
||||
|
||||
await expect(txExecute).to.changeTokenBalances(this.token, [this.mock, this.other], [-1n, 1n]);
|
||||
|
||||
await expect(txExecute).to.emit(this.token, 'Transfer').withArgs(this.mock.target, this.other.address, 1n);
|
||||
await expect(txExecute).to.emit(this.token, 'Transfer').withArgs(this.mock, this.other, 1n);
|
||||
});
|
||||
|
||||
it('is payable and can transfer eth to EOA', async function () {
|
||||
@ -352,7 +352,7 @@ describe('GovernorTimelockControl', function () {
|
||||
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.connect(this.voter1).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter1).vote({ support: VoteType.For });
|
||||
await this.helper.waitForDeadline();
|
||||
await this.helper.queue();
|
||||
await this.helper.waitForEta();
|
||||
@ -397,7 +397,7 @@ describe('GovernorTimelockControl', function () {
|
||||
it('is protected', async function () {
|
||||
await expect(this.mock.connect(this.owner).updateTimelock(this.newTimelock))
|
||||
.to.be.revertedWithCustomError(this.mock, 'GovernorOnlyExecutor')
|
||||
.withArgs(this.owner.address);
|
||||
.withArgs(this.owner);
|
||||
});
|
||||
|
||||
it('can be executed through governance to', async function () {
|
||||
@ -413,16 +413,16 @@ describe('GovernorTimelockControl', function () {
|
||||
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.connect(this.voter1).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter1).vote({ support: VoteType.For });
|
||||
await this.helper.waitForDeadline();
|
||||
await this.helper.queue();
|
||||
await this.helper.waitForEta();
|
||||
|
||||
await expect(this.helper.execute())
|
||||
.to.emit(this.mock, 'TimelockChange')
|
||||
.withArgs(this.timelock.target, this.newTimelock.target);
|
||||
.withArgs(this.timelock, this.newTimelock);
|
||||
|
||||
expect(await this.mock.timelock()).to.equal(this.newTimelock.target);
|
||||
expect(await this.mock.timelock()).to.equal(this.newTimelock);
|
||||
});
|
||||
});
|
||||
|
||||
@ -489,7 +489,7 @@ describe('GovernorTimelockControl', function () {
|
||||
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.connect(this.voter1).vote({ support: Enums.VoteType.For });
|
||||
await this.helper.connect(this.voter1).vote({ support: VoteType.For });
|
||||
await this.helper.waitForDeadline();
|
||||
await this.helper.queue();
|
||||
await this.helper.waitForEta();
|
||||
|
||||
Reference in New Issue
Block a user