Unverified Commit 254210f6 by Nicolás Venturo Committed by GitHub

Improve role behavior tests (#1300)

* The public role behavior now also tests the modifer.

* Fixed linter error.
parent 95146069
const { assertRevert } = require('../../helpers/assertRevert');
const expectEvent = require('../../helpers/expectEvent'); const expectEvent = require('../../helpers/expectEvent');
require('chai') require('chai')
...@@ -18,6 +19,24 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role ...@@ -18,6 +19,24 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
(await this.contract[`is${rolename}`](anyone)).should.equal(false); (await this.contract[`is${rolename}`](anyone)).should.equal(false);
}); });
describe('access control', function () {
context('from authorized account', function () {
const from = authorized;
it('allows access', async function () {
await this.contract[`only${rolename}Mock`]({ from });
});
});
context('from unauthorized account', function () {
const from = anyone;
it('reverts', async function () {
await assertRevert(this.contract[`only${rolename}Mock`]({ from }));
});
});
});
describe('add', function () { describe('add', function () {
it('adds role to a new account', async function () { it('adds role to a new account', async function () {
await this.contract[`add${rolename}`](anyone, { from: authorized }); await this.contract[`add${rolename}`](anyone, { from: authorized });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment