Skip to content

Commit

Permalink
test: cancellation of Defeated and Excecuted states
Browse files Browse the repository at this point in the history
  • Loading branch information
TravellerOnTheRun committed Oct 11, 2024
1 parent aa1920d commit 29b847a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/Governor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,50 @@ describe('Governor Contact', () => {
expect(tx).to.be.revertedWithCustomError({ interface: governor.interface }, unexpectedProposalState)
})

it('should NOT be possible to cancel Proposal.Defeated', async () => {
await createProposal('guardian cancelling defeated', holders[1])
await mine((await governor.votingDelay()) + 1n)

await mine(initialVotingDelay + initialVotingPeriod + 1n)

expect(await getState()).to.be.equal(ProposalState.Defeated)

const tx = governor.connect(deployer)['cancel(uint256)'](proposalId)
expect(tx).to.be.revertedWithCustomError({ interface: governor.interface }, unexpectedProposalState)
})

it('should NOT be possible to cancel Proposal.Executed', async () => {
const description = 'guardian cancelling Executed'
//create proposal
await createProposal(description, holders[1])
await mine((await governor.votingDelay()) + 1n)

await voteToSucceed()
expect(await getState()).to.be.equal(ProposalState.Succeeded)

const needsQueuing = await governor.proposalNeedsQueuing(proposalId)
expect(needsQueuing).to.be.true

await queueProposal()
const queuedState = await governor.state(proposalId)
expect(queuedState).to.be.equal(ProposalState.Queued)

await time.increaseTo(eta)
const block = await ethers.provider.getBlock('latest')
expect(block?.timestamp).to.equal(eta)

const executeTx = await governor['execute(address[],uint256[],bytes[],bytes32)'](
...proposal,
generateDescriptionHash(description),
)
await expect(executeTx).to.emit(governor, 'ProposalExecuted').withArgs(proposalId)
const state = await getState()
expect(state).to.equal(ProposalState.Executed)

const tx = governor.connect(deployer)['cancel(uint256)'](proposalId)
expect(tx).to.be.revertedWithCustomError({ interface: governor.interface }, unexpectedProposalState)
})

it('should be able to cancel ProposalState.Succceded', async () => {
//cancelling ProposalState.Succceded as guardian
await createProposal('guardian cancelling succeeded', holders[1])
Expand Down

0 comments on commit 29b847a

Please sign in to comment.