Commit f49b71d5 authored by Maurelian's avatar Maurelian

Use bound instead of vm.assume

ctb: Update Hashing tests with bounded version

ctb: Update Portal tests with bound
parent c8714cb4
---
'@eth-optimism/indexer': patch
'@eth-optimism/contracts-bedrock': patch
'@eth-optimism/contracts-periphery': patch
---
Updated forge-std version
This diff is collapsed.
...@@ -66,7 +66,7 @@ contract CrossDomainOwnableThroughPortal_Test is Portal_Initializer { ...@@ -66,7 +66,7 @@ contract CrossDomainOwnableThroughPortal_Test is Portal_Initializer {
// Only 1 log emitted // Only 1 log emitted
assertEq(logs.length, 1); assertEq(logs.length, 1);
Vm.Log memory log = logs[0]; VmSafe.Log memory log = logs[0];
// It is the expected topic // It is the expected topic
bytes32 topic = log.topics[0]; bytes32 topic = log.topics[0];
......
...@@ -21,19 +21,20 @@ contract Hashing_Test is CommonTest { ...@@ -21,19 +21,20 @@ contract Hashing_Test is CommonTest {
} }
function test_hashCrossDomainMessage_differential( function test_hashCrossDomainMessage_differential(
uint256 _nonce, uint240 _nonce,
uint16 _version,
address _sender, address _sender,
address _target, address _target,
uint256 _value, uint256 _value,
uint256 _gasLimit, uint256 _gasLimit,
bytes memory _data bytes memory _data
) external { ) external {
// Discard any fuzz tests with an invalid version // Ensure the version is valid
(, uint16 version) = Encoding.decodeVersionedNonce(_nonce); uint16 version = uint16(bound(uint256(_version), 0, 1));
vm.assume(version < 2); uint256 nonce = Encoding.encodeVersionedNonce(_nonce, version);
bytes32 _hash = ffi.hashCrossDomainMessage( bytes32 _hash = ffi.hashCrossDomainMessage(
_nonce, nonce,
_sender, _sender,
_target, _target,
_value, _value,
...@@ -42,7 +43,7 @@ contract Hashing_Test is CommonTest { ...@@ -42,7 +43,7 @@ contract Hashing_Test is CommonTest {
); );
bytes32 hash = Hashing.hashCrossDomainMessage( bytes32 hash = Hashing.hashCrossDomainMessage(
_nonce, nonce,
_sender, _sender,
_target, _target,
_value, _value,
......
...@@ -711,17 +711,18 @@ contract OptimismPortal_FinalizeWithdrawal_Test is Portal_Initializer { ...@@ -711,17 +711,18 @@ contract OptimismPortal_FinalizeWithdrawal_Test is Portal_Initializer {
uint256 _gasLimit, uint256 _gasLimit,
bytes memory _data bytes memory _data
) external { ) external {
vm.assume(_target != address(op)); // Cannot call the optimism portal. // Cannot call the optimism portal
vm.assume(_value < 200_000_000 ether); // Total ETH supply is currently ~120M ETH. vm.assume(_target != address(op));
vm.assume(_gasLimit < 50_000_000); // Total ETH supply is currently about 120M ETH.
uint256 value = bound(_value, 0, 200_000_000 ether);
uint256 _nonce = messagePasser.nonce(); uint256 gasLimit = bound(_gasLimit, 0, 50_000_000);
uint256 nonce = messagePasser.nonce();
Types.WithdrawalTransaction memory _tx = Types.WithdrawalTransaction({ Types.WithdrawalTransaction memory _tx = Types.WithdrawalTransaction({
nonce: _nonce, nonce: nonce,
sender: _sender, sender: _sender,
target: _target, target: _target,
value: _value, value: value,
gasLimit: _gasLimit, gasLimit: gasLimit,
data: _data data: _data
}); });
( (
......
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