Added events to the role contracts. (#1302)

* Added events to the role contracts.

* Fixed linter error.
This commit is contained in:
Nicolás Venturo
2018-09-07 10:04:52 -03:00
committed by Francisco Giordano
parent 84e63bbf8b
commit 951460696e
5 changed files with 32 additions and 0 deletions

View File

@ -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);
});