Commit a49e1040 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge pull request #4803 from ethereum-optimism/sc/ctb-misc-test-cleanup

maint(ctb): clean up various test files
parents dc470550 3e6dd51b
This diff is collapsed.
......@@ -4,7 +4,7 @@ pragma solidity 0.8.15;
import { CommonTest } from "./CommonTest.t.sol";
import { MerkleTrie } from "../libraries/trie/MerkleTrie.sol";
contract MerkleTrie_Test is CommonTest {
contract MerkleTrie_get_Test is CommonTest {
function setUp() public {
_setUp();
}
......
......@@ -5,7 +5,7 @@ import { CommonTest } from "./CommonTest.t.sol";
import { MintManager } from "../governance/MintManager.sol";
import { GovernanceToken } from "../governance/GovernanceToken.sol";
contract MintManager_Test is CommonTest {
contract MintManager_Initializer is CommonTest {
address constant owner = address(0x1234);
address constant rando = address(0x5678);
GovernanceToken internal gov;
......@@ -21,12 +21,22 @@ contract MintManager_Test is CommonTest {
vm.prank(owner);
gov.transferOwnership(address(manager));
}
}
contract MintManager_constructor_Test is MintManager_Initializer {
/**
* @notice Tests that the constructor properly configures the contract.
*/
function test_constructor_succeeds() external {
assertEq(manager.owner(), owner);
assertEq(address(manager.governanceToken()), address(gov));
}
}
contract MintManager_mint_Test is MintManager_Initializer {
/**
* @notice Tests that the mint function properly mints tokens when called by the owner.
*/
function test_mint_fromOwner_succeeds() external {
// Mint once.
vm.prank(owner);
......@@ -36,6 +46,9 @@ contract MintManager_Test is CommonTest {
assertEq(gov.balanceOf(owner), 100);
}
/**
* @notice Tests that the mint function reverts when called by a non-owner.
*/
function test_mint_fromNotOwner_reverts() external {
// Mint from rando fails.
vm.prank(rando);
......@@ -43,6 +56,10 @@ contract MintManager_Test is CommonTest {
manager.mint(owner, 100);
}
/**
* @notice Tests that the mint function properly mints tokens when called by the owner a second
* time after the mint period has elapsed.
*/
function test_mint_afterPeriodElapsed_succeeds() external {
// Mint once.
vm.prank(owner);
......@@ -60,6 +77,10 @@ contract MintManager_Test is CommonTest {
assertEq(gov.balanceOf(owner), 102);
}
/**
* @notice Tests that the mint function always reverts when called before the mint period has
* elapsed, even if the caller is the owner.
*/
function test_mint_beforePeriodElapsed_reverts() external {
// Mint once.
vm.prank(owner);
......@@ -77,6 +98,9 @@ contract MintManager_Test is CommonTest {
assertEq(gov.balanceOf(owner), 100);
}
/**
* @notice Tests that the owner cannot mint more than the mint cap.
*/
function test_mint_moreThanCap_reverts() external {
// Mint once.
vm.prank(owner);
......@@ -94,7 +118,12 @@ contract MintManager_Test is CommonTest {
// Token balance does not increase.
assertEq(gov.balanceOf(owner), 100);
}
}
contract MintManager_upgrade_Test is MintManager_Initializer {
/**
* @notice Tests that the owner can upgrade the mint manager.
*/
function test_upgrade_fromOwner_succeeds() external {
// Upgrade to new manager.
vm.prank(owner);
......@@ -104,6 +133,9 @@ contract MintManager_Test is CommonTest {
assertEq(gov.owner(), rando);
}
/**
* @notice Tests that the upgrade function reverts when called by a non-owner.
*/
function test_upgrade_fromNotOwner_reverts() external {
// Upgrade from rando fails.
vm.prank(rando);
......@@ -111,6 +143,10 @@ contract MintManager_Test is CommonTest {
manager.upgrade(rando);
}
/**
* @notice Tests that the upgrade function reverts when attempting to update to the zero
* address, even if the caller is the owner.
*/
function test_upgrade_toZeroAddress_reverts() external {
// Upgrade to zero address fails.
vm.prank(owner);
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { RLPReader } from "../libraries/rlp/RLPReader.sol";
import { CommonTest } from "./CommonTest.t.sol";
import { stdError } from "forge-std/Test.sol";
import { CommonTest } from "./CommonTest.t.sol";
import { RLPReader } from "../libraries/rlp/RLPReader.sol";
contract RLPReader_Test is CommonTest {
contract RLPReader_readBytes_Test is CommonTest {
function test_readBytes_bytestring00_succeeds() external {
assertEq(RLPReader.readBytes(hex"00"), hex"00");
}
......@@ -48,7 +48,9 @@ contract RLPReader_Test is CommonTest {
);
RLPReader.readBytes(hex"810a");
}
}
contract RLPReader_readList_Test is CommonTest {
function test_readList_empty_succeeds() external {
RLPReader.RLPItem[] memory list = RLPReader.readList(hex"c0");
assertEq(list.length, 0);
......
......@@ -4,7 +4,7 @@ pragma solidity 0.8.15;
import { RLPWriter } from "../libraries/rlp/RLPWriter.sol";
import { CommonTest } from "./CommonTest.t.sol";
contract RLPWriter_Test is CommonTest {
contract RLPWriter_writeString_Test is CommonTest {
function test_writeString_empty_succeeds() external {
assertEq(RLPWriter.writeString(""), hex"80");
}
......@@ -47,7 +47,9 @@ contract RLPWriter_Test is CommonTest {
hex"b904004c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e20437572616269747572206d6175726973206d61676e612c20737573636970697420736564207665686963756c61206e6f6e2c20696163756c697320666175636962757320746f72746f722e2050726f696e20737573636970697420756c74726963696573206d616c6573756164612e204475697320746f72746f7220656c69742c2064696374756d2071756973207472697374697175652065752c20756c7472696365732061742072697375732e204d6f72626920612065737420696d70657264696574206d6920756c6c616d636f7270657220616c6971756574207375736369706974206e6563206c6f72656d2e2041656e65616e2071756973206c656f206d6f6c6c69732c2076756c70757461746520656c6974207661726975732c20636f6e73657175617420656e696d2e204e756c6c6120756c74726963657320747572706973206a7573746f2c20657420706f73756572652075726e6120636f6e7365637465747572206e65632e2050726f696e206e6f6e20636f6e76616c6c6973206d657475732e20446f6e65632074656d706f7220697073756d20696e206d617572697320636f6e67756520736f6c6c696369747564696e2e20566573746962756c756d20616e746520697073756d207072696d697320696e206661756369627573206f726369206c756374757320657420756c74726963657320706f737565726520637562696c69612043757261653b2053757370656e646973736520636f6e76616c6c69732073656d2076656c206d617373612066617563696275732c2065676574206c6163696e6961206c616375732074656d706f722e204e756c6c61207175697320756c747269636965732070757275732e2050726f696e20617563746f722072686f6e637573206e69626820636f6e64696d656e74756d206d6f6c6c69732e20416c697175616d20636f6e73657175617420656e696d206174206d65747573206c75637475732c206120656c656966656e6420707572757320656765737461732e20437572616269747572206174206e696268206d657475732e204e616d20626962656e64756d2c206e6571756520617420617563746f72207472697374697175652c206c6f72656d206c696265726f20616c697175657420617263752c206e6f6e20696e74657264756d2074656c6c7573206c65637475732073697420616d65742065726f732e20437261732072686f6e6375732c206d65747573206163206f726e617265206375727375732c20646f6c6f72206a7573746f20756c747269636573206d657475732c20617420756c6c616d636f7270657220766f6c7574706174"
);
}
}
contract RLPWriter_writeUint_Test is CommonTest {
function test_writeUint_zero_succeeds() external {
assertEq(RLPWriter.writeUint(0x0), hex"80");
}
......@@ -79,7 +81,9 @@ contract RLPWriter_Test is CommonTest {
function test_writeUint_mediumint3_succeeds() external {
assertEq(RLPWriter.writeUint(100000), hex"830186a0");
}
}
contract RLPWriter_writeList_Test is CommonTest {
function test_writeList_empty_succeeds() external {
assertEq(RLPWriter.writeList(new bytes[](0)), hex"c0");
}
......
......@@ -4,8 +4,8 @@ pragma solidity 0.8.15;
import { CommonTest } from "./CommonTest.t.sol";
import { SafeCall } from "../libraries/SafeCall.sol";
contract SafeCall_Test is CommonTest {
function testFuzz_safeCall_succeeds(
contract SafeCall_call_Test is CommonTest {
function testFuzz_call_succeeds(
address from,
address to,
uint256 gas,
......
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