Update docs
This commit is contained in:
@ -1,16 +1,15 @@
|
||||
const { expectRevert } = require('@openzeppelin/test-helpers');
|
||||
const { BridgeHelper } = require('../helpers/crosschain');
|
||||
|
||||
const {
|
||||
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');
|
||||
const AccessControlCrossChainMock = artifacts.require('$AccessControlCrossChainMock');
|
||||
|
||||
const ROLE = web3.utils.soliditySha3('ROLE');
|
||||
|
||||
@ -21,6 +20,7 @@ contract('AccessControl', function (accounts) {
|
||||
|
||||
beforeEach(async function () {
|
||||
this.accessControl = await AccessControlCrossChainMock.new({ from: accounts[0] });
|
||||
await this.accessControl.$_grantRole(DEFAULT_ADMIN_ROLE, accounts[0]);
|
||||
});
|
||||
|
||||
shouldBehaveLikeAccessControl('AccessControl', ...accounts);
|
||||
@ -32,28 +32,18 @@ contract('AccessControl', function (accounts) {
|
||||
});
|
||||
|
||||
it('check alliassing', async function () {
|
||||
expect(await this.accessControl.crossChainRoleAlias(ROLE)).to.be.bignumber.equal(crossChainRoleAlias(ROLE));
|
||||
expect(await this.accessControl.$_crossChainRoleAlias(ROLE)).to.be.bignumber.equal(crossChainRoleAlias(ROLE));
|
||||
});
|
||||
|
||||
it('Crosschain calls not authorized to non-aliased addresses', async function () {
|
||||
await expectRevert(
|
||||
this.bridge.call(
|
||||
accounts[0],
|
||||
this.accessControl,
|
||||
'senderProtected',
|
||||
[ 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,
|
||||
'senderProtected',
|
||||
[ ROLE ],
|
||||
);
|
||||
await this.bridge.call(accounts[1], this.accessControl, '$_checkRole(bytes32)', [ROLE]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user