RBACMintableToken.behaviour.js 1016 B

12345678910111213141516171819202122232425262728
  1. import expectThrow from '../../helpers/expectThrow';
  2. const ROLE_MINTER = 'minter';
  3. export default function ([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. };