Use Prettier for JS files (#3913)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Francisco
2023-01-04 11:03:40 -03:00
committed by GitHub
parent 88754d0b36
commit a28aafdc85
135 changed files with 2737 additions and 3121 deletions

View File

@ -7,7 +7,7 @@ const DEFAULT_ADMIN_ROLE = '0x00000000000000000000000000000000000000000000000000
const ROLE = web3.utils.soliditySha3('ROLE');
const OTHER_ROLE = web3.utils.soliditySha3('OTHER_ROLE');
function shouldBehaveLikeAccessControl (errorPrefix, admin, authorized, other, otherAdmin) {
function shouldBehaveLikeAccessControl(errorPrefix, admin, authorized, other, otherAdmin) {
shouldSupportInterfaces(['AccessControl']);
describe('default admin', function () {
@ -15,11 +15,11 @@ function shouldBehaveLikeAccessControl (errorPrefix, admin, authorized, other, o
expect(await this.accessControl.hasRole(DEFAULT_ADMIN_ROLE, admin)).to.equal(true);
});
it('other roles\'s admin is the default admin role', async function () {
it("other roles's admin is the default admin role", async function () {
expect(await this.accessControl.getRoleAdmin(ROLE)).to.equal(DEFAULT_ADMIN_ROLE);
});
it('default admin role\'s admin is itself', async function () {
it("default admin role's admin is itself", async function () {
expect(await this.accessControl.getRoleAdmin(DEFAULT_ADMIN_ROLE)).to.equal(DEFAULT_ADMIN_ROLE);
});
});
@ -125,7 +125,7 @@ function shouldBehaveLikeAccessControl (errorPrefix, admin, authorized, other, o
await this.accessControl.grantRole(OTHER_ROLE, otherAdmin, { from: admin });
});
it('a role\'s admin role can be changed', async function () {
it("a role's admin role can be changed", async function () {
expect(await this.accessControl.getRoleAdmin(ROLE)).to.equal(OTHER_ROLE);
});
@ -140,14 +140,14 @@ function shouldBehaveLikeAccessControl (errorPrefix, admin, authorized, other, o
expectEvent(receipt, 'RoleRevoked', { account: authorized, role: ROLE, sender: otherAdmin });
});
it('a role\'s previous admins no longer grant roles', async function () {
it("a role's previous admins no longer grant roles", async function () {
await expectRevert(
this.accessControl.grantRole(ROLE, authorized, { from: admin }),
`${errorPrefix}: account ${admin.toLowerCase()} is missing role ${OTHER_ROLE}`,
);
});
it('a role\'s previous admins no longer revoke roles', async function () {
it("a role's previous admins no longer revoke roles", async function () {
await expectRevert(
this.accessControl.revokeRole(ROLE, authorized, { from: admin }),
`${errorPrefix}: account ${admin.toLowerCase()} is missing role ${OTHER_ROLE}`,
@ -164,14 +164,14 @@ function shouldBehaveLikeAccessControl (errorPrefix, admin, authorized, other, o
await this.accessControl.methods['$_checkRole(bytes32)'](ROLE, { from: authorized });
});
it('revert if sender doesn\'t have role #1', async function () {
it("revert if sender doesn't have role #1", async function () {
await expectRevert(
this.accessControl.methods['$_checkRole(bytes32)'](ROLE, { from: other }),
`${errorPrefix}: account ${other.toLowerCase()} is missing role ${ROLE}`,
);
});
it('revert if sender doesn\'t have role #2', async function () {
it("revert if sender doesn't have role #2", async function () {
await expectRevert(
this.accessControl.methods['$_checkRole(bytes32)'](OTHER_ROLE, { from: authorized }),
`${errorPrefix}: account ${authorized.toLowerCase()} is missing role ${OTHER_ROLE}`,
@ -180,7 +180,7 @@ function shouldBehaveLikeAccessControl (errorPrefix, admin, authorized, other, o
});
}
function shouldBehaveLikeAccessControlEnumerable (errorPrefix, admin, authorized, other, otherAdmin, otherAuthorized) {
function shouldBehaveLikeAccessControlEnumerable(errorPrefix, admin, authorized, other, otherAdmin, otherAuthorized) {
shouldSupportInterfaces(['AccessControlEnumerable']);
describe('enumerating', function () {

View File

@ -1,7 +1,4 @@
const {
DEFAULT_ADMIN_ROLE,
shouldBehaveLikeAccessControl,
} = require('./AccessControl.behavior.js');
const { DEFAULT_ADMIN_ROLE, shouldBehaveLikeAccessControl } = require('./AccessControl.behavior.js');
const AccessControl = artifacts.require('$AccessControl');

View File

@ -1,15 +1,13 @@
const { expectRevert } = require('@openzeppelin/test-helpers');
const { BridgeHelper } = require('../helpers/crosschain');
const {
DEFAULT_ADMIN_ROLE,
shouldBehaveLikeAccessControl,
} = require('./AccessControl.behavior.js');
const { DEFAULT_ADMIN_ROLE, shouldBehaveLikeAccessControl } = require('./AccessControl.behavior.js');
const crossChainRoleAlias = (role) => web3.utils.leftPad(
web3.utils.toHex(web3.utils.toBN(role).xor(web3.utils.toBN(web3.utils.soliditySha3('CROSSCHAIN_ALIAS')))),
64,
);
const crossChainRoleAlias = role =>
web3.utils.leftPad(
web3.utils.toHex(web3.utils.toBN(role).xor(web3.utils.toBN(web3.utils.soliditySha3('CROSSCHAIN_ALIAS')))),
64,
);
const AccessControlCrossChainMock = artifacts.require('$AccessControlCrossChainMock');
@ -39,23 +37,13 @@ contract('AccessControl', function (accounts) {
it('Crosschain calls not authorized to non-aliased addresses', async function () {
await expectRevert(
this.bridge.call(
accounts[0],
this.accessControl,
'$_checkRole(bytes32)',
[ ROLE ],
),
this.bridge.call(accounts[0], this.accessControl, '$_checkRole(bytes32)', [ROLE]),
`AccessControl: account ${accounts[0].toLowerCase()} is missing role ${crossChainRoleAlias(ROLE)}`,
);
});
it('Crosschain calls not authorized to non-aliased addresses', async function () {
await this.bridge.call(
accounts[1],
this.accessControl,
'$_checkRole(bytes32)',
[ ROLE ],
);
await this.bridge.call(accounts[1], this.accessControl, '$_checkRole(bytes32)', [ROLE]);
});
});
});

View File

@ -6,7 +6,7 @@ const { expect } = require('chai');
const Ownable = artifacts.require('$Ownable');
contract('Ownable', function (accounts) {
const [ owner, other ] = accounts;
const [owner, other] = accounts;
beforeEach(async function () {
this.ownable = await Ownable.new({ from: owner });
@ -25,10 +25,7 @@ contract('Ownable', function (accounts) {
});
it('prevents non-owners from transferring', async function () {
await expectRevert(
this.ownable.transferOwnership(other, { from: other }),
'Ownable: caller is not the owner',
);
await expectRevert(this.ownable.transferOwnership(other, { from: other }), 'Ownable: caller is not the owner');
});
it('guards ownership against stuck state', async function () {
@ -48,10 +45,7 @@ contract('Ownable', function (accounts) {
});
it('prevents non-owners from renouncement', async function () {
await expectRevert(
this.ownable.renounceOwnership({ from: other }),
'Ownable: caller is not the owner',
);
await expectRevert(this.ownable.renounceOwnership({ from: other }), 'Ownable: caller is not the owner');
});
});
});