Ensure AccessControlDefaultAdminRules's initialDefaultAdmin is non-zero (#4220)

Co-authored-by: Ernesto García <ernestognw@gmail.com>
pull/4222/head
Hadrien Croubois 2 years ago committed by GitHub
parent dcba9f995f
commit 72ed4ca67a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      contracts/access/AccessControlDefaultAdminRules.sol
  2. 9
      test/access/AccessControlDefaultAdminRules.test.js

@ -53,6 +53,7 @@ abstract contract AccessControlDefaultAdminRules is IAccessControlDefaultAdminRu
* @dev Sets the initial values for {defaultAdminDelay} and {defaultAdmin} address.
*/
constructor(uint48 initialDelay, address initialDefaultAdmin) {
require(initialDefaultAdmin != address(0), "AccessControl: 0 default admin");
_currentDelay = initialDelay;
_grantRole(DEFAULT_ADMIN_ROLE, initialDefaultAdmin);
}

@ -1,4 +1,4 @@
const { time } = require('@openzeppelin/test-helpers');
const { time, constants, expectRevert } = require('@openzeppelin/test-helpers');
const {
shouldBehaveLikeAccessControl,
shouldBehaveLikeAccessControlDefaultAdminRules,
@ -13,6 +13,13 @@ contract('AccessControlDefaultAdminRules', function (accounts) {
this.accessControl = await AccessControlDefaultAdminRules.new(delay, accounts[0], { from: accounts[0] });
});
it('initial admin not zero', async function () {
await expectRevert(
AccessControlDefaultAdminRules.new(delay, constants.ZERO_ADDRESS),
'AccessControl: 0 default admin',
);
});
shouldBehaveLikeAccessControl('AccessControl', ...accounts);
shouldBehaveLikeAccessControlDefaultAdminRules('AccessControl', delay, ...accounts);
});

Loading…
Cancel
Save