RBACMintableToken.behaviour.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. const { expectThrow } = require('../../helpers/expectThrow');
  2. const ROLE_MINTER = 'minter';
  3. function shouldBehaveLikeRBACMintableToken ([owner, anotherAccount]) {
  4. describe('handle roles', function () {
  5. it('owner can add and remove a minter role', async function () {
  6. await this.token.addMinter(anotherAccount, { from: owner });
  7. let hasRole = await this.token.hasRole(anotherAccount, ROLE_MINTER);
  8. assert.equal(hasRole, true);
  9. await this.token.removeMinter(anotherAccount, { from: owner });
  10. hasRole = await this.token.hasRole(anotherAccount, ROLE_MINTER);
  11. assert.equal(hasRole, false);
  12. });
  13. it('another account can\'t add or remove a minter role', async function () {
  14. await expectThrow(
  15. this.token.addMinter(anotherAccount, { from: anotherAccount })
  16. );
  17. await this.token.addMinter(anotherAccount, { from: owner });
  18. await expectThrow(
  19. this.token.removeMinter(anotherAccount, { from: anotherAccount })
  20. );
  21. });
  22. });
  23. }
  24. module.exports = {
  25. shouldBehaveLikeRBACMintableToken,
  26. };