Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
9be205d3
Unverified
Commit
9be205d3
authored
Jun 20, 2024
by
Maurelian
Committed by
GitHub
Jun 20, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ctb: Ensure equal number of Guardian and DG authed specs (#10955)
parent
eb4041a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
1 deletion
+33
-1
Specs.t.sol
packages/contracts-bedrock/test/Specs.t.sol
+33
-1
No files found.
packages/contracts-bedrock/test/Specs.t.sol
View file @
9be205d3
...
@@ -50,6 +50,7 @@ contract Specification_Test is CommonTest {
...
@@ -50,6 +50,7 @@ contract Specification_Test is CommonTest {
}
}
mapping(string => mapping(bytes4 => Spec)) specs;
mapping(string => mapping(bytes4 => Spec)) specs;
mapping(Role => Spec[]) public specsByRole;
mapping(string => uint256) public numEntries;
mapping(string => uint256) public numEntries;
uint256 numSpecs;
uint256 numSpecs;
...
@@ -833,8 +834,10 @@ contract Specification_Test is CommonTest {
...
@@ -833,8 +834,10 @@ contract Specification_Test is CommonTest {
/// @dev Adds a spec for a function.
/// @dev Adds a spec for a function.
function _addSpec(string memory _name, bytes4 _sel, Role _auth, bool _pausable) internal {
function _addSpec(string memory _name, bytes4 _sel, Role _auth, bool _pausable) internal {
specs[_name][_sel] = Spec({ name: _name, sel: _sel, auth: _auth, pausable: _pausable });
Spec memory spec = Spec({ name: _name, sel: _sel, auth: _auth, pausable: _pausable });
specs[_name][_sel] = spec;
numEntries[_name]++;
numEntries[_name]++;
specsByRole[_auth].push(spec);
numSpecs++;
numSpecs++;
}
}
...
@@ -894,4 +897,33 @@ contract Specification_Test is CommonTest {
...
@@ -894,4 +897,33 @@ contract Specification_Test is CommonTest {
}
}
assertEq(numSpecs, numCheckedEntries, "Some specs were not checked");
assertEq(numSpecs, numCheckedEntries, "Some specs were not checked");
}
}
/// @dev Asserts that two roles are equal by comparing their uint256 representations.
function _assertRolesEq(Role leftRole, Role rightRole) internal pure {
assertEq(uint256(leftRole), uint256(rightRole));
}
/// @notice Ensures that the DeputyGuardian is authorized to take all Guardian actions.
function testDeputyGuardianAuth() public view {
assertEq(specsByRole[Role.DEPUTYGUARDIAN].length, specsByRole[Role.GUARDIAN].length);
assertEq(specsByRole[Role.DEPUTYGUARDIAN].length, 4);
mapping(bytes4 => Spec) storage dgmFuncSpecs = specs["DeputyGuardianModule"];
mapping(bytes4 => Spec) storage superchainConfigFuncSpecs = specs["SuperchainConfig"];
mapping(bytes4 => Spec) storage portal2FuncSpecs = specs["OptimismPortal2"];
// Ensure that for each of the DeputyGuardianModule's methods there is a corresponding method on another
// system contract authed to the Guardian role.
_assertRolesEq(dgmFuncSpecs[_getSel("pause()")].auth, Role.DEPUTYGUARDIAN);
_assertRolesEq(superchainConfigFuncSpecs[_getSel("pause(string)")].auth, Role.GUARDIAN);
_assertRolesEq(dgmFuncSpecs[_getSel("unpause()")].auth, Role.DEPUTYGUARDIAN);
_assertRolesEq(superchainConfigFuncSpecs[_getSel("unpause()")].auth, Role.GUARDIAN);
_assertRolesEq(dgmFuncSpecs[_getSel("blacklistDisputeGame(address,address)")].auth, Role.DEPUTYGUARDIAN);
_assertRolesEq(portal2FuncSpecs[_getSel("blacklistDisputeGame(address)")].auth, Role.GUARDIAN);
_assertRolesEq(dgmFuncSpecs[_getSel("setRespectedGameType(address,uint32)")].auth, Role.DEPUTYGUARDIAN);
_assertRolesEq(portal2FuncSpecs[_getSel("setRespectedGameType(uint32)")].auth, Role.GUARDIAN);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment