From 254210f699cc9606d1c8600abaf1217e2f9cad7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Fri, 7 Sep 2018 11:11:27 -0300 Subject: [PATCH] Improve role behavior tests (#1300) * The public role behavior now also tests the modifer. * Fixed linter error. --- test/access/roles/PublicRole.behavior.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/access/roles/PublicRole.behavior.js b/test/access/roles/PublicRole.behavior.js index c6c3bc990..34cdbe5dd 100644 --- a/test/access/roles/PublicRole.behavior.js +++ b/test/access/roles/PublicRole.behavior.js @@ -1,3 +1,4 @@ +const { assertRevert } = require('../../helpers/assertRevert'); const expectEvent = require('../../helpers/expectEvent'); require('chai') @@ -18,6 +19,24 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role (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 () { it('adds role to a new account', async function () { await this.contract[`add${rolename}`](anyone, { from: authorized });