|
@@ -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();
|
|
|
+ it('after proposal', 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 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',
|
|
|
- );
|
|
|
- });
|
|
|
+ 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 });
|
|
|
+ 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();
|
|
|
- expect(await this.mock.state(this.proposal.id)).to.be.bignumber.equal(Enums.ProposalState.Canceled);
|
|
|
+ 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');
|
|
|
- });
|
|
|
+ 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();
|
|
|
+ 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');
|
|
|
+ });
|
|
|
|
|
|
- await this.helper.cancel();
|
|
|
- expect(await this.mock.state(this.proposal.id)).to.be.bignumber.equal(Enums.ProposalState.Canceled);
|
|
|
+ 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.execute(), 'Governor: proposal not successful');
|
|
|
+ await expectRevert(this.helper.cancel('internal'), 'Governor: proposal not active');
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
- 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();
|
|
|
+ describe('public', function () {
|
|
|
+ it('before proposal', async function () {
|
|
|
+ await expectRevert(this.helper.cancel('external'), 'Governor: unknown proposal id');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('after proposal', async function () {
|
|
|
+ await this.helper.propose();
|
|
|
+
|
|
|
+ await this.helper.cancel('external');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('after proposal - restricted to proposer', async function () {
|
|
|
+ await this.helper.propose();
|
|
|
+
|
|
|
+ await expectRevert(this.helper.cancel('external', { from: owner }), 'Governor: only proposer can cancel');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('after vote started', async function () {
|
|
|
+ await this.helper.propose();
|
|
|
+ await this.helper.waitForSnapshot(1); // snapshot + 1 block
|
|
|
+
|
|
|
+ await expectRevert(this.helper.cancel('external'), 'Governor: too late to cancel');
|
|
|
+ });
|
|
|
|
|
|
- await expectRevert(this.helper.cancel(), 'Governor: proposal not 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 expectRevert(this.helper.cancel('external'), 'Governor: too late to cancel');
|
|
|
+ });
|
|
|
+
|
|
|
+ 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');
|
|
|
+ });
|
|
|
+
|
|
|
+ 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');
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
|