Role library now requires non-zero addresses. (#1303)
* The role library now requires non-zero addresses. * Fixed SignatureBouncer checks with null address. * change ternary operator for or operator * adapt to new variable name convention * Update Roles.sol
This commit is contained in:
committed by
Francisco Giordano
parent
fa49e5189d
commit
6cae0f458d
@ -1,3 +1,5 @@
|
||||
const { assertRevert } = require('../helpers/assertRevert');
|
||||
|
||||
const RolesMock = artifacts.require('RolesMock');
|
||||
|
||||
require('chai')
|
||||
@ -10,6 +12,10 @@ contract('Roles', function ([_, authorized, otherAuthorized, anyone]) {
|
||||
this.roles = await RolesMock.new();
|
||||
});
|
||||
|
||||
it('reverts when querying roles for the null account', async function () {
|
||||
await assertRevert(this.roles.has(ZERO_ADDRESS));
|
||||
});
|
||||
|
||||
context('initially', function () {
|
||||
it('doesn\'t pre-assign roles', async function () {
|
||||
(await this.roles.has(authorized)).should.equal(false);
|
||||
@ -30,8 +36,8 @@ contract('Roles', function ([_, authorized, otherAuthorized, anyone]) {
|
||||
(await this.roles.has(authorized)).should.equal(true);
|
||||
});
|
||||
|
||||
it('doesn\'t revert when adding roles to the null account', async function () {
|
||||
await this.roles.add(ZERO_ADDRESS);
|
||||
it('reverts when adding roles to the null account', async function () {
|
||||
await assertRevert(this.roles.add(ZERO_ADDRESS));
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -53,8 +59,8 @@ contract('Roles', function ([_, authorized, otherAuthorized, anyone]) {
|
||||
await this.roles.remove(anyone);
|
||||
});
|
||||
|
||||
it('doesn\'t revert when removing roles from the null account', async function () {
|
||||
await this.roles.remove(ZERO_ADDRESS);
|
||||
it('reverts when removing roles from the null account', async function () {
|
||||
await assertRevert(this.roles.remove(ZERO_ADDRESS));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -19,6 +19,10 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
|
||||
(await this.contract[`is${rolename}`](anyone)).should.equal(false);
|
||||
});
|
||||
|
||||
it('reverts when querying roles for the null account', async function () {
|
||||
await assertRevert(this.contract[`is${rolename}`](ZERO_ADDRESS));
|
||||
});
|
||||
|
||||
describe('access control', function () {
|
||||
context('from authorized account', function () {
|
||||
const from = authorized;
|
||||
@ -53,8 +57,8 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
|
||||
(await this.contract[`is${rolename}`](authorized)).should.equal(true);
|
||||
});
|
||||
|
||||
it('doesn\'t revert when adding role to the null account', async function () {
|
||||
await this.contract[`add${rolename}`](ZERO_ADDRESS, { from: authorized });
|
||||
it('reverts when adding role to the null account', async function () {
|
||||
await assertRevert(this.contract[`add${rolename}`](ZERO_ADDRESS, { from: authorized }));
|
||||
});
|
||||
});
|
||||
|
||||
@ -74,8 +78,8 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
|
||||
await this.contract[`remove${rolename}`](anyone);
|
||||
});
|
||||
|
||||
it('doesn\'t revert when removing role from the null account', async function () {
|
||||
await this.contract[`remove${rolename}`](ZERO_ADDRESS);
|
||||
it('reverts when removing role from the null account', async function () {
|
||||
await assertRevert(this.contract[`remove${rolename}`](ZERO_ADDRESS));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user