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
b625f7d2
Unverified
Commit
b625f7d2
authored
Apr 16, 2024
by
clabby
Committed by
GitHub
Apr 17, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(ctb): Add test for `LibClone` improvement (#10153)
fmt
parent
bfe457f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
FaultDisputeGame.t.sol
...ges/contracts-bedrock/test/dispute/FaultDisputeGame.t.sol
+28
-0
No files found.
packages/contracts-bedrock/test/dispute/FaultDisputeGame.t.sol
View file @
b625f7d2
...
@@ -33,6 +33,8 @@ contract FaultDisputeGame_Init is DisputeGameFactory_Init {
...
@@ -33,6 +33,8 @@ contract FaultDisputeGame_Init is DisputeGameFactory_Init {
event Move(uint256 indexed parentIndex, Claim indexed pivot, address indexed claimant);
event Move(uint256 indexed parentIndex, Claim indexed pivot, address indexed claimant);
event ReceiveETH(uint256 amount);
function init(Claim rootClaim, Claim absolutePrestate, uint256 l2BlockNumber) public {
function init(Claim rootClaim, Claim absolutePrestate, uint256 l2BlockNumber) public {
// Set the time to a realistic date.
// Set the time to a realistic date.
vm.warp(1690906994);
vm.warp(1690906994);
...
@@ -235,6 +237,32 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
...
@@ -235,6 +237,32 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
gameProxy.initialize();
gameProxy.initialize();
}
}
/// @dev Tests that the user cannot control the first 4 bytes of the CWIA data, disallowing them to control the
/// entrypoint when no calldata is provided to a call.
function test_cwiaCalldata_userCannotControlSelector_succeeds() public {
// Construct the expected CWIA data that the proxy will pass to the implementation, alongside any extra
// calldata passed by the user.
Hash l1Head = gameProxy.l1Head();
bytes memory cwiaData = abi.encodePacked(address(this), gameProxy.rootClaim(), l1Head, gameProxy.extraData());
// We expect a `ReceiveETH` event to be emitted when 0 bytes of calldata are sent; The fallback is always
// reached *within the minimal proxy* in `LibClone`'s version of `clones-with-immutable-args`
vm.expectEmit(false, false, false, true);
emit ReceiveETH(0);
// We expect no delegatecall to the implementation contract if 0 bytes are sent. Assert that this happens
// 0 times.
vm.expectCall(address(gameImpl), cwiaData, 0);
(bool successA,) = address(gameProxy).call(hex"");
assertTrue(successA);
// When calldata is forwarded, we do expect a delegatecall to the implementation.
bytes memory data = abi.encodePacked(gameProxy.l1Head.selector);
vm.expectCall(address(gameImpl), abi.encodePacked(data, cwiaData), 1);
(bool successB, bytes memory returnData) = address(gameProxy).call(data);
assertTrue(successB);
assertEq(returnData, abi.encode(l1Head));
}
/// @dev Tests that the bond during the bisection game depths is correct.
/// @dev Tests that the bond during the bisection game depths is correct.
function test_getRequiredBond_succeeds() public {
function test_getRequiredBond_succeeds() public {
for (uint8 i = 0; i < uint8(gameProxy.splitDepth()); i++) {
for (uint8 i = 0; i < uint8(gameProxy.splitDepth()); i++) {
...
...
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