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
a9168407
Unverified
Commit
a9168407
authored
Nov 28, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contracts-bedrock: Add tests for xdm pausability
parent
cdb8400f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
0 deletions
+71
-0
ExtendedPause.t.sol
packages/contracts-bedrock/test/ExtendedPause.t.sol
+35
-0
L1CrossDomainMessenger.t.sol
packages/contracts-bedrock/test/L1CrossDomainMessenger.t.sol
+36
-0
No files found.
packages/contracts-bedrock/test/ExtendedPause.t.sol
0 → 100644
View file @
a9168407
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { CommonTest } from "test/setup/CommonTest.sol";
import { SuperchainConfig } from "src/L1/SuperchainConfig.sol";
contract ExtendedPause_Test is CommonTest {
/// @dev Tests that other contracts are paused when the superchain config is paused
/// This test is somewhat redundant with tests in the SuperchainConfig and other pausable contracts, however
/// it is worthwhile to pull them into one location to ensure that the behavior is consistent.
function test_pause_fullSystem_succeeds() external {
assertFalse(superchainConfig.paused());
assertEq(l1CrossDomainMessenger.paused(), superchainConfig.paused());
vm.prank(superchainConfig.guardian());
superchainConfig.pause("identifier");
assertTrue(superchainConfig.paused());
assertEq(l1CrossDomainMessenger.paused(), superchainConfig.paused());
// The following is hacky approach which ensures that this test will fail if the paused() function is
// added to the L1StandardBridge or the L1ERC721Bridge. At that point this test should be updated to include
// those methods.
try SuperchainConfig(address(l1StandardBridge)).paused() {
revert("The L1StandardBridge has a paused() function, but is not tested as part of the ExtendedPause");
} catch (bytes memory) {
assertTrue(true);
}
try SuperchainConfig(address(l1ERC721Bridge)).paused() {
revert("The L1ERC721Bridge has a paused() function, but is not tested as part of the ExtendedPause");
} catch (bytes memory) {
assertTrue(true);
}
}
}
packages/contracts-bedrock/test/L1CrossDomainMessenger.t.sol
View file @
a9168407
...
...
@@ -13,6 +13,7 @@ import { Encoding } from "src/libraries/Encoding.sol";
// Target contract dependencies
import { OptimismPortal } from "src/L1/OptimismPortal.sol";
import { SuperchainConfig } from "src/L1/SuperchainConfig.sol";
contract L1CrossDomainMessenger_Test is Bridge_Initializer {
/// @dev The receiver address
...
...
@@ -558,4 +559,39 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer {
hex"1111"
);
}
/// @dev Tests that the relayMessage function is able to relay a message
/// successfully by calling the target contract.
function test_relayMessage_paused_reverts() external {
vm.prank(superchainConfig.guardian());
superchainConfig.pause("identifier");
vm.expectRevert("CrossDomainMessenger: paused");
l1CrossDomainMessenger.relayMessage(
Encoding.encodeVersionedNonce({ _nonce: 0, _version: 1 }), // nonce
address(0),
address(0),
0, // value
0,
hex"1111"
);
}
/// @dev Tests that the superchain config is called by the messengers paused function
function test_pause_callsSuperchainConfig_succeeds() external {
vm.expectCall(address(superchainConfig), abi.encodeWithSelector(SuperchainConfig.paused.selector));
l1CrossDomainMessenger.paused();
}
/// @dev Tests that changing the superchain config paused status changes the return value of the messenger
function test_pause_matchesSuperchainConfig_succeeds() external {
assertFalse(l1CrossDomainMessenger.paused());
assertEq(l1CrossDomainMessenger.paused(), superchainConfig.paused());
vm.prank(superchainConfig.guardian());
superchainConfig.pause("identifier");
assertTrue(l1CrossDomainMessenger.paused());
assertEq(l1CrossDomainMessenger.paused(), superchainConfig.paused());
}
}
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