Commit e4b6580b authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: simplify safecall test

Modularizes out a bit from https://github.com/ethereum-optimism/optimism/pull/7928
where the `SafeCall` test doesn't require `CommonTest` but instead can
just use `Test`. This simplifies the `setUp` and should reduce the
amount of computation required to set up the tests. This also reduces
the need to use `vm.assume` to ignore contracts that are deployed as
part of the `CommonTest` setup.
parent 96a24cc3
...@@ -672,7 +672,7 @@ ResourceMetering_Test:test_meter_updateTwoEmptyBlocks_succeeds() (gas: 23703) ...@@ -672,7 +672,7 @@ ResourceMetering_Test:test_meter_updateTwoEmptyBlocks_succeeds() (gas: 23703)
ResourceMetering_Test:test_meter_useMax_succeeds() (gas: 20020816) ResourceMetering_Test:test_meter_useMax_succeeds() (gas: 20020816)
ResourceMetering_Test:test_meter_useMoreThanMax_reverts() (gas: 19549) ResourceMetering_Test:test_meter_useMoreThanMax_reverts() (gas: 19549)
SafeCall_Test:test_callWithMinGas_noLeakageHigh_succeeds() (gas: 1021670598) SafeCall_Test:test_callWithMinGas_noLeakageHigh_succeeds() (gas: 1021670598)
SafeCall_Test:test_callWithMinGas_noLeakageLow_succeeds() (gas: 1095190710) SafeCall_Test:test_callWithMinGas_noLeakageLow_succeeds() (gas: 1095190688)
Semver_Test:test_behindProxy_succeeds() (gas: 507558) Semver_Test:test_behindProxy_succeeds() (gas: 507558)
Semver_Test:test_version_succeeds() (gas: 9418) Semver_Test:test_version_succeeds() (gas: 9418)
SequencerFeeVault_L2Withdrawal_Test:test_withdraw_toL2_succeeds() (gas: 78333) SequencerFeeVault_L2Withdrawal_Test:test_withdraw_toL2_succeeds() (gas: 78333)
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
pragma solidity 0.8.15; pragma solidity 0.8.15;
// Testing utilities // Testing utilities
import { CommonTest } from "test/CommonTest.t.sol"; import { Test } from "forge-std/Test.sol";
// Target contract // Target contract
import { SafeCall } from "src/libraries/SafeCall.sol"; import { SafeCall } from "src/libraries/SafeCall.sol";
contract SafeCall_Test is CommonTest { contract SafeCall_Test is Test {
/// @dev Tests that the `send` function succeeds. /// @dev Tests that the `send` function succeeds.
function testFuzz_send_succeeds(address from, address to, uint256 gas, uint64 value) external { function testFuzz_send_succeeds(address from, address to, uint256 gas, uint64 value) external {
vm.assume(from.balance == 0); vm.assume(from.balance == 0);
...@@ -21,8 +21,7 @@ contract SafeCall_Test is CommonTest { ...@@ -21,8 +21,7 @@ contract SafeCall_Test is CommonTest {
vm.assume(to != address(0x000000000000000000636F6e736F6c652e6c6f67)); vm.assume(to != address(0x000000000000000000636F6e736F6c652e6c6f67));
// don't call the create2 deployer // don't call the create2 deployer
vm.assume(to != address(0x4e59b44847b379578588920cA78FbF26c0B4956C)); vm.assume(to != address(0x4e59b44847b379578588920cA78FbF26c0B4956C));
// don't call the ffi interface vm.assume(to != address(this));
vm.assume(to != address(0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f));
assertEq(from.balance, 0, "from balance is 0"); assertEq(from.balance, 0, "from balance is 0");
vm.deal(from, value); vm.deal(from, value);
...@@ -56,8 +55,7 @@ contract SafeCall_Test is CommonTest { ...@@ -56,8 +55,7 @@ contract SafeCall_Test is CommonTest {
vm.assume(to != address(0x000000000000000000636F6e736F6c652e6c6f67)); vm.assume(to != address(0x000000000000000000636F6e736F6c652e6c6f67));
// don't call the create2 deployer // don't call the create2 deployer
vm.assume(to != address(0x4e59b44847b379578588920cA78FbF26c0B4956C)); vm.assume(to != address(0x4e59b44847b379578588920cA78FbF26c0B4956C));
// don't call the ffi interface vm.assume(to != address(this));
vm.assume(to != address(0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f));
assertEq(from.balance, 0, "from balance is 0"); assertEq(from.balance, 0, "from balance is 0");
vm.deal(from, value); vm.deal(from, value);
...@@ -99,8 +97,7 @@ contract SafeCall_Test is CommonTest { ...@@ -99,8 +97,7 @@ contract SafeCall_Test is CommonTest {
vm.assume(to != address(0x000000000000000000636F6e736F6c652e6c6f67)); vm.assume(to != address(0x000000000000000000636F6e736F6c652e6c6f67));
// don't call the create2 deployer // don't call the create2 deployer
vm.assume(to != address(0x4e59b44847b379578588920cA78FbF26c0B4956C)); vm.assume(to != address(0x4e59b44847b379578588920cA78FbF26c0B4956C));
// don't call the FFIInterface vm.assume(to != address(this));
vm.assume(to != address(0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f));
assertEq(from.balance, 0, "from balance is 0"); assertEq(from.balance, 0, "from balance is 0");
vm.deal(from, value); vm.deal(from, value);
......
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