Add a public Governor.cancel function (#3983)
This commit is contained in:
@ -382,55 +382,109 @@ contract('Governor', function (accounts) {
|
||||
});
|
||||
|
||||
describe('cancel', function () {
|
||||
it('before proposal', async function () {
|
||||
await expectRevert(this.helper.cancel(), 'Governor: unknown proposal id');
|
||||
describe('internal', function () {
|
||||
it('before proposal', async function () {
|
||||
await expectRevert(this.helper.cancel('internal'), 'Governor: unknown proposal id');
|
||||
});
|
||||
|
||||
it('after proposal', async function () {
|
||||
await this.helper.propose();
|
||||
|
||||
await this.helper.cancel('internal');
|
||||
expect(await this.mock.state(this.proposal.id)).to.be.bignumber.equal(Enums.ProposalState.Canceled);
|
||||
|
||||
await this.helper.waitForSnapshot();
|
||||
await expectRevert(
|
||||
this.helper.vote({ support: Enums.VoteType.For }, { from: voter1 }),
|
||||
'Governor: vote not currently active',
|
||||
);
|
||||
});
|
||||
|
||||
it('after vote', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.vote({ support: Enums.VoteType.For }, { from: voter1 });
|
||||
|
||||
await this.helper.cancel('internal');
|
||||
expect(await this.mock.state(this.proposal.id)).to.be.bignumber.equal(Enums.ProposalState.Canceled);
|
||||
|
||||
await this.helper.waitForDeadline();
|
||||
await expectRevert(this.helper.execute(), 'Governor: proposal not successful');
|
||||
});
|
||||
|
||||
it('after deadline', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.vote({ support: Enums.VoteType.For }, { from: voter1 });
|
||||
await this.helper.waitForDeadline();
|
||||
|
||||
await this.helper.cancel('internal');
|
||||
expect(await this.mock.state(this.proposal.id)).to.be.bignumber.equal(Enums.ProposalState.Canceled);
|
||||
|
||||
await expectRevert(this.helper.execute(), 'Governor: proposal not successful');
|
||||
});
|
||||
|
||||
it('after execution', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.vote({ support: Enums.VoteType.For }, { from: voter1 });
|
||||
await this.helper.waitForDeadline();
|
||||
await this.helper.execute();
|
||||
|
||||
await expectRevert(this.helper.cancel('internal'), 'Governor: proposal not active');
|
||||
});
|
||||
});
|
||||
|
||||
it('after proposal', async function () {
|
||||
await this.helper.propose();
|
||||
describe('public', function () {
|
||||
it('before proposal', async function () {
|
||||
await expectRevert(this.helper.cancel('external'), 'Governor: unknown proposal id');
|
||||
});
|
||||
|
||||
await this.helper.cancel();
|
||||
expect(await this.mock.state(this.proposal.id)).to.be.bignumber.equal(Enums.ProposalState.Canceled);
|
||||
it('after proposal', async function () {
|
||||
await this.helper.propose();
|
||||
|
||||
await this.helper.waitForSnapshot();
|
||||
await expectRevert(
|
||||
this.helper.vote({ support: Enums.VoteType.For }, { from: voter1 }),
|
||||
'Governor: vote not currently active',
|
||||
);
|
||||
});
|
||||
await this.helper.cancel('external');
|
||||
});
|
||||
|
||||
it('after vote', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.vote({ support: Enums.VoteType.For }, { from: voter1 });
|
||||
it('after proposal - restricted to proposer', async function () {
|
||||
await this.helper.propose();
|
||||
|
||||
await this.helper.cancel();
|
||||
expect(await this.mock.state(this.proposal.id)).to.be.bignumber.equal(Enums.ProposalState.Canceled);
|
||||
await expectRevert(this.helper.cancel('external', { from: owner }), 'Governor: only proposer can cancel');
|
||||
});
|
||||
|
||||
await this.helper.waitForDeadline();
|
||||
await expectRevert(this.helper.execute(), 'Governor: proposal not successful');
|
||||
});
|
||||
it('after vote started', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot(1); // snapshot + 1 block
|
||||
|
||||
it('after deadline', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.vote({ support: Enums.VoteType.For }, { from: voter1 });
|
||||
await this.helper.waitForDeadline();
|
||||
await expectRevert(this.helper.cancel('external'), 'Governor: too late to cancel');
|
||||
});
|
||||
|
||||
await this.helper.cancel();
|
||||
expect(await this.mock.state(this.proposal.id)).to.be.bignumber.equal(Enums.ProposalState.Canceled);
|
||||
it('after vote', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.vote({ support: Enums.VoteType.For }, { from: voter1 });
|
||||
|
||||
await expectRevert(this.helper.execute(), 'Governor: proposal not successful');
|
||||
});
|
||||
await expectRevert(this.helper.cancel('external'), 'Governor: too late to cancel');
|
||||
});
|
||||
|
||||
it('after execution', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.vote({ support: Enums.VoteType.For }, { from: voter1 });
|
||||
await this.helper.waitForDeadline();
|
||||
await this.helper.execute();
|
||||
it('after deadline', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.vote({ support: Enums.VoteType.For }, { from: voter1 });
|
||||
await this.helper.waitForDeadline();
|
||||
|
||||
await expectRevert(this.helper.cancel(), 'Governor: proposal not active');
|
||||
await expectRevert(this.helper.cancel('external'), 'Governor: too late to cancel');
|
||||
});
|
||||
|
||||
it('after execution', async function () {
|
||||
await this.helper.propose();
|
||||
await this.helper.waitForSnapshot();
|
||||
await this.helper.vote({ support: Enums.VoteType.For }, { from: voter1 });
|
||||
await this.helper.waitForDeadline();
|
||||
await this.helper.execute();
|
||||
|
||||
await expectRevert(this.helper.cancel('external'), 'Governor: too late to cancel');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user