You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1020 B
33 lines
1020 B
7 years ago
|
const { expectThrow } = require('../../helpers/expectThrow');
|
||
7 years ago
|
|
||
|
const ROLE_MINTER = 'minter';
|
||
|
|
||
7 years ago
|
function shouldBehaveLikeRBACMintableToken (owner, [anyone]) {
|
||
7 years ago
|
describe('handle roles', function () {
|
||
|
it('owner can add and remove a minter role', async function () {
|
||
7 years ago
|
await this.token.addMinter(anyone, { from: owner });
|
||
|
let hasRole = await this.token.hasRole(anyone, ROLE_MINTER);
|
||
7 years ago
|
assert.equal(hasRole, true);
|
||
|
|
||
7 years ago
|
await this.token.removeMinter(anyone, { from: owner });
|
||
|
hasRole = await this.token.hasRole(anyone, ROLE_MINTER);
|
||
7 years ago
|
assert.equal(hasRole, false);
|
||
|
});
|
||
|
|
||
7 years ago
|
it('anyone can\'t add or remove a minter role', async function () {
|
||
7 years ago
|
await expectThrow(
|
||
7 years ago
|
this.token.addMinter(anyone, { from: anyone })
|
||
7 years ago
|
);
|
||
|
|
||
7 years ago
|
await this.token.addMinter(anyone, { from: owner });
|
||
7 years ago
|
await expectThrow(
|
||
7 years ago
|
this.token.removeMinter(anyone, { from: anyone })
|
||
7 years ago
|
);
|
||
|
});
|
||
7 years ago
|
});
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
shouldBehaveLikeRBACMintableToken,
|
||
7 years ago
|
};
|