Skip to content

Commit

Permalink
add explicit test when auth revert without permission
Browse files Browse the repository at this point in the history
  • Loading branch information
Rekard0 committed Oct 31, 2024
1 parent f365fb5 commit 9f4dbf2
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions packages/contracts/test/10_unit-testing/11_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,64 @@ describe('TokenVoting', function () {
.to.be.revertedWithCustomError(plugin, 'ProposalExecutionForbidden')
.withArgs(id);
});

it.only('can not execute even if participation and support are met when caller does not have permission', async () => {
const {
alice,
bob,
carol,
dave,
eve,
frank,
grace,
initializedPlugin: plugin,
dummyMetadata,
dummyActions,
dao,
} = await loadFixture(localFixture);

const endDate = (await time.latest()) + TIME.DAY;
const id = await createProposalId(
plugin.address,
dummyActions,
dummyMetadata
);

// Create a proposal.
await plugin[CREATE_PROPOSAL_SIGNATURE](
dummyMetadata,
dummyActions,
0,
0,
endDate,
VoteOption.None,
false
);

// Vote with enough voters so that the execution criteria are met.
await voteWithSigners(plugin, id, {
yes: [alice, bob, carol], // 30 votes
no: [dave, eve], // 20 votes
abstain: [frank, grace], // 20 votes
});

// Wait until the vote is over.
await time.increaseTo(endDate);

// Check that the proposal can be executed.
expect(await plugin.isSupportThresholdReached(id)).to.be.true;
expect(await plugin.isMinParticipationReached(id)).to.be.true;
expect(await plugin.canExecute(id)).to.equal(true);

await expect(plugin.connect(alice).execute(id))
.to.be.revertedWithCustomError(plugin, 'DaoUnauthorized')
.withArgs(
dao.address,
plugin.address,
alice.address,
EXECUTE_PROPOSAL_PERMISSION_ID
);
});
});

describe('Early Execution', async () => {
Expand Down

0 comments on commit 9f4dbf2

Please sign in to comment.