Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed May 10, 2023
1 parent 16738f6 commit 88df925
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions test/access/AccessControl.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,14 +621,17 @@ function shouldBehaveLikeAccessControlDefaultAdminRules(errorPrefix, delay, defa
});

describe('renounces admin', function () {
let expectedSchedule;
let delayPassed;
let delayNotPassed;

beforeEach(async function () {
await this.accessControl.beginDefaultAdminTransfer(constants.ZERO_ADDRESS, { from: defaultAdmin });
delayPassed = web3.utils
expectedSchedule = web3.utils
.toBN(await time.latest())
.add(delay)
.addn(1);
.add(delay);
delayNotPassed = expectedSchedule;
delayPassed = expectedSchedule.addn(1);
});

it('reverts if caller is not default admin', async function () {
Expand All @@ -639,6 +642,15 @@ function shouldBehaveLikeAccessControlDefaultAdminRules(errorPrefix, delay, defa
);
});

it('no op if renouncing when not having the role', async function () {
await time.setNextBlockTimestamp(delayPassed);
await this.accessControl.renounceRole(DEFAULT_ADMIN_ROLE, other, { from: other });

const { newAdmin, schedule } = await this.accessControl.pendingDefaultAdmin();
expect(newAdmin).to.equal(constants.ZERO_ADDRESS);
expect(schedule).to.be.bignumber.equal(expectedSchedule);
});

it('keeps defaultAdmin consistent with hasRole if another non-defaultAdmin user renounces the DEFAULT_ADMIN_ROLE', async function () {
await time.setNextBlockTimestamp(delayPassed);

Expand Down Expand Up @@ -677,12 +689,6 @@ function shouldBehaveLikeAccessControlDefaultAdminRules(errorPrefix, delay, defa
});

describe('schedule not passed', function () {
let delayNotPassed;

beforeEach(function () {
delayNotPassed = delayPassed.subn(1);
});

for (const [fromSchedule, tag] of [
[-1, 'less'],
[0, 'equal'],
Expand Down

0 comments on commit 88df925

Please sign in to comment.