* Now compiling using truffle 5.
* Migrated some test files, missing BN scientific notation usage.
* Now using BN time values.
* Migrate ERC20 tests.
* Migrate all ERC20 tests.
* Migrate utils, payment and ownership tests.
* All tests save ERC721 migrated.
* Migrated ERC721 tests.
* Fix lint errors.
* Delete old test helpers.
* Fix remaining crowdsale tests.
* Fix signature bouncer tests.
* Update how constants is used.
* Compile script pre-removes the build dir.
* Fix SafeMath tests.
* Revert "Compile script pre-removes the build dir."
This reverts commit 247e745113.
* Fix linter errors.
* Upgrade openzeppelin-test-helpers dependency.
* Update openzeppelin-test-helpers dependency.
* Define math constants globally.
* Remove unnecessary ether unit.
* Roll back reduced ether amounts in tests.
* Remove unnecessary toNumber conversions.
* Delete compile script.
* Fixed failing test.
63 lines
2.1 KiB
JavaScript
63 lines
2.1 KiB
JavaScript
const { shouldFail, constants } = require('openzeppelin-test-helpers');
|
|
const { ZERO_ADDRESS } = constants;
|
|
|
|
const RolesMock = artifacts.require('RolesMock');
|
|
|
|
contract('Roles', function ([_, authorized, otherAuthorized, anyone]) {
|
|
beforeEach(async function () {
|
|
this.roles = await RolesMock.new();
|
|
});
|
|
|
|
it('reverts when querying roles for the null account', async function () {
|
|
await shouldFail.reverting(this.roles.has(ZERO_ADDRESS));
|
|
});
|
|
|
|
context('initially', function () {
|
|
it('doesn\'t pre-assign roles', async function () {
|
|
(await this.roles.has(authorized)).should.equal(false);
|
|
(await this.roles.has(otherAuthorized)).should.equal(false);
|
|
(await this.roles.has(anyone)).should.equal(false);
|
|
});
|
|
|
|
describe('adding roles', function () {
|
|
it('adds roles to a single account', async function () {
|
|
await this.roles.add(authorized);
|
|
(await this.roles.has(authorized)).should.equal(true);
|
|
(await this.roles.has(anyone)).should.equal(false);
|
|
});
|
|
|
|
it('reverts when adding roles to an already assigned account', async function () {
|
|
await this.roles.add(authorized);
|
|
await shouldFail.reverting(this.roles.add(authorized));
|
|
});
|
|
|
|
it('reverts when adding roles to the null account', async function () {
|
|
await shouldFail.reverting(this.roles.add(ZERO_ADDRESS));
|
|
});
|
|
});
|
|
});
|
|
|
|
context('with added roles', function () {
|
|
beforeEach(async function () {
|
|
await this.roles.add(authorized);
|
|
await this.roles.add(otherAuthorized);
|
|
});
|
|
|
|
describe('removing roles', function () {
|
|
it('removes a single role', async function () {
|
|
await this.roles.remove(authorized);
|
|
(await this.roles.has(authorized)).should.equal(false);
|
|
(await this.roles.has(otherAuthorized)).should.equal(true);
|
|
});
|
|
|
|
it('reverts when removing unassigned roles', async function () {
|
|
await shouldFail.reverting(this.roles.remove(anyone));
|
|
});
|
|
|
|
it('reverts when removing roles from the null account', async function () {
|
|
await shouldFail.reverting(this.roles.remove(ZERO_ADDRESS));
|
|
});
|
|
});
|
|
});
|
|
});
|