Commit 7a25a569 authored by Maurelian's avatar Maurelian

contracts-bedrock: Update tests for minimal Superchain

parent 7986507d
...@@ -73,7 +73,8 @@ contract SuperchainConfig is Initializable, ISemver { ...@@ -73,7 +73,8 @@ contract SuperchainConfig is Initializable, ISemver {
emit Unpaused(); emit Unpaused();
} }
/// @notice Sets the guardian address. /// @notice Sets the guardian address. This is only callable during initialization, so an upgrade
/// will be required to change the guardian.
/// @param _guardian The new guardian address. /// @param _guardian The new guardian address.
function _setGuardian(address _guardian) internal { function _setGuardian(address _guardian) internal {
Storage.setAddress(GUARDIAN_SLOT, _guardian); Storage.setAddress(GUARDIAN_SLOT, _guardian);
......
...@@ -35,6 +35,14 @@ contract Initializer_Test is Bridge_Initializer { ...@@ -35,6 +35,14 @@ contract Initializer_Test is Bridge_Initializer {
// Initialize the `contracts` array with the addresses of the contracts to test, the // Initialize the `contracts` array with the addresses of the contracts to test, the
// calldata used to initialize them, and the storage slot of their `_initialized` flag. // calldata used to initialize them, and the storage slot of their `_initialized` flag.
// SuperchainConfig
contracts.push(
InitializeableContract({
target: address(superchainConfig),
initCalldata: abi.encodeCall(superchainConfig.initialize, (address(0))),
initializedSlotVal: loadInitializedSlot("SuperchainConfig", true)
})
);
// L1CrossDomainMessenger // L1CrossDomainMessenger
contracts.push( contracts.push(
InitializeableContract({ InitializeableContract({
......
...@@ -17,7 +17,7 @@ contract SuperchainConfig_Init_Test is CommonTest { ...@@ -17,7 +17,7 @@ contract SuperchainConfig_Init_Test is CommonTest {
/// @dev Tests that initialization sets the correct values. These are defined in CommonTest.sol. /// @dev Tests that initialization sets the correct values. These are defined in CommonTest.sol.
function test_initialize_values_succeeds() external { function test_initialize_values_succeeds() external {
assertFalse(superchainConfig.paused()); assertFalse(superchainConfig.paused());
assertEq(superchainConfig.guardian(), guardian); assertEq(superchainConfig.guardian(), cfg.portalGuardian());
} }
} }
...@@ -44,7 +44,7 @@ contract SuperchainConfig_Pause_Test is CommonTest { ...@@ -44,7 +44,7 @@ contract SuperchainConfig_Pause_Test is CommonTest {
vm.expectEmit(address(superchainConfig)); vm.expectEmit(address(superchainConfig));
emit Paused("identifier"); emit Paused("identifier");
vm.prank(guardian); vm.prank(cfg.portalGuardian());
superchainConfig.pause("identifier"); superchainConfig.pause("identifier");
assertTrue(superchainConfig.paused()); assertTrue(superchainConfig.paused());
...@@ -54,7 +54,9 @@ contract SuperchainConfig_Pause_Test is CommonTest { ...@@ -54,7 +54,9 @@ contract SuperchainConfig_Pause_Test is CommonTest {
contract SuperchainConfig_Unpause_TestFail is CommonTest { contract SuperchainConfig_Unpause_TestFail is CommonTest {
/// @dev Tests that `unpause` reverts when called by a non-guardian. /// @dev Tests that `unpause` reverts when called by a non-guardian.
function test_unpause_notGuardian_reverts() external { function test_unpause_notGuardian_reverts() external {
_pause(); vm.prank(cfg.portalGuardian());
superchainConfig.pause("identifier");
assertEq(superchainConfig.paused(), true);
assertTrue(superchainConfig.guardian() != alice); assertTrue(superchainConfig.guardian() != alice);
vm.expectRevert("SuperchainConfig: only guardian can unpause"); vm.expectRevert("SuperchainConfig: only guardian can unpause");
...@@ -69,11 +71,13 @@ contract SuperchainConfig_Unpause_Test is CommonTest { ...@@ -69,11 +71,13 @@ contract SuperchainConfig_Unpause_Test is CommonTest {
/// @dev Tests that `unpause` successfully unpauses /// @dev Tests that `unpause` successfully unpauses
/// when called by the guardian. /// when called by the guardian.
function test_unpause_succeeds() external { function test_unpause_succeeds() external {
_pause(); vm.prank(cfg.portalGuardian());
superchainConfig.pause("identifier");
assertEq(superchainConfig.paused(), true);
vm.expectEmit(address(superchainConfig)); vm.expectEmit(address(superchainConfig));
emit Unpaused(); emit Unpaused();
vm.prank(guardian); vm.prank(cfg.portalGuardian());
superchainConfig.unpause(); superchainConfig.unpause();
assertFalse(superchainConfig.paused()); assertFalse(superchainConfig.paused());
......
...@@ -94,4 +94,8 @@ contract Events { ...@@ -94,4 +94,8 @@ contract Events {
uint256 amount, uint256 amount,
bytes data bytes data
); );
event Paused(string identifier);
event Unpaused();
} }
...@@ -30,6 +30,7 @@ import { L1ERC721Bridge } from "src/L1/L1ERC721Bridge.sol"; ...@@ -30,6 +30,7 @@ import { L1ERC721Bridge } from "src/L1/L1ERC721Bridge.sol";
import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol";
import { Executables } from "scripts/Executables.sol"; import { Executables } from "scripts/Executables.sol";
import { Vm } from "forge-std/Vm.sol"; import { Vm } from "forge-std/Vm.sol";
import { SuperchainConfig } from "src/L1/SuperchainConfig.sol";
/// @title Setup /// @title Setup
/// @dev This contact is responsible for setting up the contracts in state. It currently /// @dev This contact is responsible for setting up the contracts in state. It currently
...@@ -50,6 +51,7 @@ contract Setup { ...@@ -50,6 +51,7 @@ contract Setup {
L1ERC721Bridge l1ERC721Bridge; L1ERC721Bridge l1ERC721Bridge;
OptimismMintableERC20Factory l1OptimismMintableERC20Factory; OptimismMintableERC20Factory l1OptimismMintableERC20Factory;
ProtocolVersions protocolVersions; ProtocolVersions protocolVersions;
SuperchainConfig superchainConfig;
L2CrossDomainMessenger l2CrossDomainMessenger = L2CrossDomainMessenger l2CrossDomainMessenger =
L2CrossDomainMessenger(payable(Predeploys.L2_CROSS_DOMAIN_MESSENGER)); L2CrossDomainMessenger(payable(Predeploys.L2_CROSS_DOMAIN_MESSENGER));
...@@ -106,6 +108,7 @@ contract Setup { ...@@ -106,6 +108,7 @@ contract Setup {
l1OptimismMintableERC20Factory = l1OptimismMintableERC20Factory =
OptimismMintableERC20Factory(deploy.mustGetAddress("OptimismMintableERC20FactoryProxy")); OptimismMintableERC20Factory(deploy.mustGetAddress("OptimismMintableERC20FactoryProxy"));
protocolVersions = ProtocolVersions(deploy.mustGetAddress("ProtocolVersionsProxy")); protocolVersions = ProtocolVersions(deploy.mustGetAddress("ProtocolVersionsProxy"));
superchainConfig = SuperchainConfig(deploy.mustGetAddress("SuperchainConfigProxy"));
vm.label(address(l2OutputOracle), "L2OutputOracle"); vm.label(address(l2OutputOracle), "L2OutputOracle");
vm.label(deploy.mustGetAddress("L2OutputOracleProxy"), "L2OutputOracleProxy"); vm.label(deploy.mustGetAddress("L2OutputOracleProxy"), "L2OutputOracleProxy");
...@@ -124,6 +127,8 @@ contract Setup { ...@@ -124,6 +127,8 @@ contract Setup {
vm.label(deploy.mustGetAddress("OptimismMintableERC20FactoryProxy"), "OptimismMintableERC20FactoryProxy"); vm.label(deploy.mustGetAddress("OptimismMintableERC20FactoryProxy"), "OptimismMintableERC20FactoryProxy");
vm.label(address(protocolVersions), "ProtocolVersions"); vm.label(address(protocolVersions), "ProtocolVersions");
vm.label(deploy.mustGetAddress("ProtocolVersionsProxy"), "ProtocolVersionsProxy"); vm.label(deploy.mustGetAddress("ProtocolVersionsProxy"), "ProtocolVersionsProxy");
vm.label(address(superchainConfig), "SuperchainConfig");
vm.label(deploy.mustGetAddress("SuperchainConfigProxy"), "SuperchainConfigProxy");
vm.label(AddressAliasHelper.applyL1ToL2Alias(address(l1CrossDomainMessenger)), "L1CrossDomainMessenger_aliased"); vm.label(AddressAliasHelper.applyL1ToL2Alias(address(l1CrossDomainMessenger)), "L1CrossDomainMessenger_aliased");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment