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
99810e0b
Unverified
Commit
99810e0b
authored
Nov 22, 2024
by
Matthew Slipper
Committed by
GitHub
Nov 22, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "improve Legacy Contract tests (#13022)" (#13031)
This reverts commit
8f5c20ee
.
parent
5aa14b37
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
96 deletions
+5
-96
DeployerWhitelist.t.sol
...ges/contracts-bedrock/test/legacy/DeployerWhitelist.t.sol
+4
-95
L1BlockNumber.t.sol
packages/contracts-bedrock/test/legacy/L1BlockNumber.t.sol
+1
-1
No files found.
packages/contracts-bedrock/test/legacy/DeployerWhitelist.t.sol
View file @
99810e0b
...
...
@@ -10,11 +10,6 @@ import { DeployUtils } from "scripts/libraries/DeployUtils.sol";
contract DeployerWhitelist_Test is Test {
IDeployerWhitelist list;
address owner = address(12345);
event OwnerChanged(address oldOwner, address newOwner);
event WhitelistDisabled(address oldOwner);
event WhitelistStatusChanged(address deployer, bool whitelisted);
/// @dev Sets up the test suite.
function setUp() public {
...
...
@@ -32,96 +27,10 @@ contract DeployerWhitelist_Test is Test {
}
/// @dev Tests that `setOwner` correctly sets the contract owner.
function test_setOwner_succeeds(address _owner) external {
vm.store(address(list), bytes32(uint256(0)), bytes32(uint256(uint160(owner))));
assertEq(list.owner(), owner);
_owner = address(uint160(bound(uint160(_owner), 1, type(uint160).max)));
vm.prank(owner);
vm.expectEmit(true, true, true, true);
emit OwnerChanged(owner, _owner);
list.setOwner(_owner);
assertEq(list.owner(), _owner);
}
/// @dev Tests that `setOwner` reverts when the caller is not the owner.
function test_setOwner_reverts(address _caller, address _owner) external {
vm.store(address(list), bytes32(uint256(0)), bytes32(uint256(uint160(owner))));
assertEq(list.owner(), owner);
vm.assume(_caller != owner);
vm.prank(_caller);
vm.expectRevert(bytes("DeployerWhitelist: function can only be called by the owner of this contract"));
list.setOwner(_owner);
}
/// @dev Tests that `setOwner` reverts when the new owner is the zero address.
function test_setOwner_reverts_zeroAddress() external {
vm.store(address(list), bytes32(uint256(0)), bytes32(uint256(uint160(owner))));
assertEq(list.owner(), owner);
vm.prank(owner);
vm.expectRevert(bytes("DeployerWhitelist: can only be disabled via enableArbitraryContractDeployment"));
list.setOwner(address(0));
}
/// @dev Tests that `enableArbitraryContractDeployment` correctly disables the whitelist.
function test_enableArbitraryContractDeployment_succeeds() external {
vm.store(address(list), bytes32(uint256(0)), bytes32(uint256(uint160(owner))));
assertEq(list.owner(), owner);
vm.prank(owner);
vm.expectEmit(true, true, true, true);
emit WhitelistDisabled(owner);
list.enableArbitraryContractDeployment();
assertEq(list.owner(), address(0));
// Any address is allowed to deploy contracts even if they are not whitelisted
assertEq(list.whitelist(address(1)), false);
assertEq(list.isDeployerAllowed(address(1)), true);
}
/// @dev Tests that `enableArbitraryContractDeployment` reverts when the caller is not the owner.
function test_enableArbitraryContractDeployment_reverts(address _caller) external {
vm.store(address(list), bytes32(uint256(0)), bytes32(uint256(uint160(owner))));
assertEq(list.owner(), owner);
vm.assume(_caller != owner);
vm.prank(_caller);
vm.expectRevert(bytes("DeployerWhitelist: function can only be called by the owner of this contract"));
list.enableArbitraryContractDeployment();
}
/// @dev Tests that `setWhitelistedDeployer` correctly sets the whitelist status of a deployer.
function test_setWhitelistedDeployer_succeeds(address _deployer, bool _isWhitelisted) external {
vm.store(address(list), bytes32(uint256(0)), bytes32(uint256(uint160(owner))));
assertEq(list.owner(), owner);
vm.prank(owner);
vm.expectEmit(true, true, true, true);
emit WhitelistStatusChanged(_deployer, _isWhitelisted);
list.setWhitelistedDeployer(_deployer, _isWhitelisted);
assertEq(list.whitelist(_deployer), _isWhitelisted);
// _deployer is whitelisted or not (and arbitrary contract deployment is not enabled)
assertNotEq(list.owner(), address(0));
assertEq(list.isDeployerAllowed(_deployer), _isWhitelisted);
}
/// @dev Tests that `setWhitelistedDeployer` reverts when the caller is not the owner.
function test_setWhitelistedDeployer_reverts(address _caller, address _deployer, bool _isWhitelisted) external {
vm.store(address(list), bytes32(uint256(0)), bytes32(uint256(uint160(owner))));
assertEq(list.owner(), owner);
vm.assume(_caller != owner);
function test_storageSlots_succeeds() external {
vm.prank(list.owner());
list.setOwner(address(1));
vm.prank(_caller);
vm.expectRevert(bytes("DeployerWhitelist: function can only be called by the owner of this contract"));
list.setWhitelistedDeployer(_deployer, _isWhitelisted);
assertEq(bytes32(uint256(1)), vm.load(address(list), bytes32(uint256(0))));
}
}
packages/contracts-bedrock/test/legacy/L1BlockNumber.t.sol
View file @
99810e0b
...
...
@@ -49,7 +49,7 @@ contract L1BlockNumberTest is Test {
/// @dev Tests that `fallback` is correctly dispatched.
function test_fallback_succeeds() external {
(bool success, bytes memory ret) = address(bn).call(hex"
11
");
(bool success, bytes memory ret) = address(bn).call(hex"");
assertEq(success, true);
assertEq(ret, abi.encode(number));
}
...
...
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