RBACMintableToken.behavior.js 936 B

123456789101112131415161718192021222324252627282930
  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. (await this.token.hasRole(anyone, ROLE_MINTER)).should.equal(true);
  8. await this.token.removeMinter(anyone, { from: owner });
  9. (await this.token.hasRole(anyone, ROLE_MINTER)).should.equal(false);
  10. });
  11. it('anyone can\'t add or remove a minter role', async function () {
  12. await expectThrow(
  13. this.token.addMinter(anyone, { from: anyone })
  14. );
  15. await this.token.addMinter(anyone, { from: owner });
  16. await expectThrow(
  17. this.token.removeMinter(anyone, { from: anyone })
  18. );
  19. });
  20. });
  21. }
  22. module.exports = {
  23. shouldBehaveLikeRBACMintableToken,
  24. };