-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Test msg sender, value for all msg calls
This restructures the tests to confirm the expected msg.value and msg.sender with various different message call types, e.g. call, delegatecall, callcode, staticcall. The storage tests are also split up so that they are independent set of tests to keep different types of tests separate and reduce clutter with the slight increase in redundancy in the test logic.
- Loading branch information
Showing
6 changed files
with
496 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
/** | ||
* @title A contract to inspect the msg context. | ||
* @notice This contract is used to test the expected msg.sender and msg.value | ||
* of a contract call in various scenarios. | ||
*/ | ||
contract ContextInspector { | ||
/** | ||
* @dev Emitted when the emitMsgSender() function is called. | ||
*/ | ||
event MsgSender(address sender); | ||
|
||
/** | ||
* @dev Emitted when the emitMsgValue() function is called. | ||
* | ||
* Note that `value` may be zero. | ||
*/ | ||
event MsgValue(uint256 value); | ||
|
||
function emitMsgSender() external { | ||
emit MsgSender(msg.sender); | ||
} | ||
|
||
function emitMsgValue() external payable { | ||
emit MsgValue(msg.value); | ||
} | ||
|
||
/** | ||
* @dev Returns the current msg.sender. This is primarily used for testing | ||
* staticcall as events are not emitted. | ||
*/ | ||
function getMsgSender() external view returns (address) { | ||
return msg.sender; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
/** | ||
* @title A basic contract with a storage value. | ||
* @notice This contract is used to test storage reads and writes, primarily | ||
* for testing storage behavior in delegateCall. | ||
*/ | ||
contract StorageBasic { | ||
uint256 public storageValue; | ||
|
||
function setStorageValue(uint256 value) external { | ||
storageValue = value; | ||
} | ||
} |
Oops, something went wrong.