Commit a6a14b70 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

Merge pull request #4938 from ethereum-optimism/fix/test-setup

contracts-bedrock: fix setup chain in tests
parents d1e99369 80399959
This diff is collapsed.
...@@ -50,7 +50,7 @@ contract CommonTest is Test { ...@@ -50,7 +50,7 @@ contract CommonTest is Test {
FFIInterface ffi; FFIInterface ffi;
function _setUp() public { function setUp() public virtual {
// Give alice and bob some ETH // Give alice and bob some ETH
vm.deal(alice, 1 << 16); vm.deal(alice, 1 << 16);
vm.deal(bob, 1 << 16); vm.deal(bob, 1 << 16);
...@@ -117,9 +117,8 @@ contract L2OutputOracle_Initializer is CommonTest { ...@@ -117,9 +117,8 @@ contract L2OutputOracle_Initializer is CommonTest {
vm.warp(oracle.computeL2Timestamp(_nextBlockNumber) + 1); vm.warp(oracle.computeL2Timestamp(_nextBlockNumber) + 1);
} }
function setUp() public virtual { function setUp() public virtual override {
_setUp(); super.setUp();
// By default the first block has timestamp and number zero, which will cause underflows in the // By default the first block has timestamp and number zero, which will cause underflows in the
// tests, so we'll move forward to these block values. // tests, so we'll move forward to these block values.
initL1Time = startingTimestamp + 1; initL1Time = startingTimestamp + 1;
...@@ -163,7 +162,7 @@ contract Portal_Initializer is L2OutputOracle_Initializer { ...@@ -163,7 +162,7 @@ contract Portal_Initializer is L2OutputOracle_Initializer {
); );
function setUp() public virtual override { function setUp() public virtual override {
L2OutputOracle_Initializer.setUp(); super.setUp();
opImpl = new OptimismPortal(oracle, 7 days); opImpl = new OptimismPortal(oracle, 7 days);
Proxy proxy = new Proxy(multisig); Proxy proxy = new Proxy(multisig);
......
...@@ -18,7 +18,8 @@ contract XDomainSetter is CrossDomainOwnable { ...@@ -18,7 +18,8 @@ contract XDomainSetter is CrossDomainOwnable {
contract CrossDomainOwnable_Test is CommonTest { contract CrossDomainOwnable_Test is CommonTest {
XDomainSetter setter; XDomainSetter setter;
function setUp() external { function setUp() public override {
super.setUp();
setter = new XDomainSetter(); setter = new XDomainSetter();
} }
......
...@@ -7,7 +7,7 @@ import { DeployerWhitelist } from "../legacy/DeployerWhitelist.sol"; ...@@ -7,7 +7,7 @@ import { DeployerWhitelist } from "../legacy/DeployerWhitelist.sol";
contract DeployerWhitelist_Test is CommonTest { contract DeployerWhitelist_Test is CommonTest {
DeployerWhitelist list; DeployerWhitelist list;
function setUp() external { function setUp() public virtual override {
list = new DeployerWhitelist(); list = new DeployerWhitelist();
} }
......
...@@ -6,10 +6,6 @@ import { Types } from "../libraries/Types.sol"; ...@@ -6,10 +6,6 @@ import { Types } from "../libraries/Types.sol";
import { Encoding } from "../libraries/Encoding.sol"; import { Encoding } from "../libraries/Encoding.sol";
contract Encoding_Test is CommonTest { contract Encoding_Test is CommonTest {
function setUp() external {
_setUp();
}
function testFuzz_nonceVersioning_succeeds(uint240 _nonce, uint16 _version) external { function testFuzz_nonceVersioning_succeeds(uint240 _nonce, uint16 _version) external {
(uint240 nonce, uint16 version) = Encoding.decodeVersionedNonce( (uint240 nonce, uint16 version) = Encoding.decodeVersionedNonce(
Encoding.encodeVersionedNonce(_nonce, _version) Encoding.encodeVersionedNonce(_nonce, _version)
......
...@@ -25,7 +25,8 @@ contract GasPriceOracle_Test is CommonTest { ...@@ -25,7 +25,8 @@ contract GasPriceOracle_Test is CommonTest {
uint256 constant l1FeeOverhead = 310; uint256 constant l1FeeOverhead = 310;
uint256 constant l1FeeScalar = 10; uint256 constant l1FeeScalar = 10;
function setUp() external { function setUp() public virtual override {
super.setUp();
// place the L1Block contract at the predeploy address // place the L1Block contract at the predeploy address
vm.etch(Predeploys.L1_BLOCK_ATTRIBUTES, address(new L1Block()).code); vm.etch(Predeploys.L1_BLOCK_ATTRIBUTES, address(new L1Block()).code);
......
...@@ -9,7 +9,8 @@ contract GovernanceToken_Test is CommonTest { ...@@ -9,7 +9,8 @@ contract GovernanceToken_Test is CommonTest {
address constant rando = address(0x5678); address constant rando = address(0x5678);
GovernanceToken internal gov; GovernanceToken internal gov;
function setUp() external { function setUp() public virtual override {
super.setUp();
vm.prank(owner); vm.prank(owner);
gov = new GovernanceToken(); gov = new GovernanceToken();
} }
......
...@@ -7,10 +7,6 @@ import { Hashing } from "../libraries/Hashing.sol"; ...@@ -7,10 +7,6 @@ import { Hashing } from "../libraries/Hashing.sol";
import { Encoding } from "../libraries/Encoding.sol"; import { Encoding } from "../libraries/Encoding.sol";
contract Hashing_hashDepositSource_Test is CommonTest { contract Hashing_hashDepositSource_Test is CommonTest {
function setUp() external {
_setUp();
}
/** /**
* @notice Tests that hashDepositSource returns the correct hash in a simple case. * @notice Tests that hashDepositSource returns the correct hash in a simple case.
*/ */
...@@ -26,10 +22,6 @@ contract Hashing_hashDepositSource_Test is CommonTest { ...@@ -26,10 +22,6 @@ contract Hashing_hashDepositSource_Test is CommonTest {
} }
contract Hashing_hashCrossDomainMessage_Test is CommonTest { contract Hashing_hashCrossDomainMessage_Test is CommonTest {
function setUp() external {
_setUp();
}
/** /**
* @notice Tests that hashCrossDomainMessage returns the correct hash in a simple case. * @notice Tests that hashCrossDomainMessage returns the correct hash in a simple case.
*/ */
...@@ -54,10 +46,6 @@ contract Hashing_hashCrossDomainMessage_Test is CommonTest { ...@@ -54,10 +46,6 @@ contract Hashing_hashCrossDomainMessage_Test is CommonTest {
} }
contract Hashing_hashWithdrawal_Test is CommonTest { contract Hashing_hashWithdrawal_Test is CommonTest {
function setUp() external {
_setUp();
}
/** /**
* @notice Tests that hashWithdrawal returns the correct hash in a simple case. * @notice Tests that hashWithdrawal returns the correct hash in a simple case.
*/ */
...@@ -79,10 +67,6 @@ contract Hashing_hashWithdrawal_Test is CommonTest { ...@@ -79,10 +67,6 @@ contract Hashing_hashWithdrawal_Test is CommonTest {
} }
contract Hashing_hashOutputRootProof_Test is CommonTest { contract Hashing_hashOutputRootProof_Test is CommonTest {
function setUp() external {
_setUp();
}
/** /**
* @notice Tests that hashOutputRootProof returns the correct hash in a simple case. * @notice Tests that hashOutputRootProof returns the correct hash in a simple case.
*/ */
...@@ -112,10 +96,6 @@ contract Hashing_hashOutputRootProof_Test is CommonTest { ...@@ -112,10 +96,6 @@ contract Hashing_hashOutputRootProof_Test is CommonTest {
} }
contract Hashing_hashDepositTransaction_Test is CommonTest { contract Hashing_hashDepositTransaction_Test is CommonTest {
function setUp() external {
_setUp();
}
/** /**
* @notice Tests that hashDepositTransaction returns the correct hash in a simple case. * @notice Tests that hashDepositTransaction returns the correct hash in a simple case.
*/ */
......
...@@ -9,7 +9,8 @@ contract L1BlockTest is CommonTest { ...@@ -9,7 +9,8 @@ contract L1BlockTest is CommonTest {
address depositor; address depositor;
bytes32 immutable NON_ZERO_HASH = keccak256(abi.encode(1)); bytes32 immutable NON_ZERO_HASH = keccak256(abi.encode(1));
function setUp() external { function setUp() public virtual override {
super.setUp();
lb = new L1Block(); lb = new L1Block();
depositor = lb.DEPOSITOR_ACCOUNT(); depositor = lb.DEPOSITOR_ACCOUNT();
vm.prank(depositor); vm.prank(depositor);
......
...@@ -21,7 +21,8 @@ contract L2ToL1MessagePasserTest is CommonTest { ...@@ -21,7 +21,8 @@ contract L2ToL1MessagePasserTest is CommonTest {
event WithdrawerBalanceBurnt(uint256 indexed amount); event WithdrawerBalanceBurnt(uint256 indexed amount);
function setUp() public virtual { function setUp() public virtual override {
super.setUp();
messagePasser = new L2ToL1MessagePasser(); messagePasser = new L2ToL1MessagePasser();
} }
......
...@@ -8,7 +8,8 @@ import { Predeploys } from "../libraries/Predeploys.sol"; ...@@ -8,7 +8,8 @@ import { Predeploys } from "../libraries/Predeploys.sol";
contract LegacyERC20ETH_Test is CommonTest { contract LegacyERC20ETH_Test is CommonTest {
LegacyERC20ETH eth; LegacyERC20ETH eth;
function setUp() external { function setUp() public virtual override {
super.setUp();
eth = new LegacyERC20ETH(); eth = new LegacyERC20ETH();
} }
......
...@@ -8,7 +8,8 @@ import { Predeploys } from "../libraries/Predeploys.sol"; ...@@ -8,7 +8,8 @@ import { Predeploys } from "../libraries/Predeploys.sol";
contract LegacyMessagePasser_Test is CommonTest { contract LegacyMessagePasser_Test is CommonTest {
LegacyMessagePasser messagePasser; LegacyMessagePasser messagePasser;
function setUp() external { function setUp() public virtual override {
super.setUp();
messagePasser = new LegacyMessagePasser(); messagePasser = new LegacyMessagePasser();
} }
......
...@@ -5,10 +5,6 @@ import { CommonTest } from "./CommonTest.t.sol"; ...@@ -5,10 +5,6 @@ import { CommonTest } from "./CommonTest.t.sol";
import { MerkleTrie } from "../libraries/trie/MerkleTrie.sol"; import { MerkleTrie } from "../libraries/trie/MerkleTrie.sol";
contract MerkleTrie_get_Test is CommonTest { contract MerkleTrie_get_Test is CommonTest {
function setUp() public {
_setUp();
}
function test_get_validProof1_succeeds() external { function test_get_validProof1_succeeds() external {
bytes32 root = 0xd582f99275e227a1cf4284899e5ff06ee56da8859be71b553397c69151bc942f; bytes32 root = 0xd582f99275e227a1cf4284899e5ff06ee56da8859be71b553397c69151bc942f;
bytes memory key = hex"6b6579326262"; bytes memory key = hex"6b6579326262";
......
...@@ -11,7 +11,9 @@ contract MintManager_Initializer is CommonTest { ...@@ -11,7 +11,9 @@ contract MintManager_Initializer is CommonTest {
GovernanceToken internal gov; GovernanceToken internal gov;
MintManager internal manager; MintManager internal manager;
function setUp() external { function setUp() public virtual override {
super.setUp();
vm.prank(owner); vm.prank(owner);
gov = new GovernanceToken(); gov = new GovernanceToken();
......
...@@ -21,8 +21,8 @@ contract ResourceMetering_Test is CommonTest { ...@@ -21,8 +21,8 @@ contract ResourceMetering_Test is CommonTest {
MeterUser internal meter; MeterUser internal meter;
uint64 initialBlockNum; uint64 initialBlockNum;
function setUp() external { function setUp() public virtual override {
_setUp(); super.setUp();
meter = new MeterUser(); meter = new MeterUser();
initialBlockNum = uint64(block.number); initialBlockNum = uint64(block.number);
} }
......
...@@ -19,7 +19,7 @@ contract Semver_Test is CommonTest { ...@@ -19,7 +19,7 @@ contract Semver_Test is CommonTest {
/** /**
* @notice Deploy a Semver contract * @notice Deploy a Semver contract
*/ */
function setUp() external { function setUp() public virtual override {
semver = new Semver(7, 8, 0); semver = new Semver(7, 8, 0);
} }
......
...@@ -28,13 +28,13 @@ contract SequencerFeeVault_Test is Bridge_Initializer { ...@@ -28,13 +28,13 @@ contract SequencerFeeVault_Test is Bridge_Initializer {
} }
function test_receive_succeeds() external { function test_receive_succeeds() external {
assertEq(address(vault).balance, 0); uint256 balance = address(vault).balance;
vm.prank(alice); vm.prank(alice);
(bool success, ) = address(vault).call{ value: 100 }(hex""); (bool success, ) = address(vault).call{ value: 100 }(hex"");
assertEq(success, true); assertEq(success, true);
assertEq(address(vault).balance, 100); assertEq(address(vault).balance, balance + 100);
} }
function test_withdraw_notEnough_reverts() external { function test_withdraw_notEnough_reverts() external {
......
...@@ -7,7 +7,8 @@ import { SystemConfig } from "../L1/SystemConfig.sol"; ...@@ -7,7 +7,8 @@ import { SystemConfig } from "../L1/SystemConfig.sol";
contract SystemConfig_Init is CommonTest { contract SystemConfig_Init is CommonTest {
SystemConfig sysConf; SystemConfig sysConf;
function setUp() external { function setUp() public virtual override {
super.setUp();
sysConf = new SystemConfig({ sysConf = new SystemConfig({
_owner: alice, _owner: alice,
_overhead: 2100, _overhead: 2100,
......
...@@ -94,7 +94,7 @@ contract RelayActor is StdUtils { ...@@ -94,7 +94,7 @@ contract RelayActor is StdUtils {
contract XDM_MinGasLimits is Messenger_Initializer { contract XDM_MinGasLimits is Messenger_Initializer {
RelayActor actor; RelayActor actor;
function setUp() public override { function setUp() public virtual override {
// Set up the `L1CrossDomainMessenger` and `OptimismPortal` contracts. // Set up the `L1CrossDomainMessenger` and `OptimismPortal` contracts.
super.setUp(); super.setUp();
......
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