RBACMintableToken.behavior.js 1010 B

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