Added events to the role contracts. (#1302)
* Added events to the role contracts. * Fixed linter error.
This commit is contained in:
committed by
Francisco Giordano
parent
84e63bbf8b
commit
951460696e
@ -6,6 +6,9 @@ import "../Roles.sol";
|
||||
contract CapperRole {
|
||||
using Roles for Roles.Role;
|
||||
|
||||
event CapperAdded(address indexed account);
|
||||
event CapperRemoved(address indexed account);
|
||||
|
||||
Roles.Role private cappers;
|
||||
|
||||
constructor() public {
|
||||
@ -23,6 +26,7 @@ contract CapperRole {
|
||||
|
||||
function addCapper(address _account) public onlyCapper {
|
||||
cappers.add(_account);
|
||||
emit CapperAdded(_account);
|
||||
}
|
||||
|
||||
function renounceCapper() public {
|
||||
@ -31,5 +35,6 @@ contract CapperRole {
|
||||
|
||||
function _removeCapper(address _account) internal {
|
||||
cappers.remove(_account);
|
||||
emit CapperRemoved(_account);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,9 @@ import "../Roles.sol";
|
||||
contract MinterRole {
|
||||
using Roles for Roles.Role;
|
||||
|
||||
event MinterAdded(address indexed account);
|
||||
event MinterRemoved(address indexed account);
|
||||
|
||||
Roles.Role private minters;
|
||||
|
||||
constructor() public {
|
||||
@ -23,6 +26,7 @@ contract MinterRole {
|
||||
|
||||
function addMinter(address _account) public onlyMinter {
|
||||
minters.add(_account);
|
||||
emit MinterAdded(_account);
|
||||
}
|
||||
|
||||
function renounceMinter() public {
|
||||
@ -31,5 +35,6 @@ contract MinterRole {
|
||||
|
||||
function _removeMinter(address _account) internal {
|
||||
minters.remove(_account);
|
||||
emit MinterRemoved(_account);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,9 @@ import "../Roles.sol";
|
||||
contract PauserRole {
|
||||
using Roles for Roles.Role;
|
||||
|
||||
event PauserAdded(address indexed account);
|
||||
event PauserRemoved(address indexed account);
|
||||
|
||||
Roles.Role private pausers;
|
||||
|
||||
constructor() public {
|
||||
@ -23,6 +26,7 @@ contract PauserRole {
|
||||
|
||||
function addPauser(address _account) public onlyPauser {
|
||||
pausers.add(_account);
|
||||
emit PauserAdded(_account);
|
||||
}
|
||||
|
||||
function renouncePauser() public {
|
||||
@ -31,5 +35,6 @@ contract PauserRole {
|
||||
|
||||
function _removePauser(address _account) internal {
|
||||
pausers.remove(_account);
|
||||
emit PauserRemoved(_account);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,9 @@ import "../Roles.sol";
|
||||
contract SignerRole {
|
||||
using Roles for Roles.Role;
|
||||
|
||||
event SignerAdded(address indexed account);
|
||||
event SignerRemoved(address indexed account);
|
||||
|
||||
Roles.Role private signers;
|
||||
|
||||
constructor() public {
|
||||
@ -23,6 +26,7 @@ contract SignerRole {
|
||||
|
||||
function addSigner(address _account) public onlySigner {
|
||||
signers.add(_account);
|
||||
emit SignerAdded(_account);
|
||||
}
|
||||
|
||||
function renounceSigner() public {
|
||||
@ -31,5 +35,6 @@ contract SignerRole {
|
||||
|
||||
function _removeSigner(address _account) internal {
|
||||
signers.remove(_account);
|
||||
emit SignerRemoved(_account);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
const expectEvent = require('../../helpers/expectEvent');
|
||||
|
||||
require('chai')
|
||||
.should();
|
||||
|
||||
@ -22,6 +24,11 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
|
||||
(await this.contract[`is${rolename}`](anyone)).should.equal(true);
|
||||
});
|
||||
|
||||
it(`emits a ${rolename}Added event`, async function () {
|
||||
const { logs } = await this.contract[`add${rolename}`](anyone, { from: authorized });
|
||||
expectEvent.inLogs(logs, `${rolename}Added`, { account: anyone });
|
||||
});
|
||||
|
||||
it('adds role to an already-assigned account', async function () {
|
||||
await this.contract[`add${rolename}`](authorized, { from: authorized });
|
||||
(await this.contract[`is${rolename}`](authorized)).should.equal(true);
|
||||
@ -39,6 +46,11 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
|
||||
(await this.contract[`is${rolename}`](otherAuthorized)).should.equal(true);
|
||||
});
|
||||
|
||||
it(`emits a ${rolename}Removed event`, async function () {
|
||||
const { logs } = await this.contract[`remove${rolename}`](authorized);
|
||||
expectEvent.inLogs(logs, `${rolename}Removed`, { account: authorized });
|
||||
});
|
||||
|
||||
it('doesn\'t revert when removing from an unassigned account', async function () {
|
||||
await this.contract[`remove${rolename}`](anyone);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user