Skip to content

Commit

Permalink
Merge pull request #4803 from ethereum-optimism/sc/ctb-misc-test-cleanup
Browse files Browse the repository at this point in the history
maint(ctb): clean up various test files
  • Loading branch information
mergify[bot] authored Jan 30, 2023
2 parents dc47055 + 3e6dd51 commit a49e104
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 99 deletions.
182 changes: 91 additions & 91 deletions packages/contracts-bedrock/.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -189,36 +189,36 @@ LegacyERC20ETH_Test:test_mint_doesNotExist_reverts() (gas: 10649)
LegacyERC20ETH_Test:test_transferFrom_doesNotExist_reverts() (gas: 12890)
LegacyERC20ETH_Test:test_transfer_doesNotExist_reverts() (gas: 10733)
LegacyMessagePasser_Test:test_passMessageToL1_succeeds() (gas: 34518)
MerkleTrie_Test:test_get_corruptedProof_reverts() (gas: 5713)
MerkleTrie_Test:test_get_extraProofElements_reverts() (gas: 60653)
MerkleTrie_Test:test_get_invalidDataRemainder_reverts() (gas: 35852)
MerkleTrie_Test:test_get_invalidInternalNodeHash_reverts() (gas: 50810)
MerkleTrie_Test:test_get_nonexistentKey1_reverts() (gas: 59671)
MerkleTrie_Test:test_get_nonexistentKey2_reverts() (gas: 23385)
MerkleTrie_Test:test_get_smallerPathThanKey1_reverts() (gas: 53547)
MerkleTrie_Test:test_get_smallerPathThanKey2_reverts() (gas: 55006)
MerkleTrie_Test:test_get_validProof10_succeeds() (gas: 50593)
MerkleTrie_Test:test_get_validProof1_succeeds() (gas: 61666)
MerkleTrie_Test:test_get_validProof2_succeeds() (gas: 71601)
MerkleTrie_Test:test_get_validProof3_succeeds() (gas: 32827)
MerkleTrie_Test:test_get_validProof4_succeeds() (gas: 23623)
MerkleTrie_Test:test_get_validProof5_succeeds() (gas: 84262)
MerkleTrie_Test:test_get_validProof6_succeeds() (gas: 72998)
MerkleTrie_Test:test_get_validProof7_succeeds() (gas: 79653)
MerkleTrie_Test:test_get_validProof8_succeeds() (gas: 50550)
MerkleTrie_Test:test_get_validProof9_succeeds() (gas: 50593)
MerkleTrie_Test:test_get_wrongKeyProof_reverts() (gas: 53848)
MerkleTrie_Test:test_get_zeroBranchValueLength_reverts() (gas: 43270)
MerkleTrie_Test:test_get_zeroLengthKey_reverts() (gas: 3632)
MintManager_Test:test_constructor_succeeds() (gas: 10535)
MintManager_Test:test_mint_afterPeriodElapsed_succeeds() (gas: 148117)
MintManager_Test:test_mint_beforePeriodElapsed_reverts() (gas: 140455)
MintManager_Test:test_mint_fromNotOwner_reverts() (gas: 10987)
MintManager_Test:test_mint_fromOwner_succeeds() (gas: 137241)
MintManager_Test:test_mint_moreThanCap_reverts() (gas: 142523)
MintManager_Test:test_upgrade_fromNotOwner_reverts() (gas: 10974)
MintManager_Test:test_upgrade_fromOwner_succeeds() (gas: 23463)
MintManager_Test:test_upgrade_toZeroAddress_reverts() (gas: 11003)
MerkleTrie_get_Test:test_get_corruptedProof_reverts() (gas: 5713)
MerkleTrie_get_Test:test_get_extraProofElements_reverts() (gas: 60653)
MerkleTrie_get_Test:test_get_invalidDataRemainder_reverts() (gas: 35852)
MerkleTrie_get_Test:test_get_invalidInternalNodeHash_reverts() (gas: 50810)
MerkleTrie_get_Test:test_get_nonexistentKey1_reverts() (gas: 59671)
MerkleTrie_get_Test:test_get_nonexistentKey2_reverts() (gas: 23385)
MerkleTrie_get_Test:test_get_smallerPathThanKey1_reverts() (gas: 53547)
MerkleTrie_get_Test:test_get_smallerPathThanKey2_reverts() (gas: 55006)
MerkleTrie_get_Test:test_get_validProof10_succeeds() (gas: 50593)
MerkleTrie_get_Test:test_get_validProof1_succeeds() (gas: 61666)
MerkleTrie_get_Test:test_get_validProof2_succeeds() (gas: 71601)
MerkleTrie_get_Test:test_get_validProof3_succeeds() (gas: 32827)
MerkleTrie_get_Test:test_get_validProof4_succeeds() (gas: 23623)
MerkleTrie_get_Test:test_get_validProof5_succeeds() (gas: 84262)
MerkleTrie_get_Test:test_get_validProof6_succeeds() (gas: 72998)
MerkleTrie_get_Test:test_get_validProof7_succeeds() (gas: 79653)
MerkleTrie_get_Test:test_get_validProof8_succeeds() (gas: 50550)
MerkleTrie_get_Test:test_get_validProof9_succeeds() (gas: 50593)
MerkleTrie_get_Test:test_get_wrongKeyProof_reverts() (gas: 53848)
MerkleTrie_get_Test:test_get_zeroBranchValueLength_reverts() (gas: 43270)
MerkleTrie_get_Test:test_get_zeroLengthKey_reverts() (gas: 3632)
MintManager_constructor_Test:test_constructor_succeeds() (gas: 10512)
MintManager_mint_Test:test_mint_afterPeriodElapsed_succeeds() (gas: 148139)
MintManager_mint_Test:test_mint_beforePeriodElapsed_reverts() (gas: 140433)
MintManager_mint_Test:test_mint_fromNotOwner_reverts() (gas: 10943)
MintManager_mint_Test:test_mint_fromOwner_succeeds() (gas: 137219)
MintManager_mint_Test:test_mint_moreThanCap_reverts() (gas: 142478)
MintManager_upgrade_Test:test_upgrade_fromNotOwner_reverts() (gas: 10929)
MintManager_upgrade_Test:test_upgrade_fromOwner_succeeds() (gas: 23411)
MintManager_upgrade_Test:test_upgrade_toZeroAddress_reverts() (gas: 10958)
OptimismMintableERC20_Test:test_bridge_succeeds() (gas: 7643)
OptimismMintableERC20_Test:test_burn_notBridge_reverts() (gas: 11165)
OptimismMintableERC20_Test:test_burn_succeeds() (gas: 51013)
Expand Down Expand Up @@ -310,67 +310,67 @@ ProxyAdmin_Test:test_setAddressManager_notOwner_reverts() (gas: 10600)
ProxyAdmin_Test:test_setImplementationName_notOwner_reverts() (gas: 11156)
ProxyAdmin_Test:test_setImplementationName_succeeds() (gas: 38945)
ProxyAdmin_Test:test_setProxyType_notOwner_reverts() (gas: 10814)
RLPReader_Test:test_readBytes_bytestring00_succeeds() (gas: 1857)
RLPReader_Test:test_readBytes_bytestring01_succeeds() (gas: 1900)
RLPReader_Test:test_readBytes_bytestring7f_succeeds() (gas: 1898)
RLPReader_Test:test_readBytes_invalidListLength_reverts() (gas: 3925)
RLPReader_Test:test_readBytes_invalidPrefix_reverts() (gas: 3983)
RLPReader_Test:test_readBytes_invalidRemainder_reverts() (gas: 4177)
RLPReader_Test:test_readBytes_invalidStringLength_reverts() (gas: 3880)
RLPReader_Test:test_readBytes_revertListItem_reverts() (gas: 4043)
RLPReader_Test:test_readList_dictTest1_succeeds() (gas: 23202)
RLPReader_Test:test_readList_empty_succeeds() (gas: 4613)
RLPReader_Test:test_readList_incorrectLengthInArray_reverts() (gas: 3954)
RLPReader_Test:test_readList_int32Overflow2_reverts() (gas: 4117)
RLPReader_Test:test_readList_int32Overflow_reverts() (gas: 4116)
RLPReader_Test:test_readList_invalidRemainder_reverts() (gas: 4158)
RLPReader_Test:test_readList_invalidShortList_reverts() (gas: 3967)
RLPReader_Test:test_readList_invalidValue_reverts() (gas: 3879)
RLPReader_Test:test_readList_leadingZerosInLongLengthArray1_reverts() (gas: 3982)
RLPReader_Test:test_readList_leadingZerosInLongLengthArray2_reverts() (gas: 3968)
RLPReader_Test:test_readList_leadingZerosInLongLengthList1_reverts() (gas: 4007)
RLPReader_Test:test_readList_listLongerThan32Elements_reverts() (gas: 38571)
RLPReader_Test:test_readList_listOfLists2_succeeds() (gas: 12169)
RLPReader_Test:test_readList_listOfLists_succeeds() (gas: 9482)
RLPReader_Test:test_readList_longList1_succeeds() (gas: 28417)
RLPReader_Test:test_readList_longList2_succeeds() (gas: 196855)
RLPReader_Test:test_readList_longListLessThan56Bytes_reverts() (gas: 4046)
RLPReader_Test:test_readList_longStringLength_reverts() (gas: 3924)
RLPReader_Test:test_readList_longStringLessThan56Bytes_reverts() (gas: 3998)
RLPReader_Test:test_readList_multiList_succeeds() (gas: 11784)
RLPReader_Test:test_readList_nonOptimalLongLengthArray1_reverts() (gas: 3999)
RLPReader_Test:test_readList_nonOptimalLongLengthArray2_reverts() (gas: 4000)
RLPReader_Test:test_readList_notEnoughContentForList1_reverts() (gas: 4138)
RLPReader_Test:test_readList_notEnoughContentForList2_reverts() (gas: 4139)
RLPReader_Test:test_readList_notEnoughContentForString1_reverts() (gas: 4094)
RLPReader_Test:test_readList_notEnoughContentForString2_reverts() (gas: 4138)
RLPReader_Test:test_readList_notLongEnough_reverts() (gas: 3933)
RLPReader_Test:test_readList_shortListMax1_succeeds() (gas: 39747)
RLPWriter_Test:test_writeList_dictTest1_succeeds() (gas: 37112)
RLPWriter_Test:test_writeList_empty_succeeds() (gas: 1743)
RLPWriter_Test:test_writeList_listoflists2_succeeds() (gas: 16656)
RLPWriter_Test:test_writeList_listoflists_succeeds() (gas: 10857)
RLPWriter_Test:test_writeList_longlist1_succeeds() (gas: 40467)
RLPWriter_Test:test_writeList_longlist2_succeeds() (gas: 281281)
RLPWriter_Test:test_writeList_multiList_succeeds() (gas: 22566)
RLPWriter_Test:test_writeList_shortListMax1_succeeds() (gas: 36918)
RLPWriter_Test:test_writeList_stringList_succeeds() (gas: 10742)
RLPWriter_Test:test_writeString_bytestring00_succeeds() (gas: 977)
RLPWriter_Test:test_writeString_bytestring01_succeeds() (gas: 998)
RLPWriter_Test:test_writeString_bytestring7f_succeeds() (gas: 1019)
RLPWriter_Test:test_writeString_empty_succeeds() (gas: 1644)
RLPWriter_Test:test_writeString_longstring2_succeeds() (gas: 258779)
RLPWriter_Test:test_writeString_longstring_succeeds() (gas: 16994)
RLPWriter_Test:test_writeString_shortstring2_succeeds() (gas: 15409)
RLPWriter_Test:test_writeString_shortstring_succeeds() (gas: 2480)
RLPWriter_Test:test_writeUint_mediumint2_succeeds() (gas: 8702)
RLPWriter_Test:test_writeUint_mediumint3_succeeds() (gas: 9123)
RLPWriter_Test:test_writeUint_mediumint_succeeds() (gas: 8405)
RLPWriter_Test:test_writeUint_smallint2_succeeds() (gas: 7290)
RLPWriter_Test:test_writeUint_smallint3_succeeds() (gas: 7311)
RLPWriter_Test:test_writeUint_smallint4_succeeds() (gas: 7312)
RLPWriter_Test:test_writeUint_smallint_succeeds() (gas: 7290)
RLPWriter_Test:test_writeUint_zero_succeeds() (gas: 7802)
RLPReader_readBytes_Test:test_readBytes_bytestring00_succeeds() (gas: 1834)
RLPReader_readBytes_Test:test_readBytes_bytestring01_succeeds() (gas: 1833)
RLPReader_readBytes_Test:test_readBytes_bytestring7f_succeeds() (gas: 1854)
RLPReader_readBytes_Test:test_readBytes_invalidListLength_reverts() (gas: 3924)
RLPReader_readBytes_Test:test_readBytes_invalidPrefix_reverts() (gas: 3939)
RLPReader_readBytes_Test:test_readBytes_invalidRemainder_reverts() (gas: 4133)
RLPReader_readBytes_Test:test_readBytes_invalidStringLength_reverts() (gas: 3857)
RLPReader_readBytes_Test:test_readBytes_revertListItem_reverts() (gas: 3976)
RLPReader_readList_Test:test_readList_dictTest1_succeeds() (gas: 23179)
RLPReader_readList_Test:test_readList_empty_succeeds() (gas: 4612)
RLPReader_readList_Test:test_readList_incorrectLengthInArray_reverts() (gas: 3976)
RLPReader_readList_Test:test_readList_int32Overflow2_reverts() (gas: 4094)
RLPReader_readList_Test:test_readList_int32Overflow_reverts() (gas: 4094)
RLPReader_readList_Test:test_readList_invalidRemainder_reverts() (gas: 4158)
RLPReader_readList_Test:test_readList_invalidShortList_reverts() (gas: 3967)
RLPReader_readList_Test:test_readList_invalidValue_reverts() (gas: 3878)
RLPReader_readList_Test:test_readList_leadingZerosInLongLengthArray1_reverts() (gas: 3982)
RLPReader_readList_Test:test_readList_leadingZerosInLongLengthArray2_reverts() (gas: 3945)
RLPReader_readList_Test:test_readList_leadingZerosInLongLengthList1_reverts() (gas: 3984)
RLPReader_readList_Test:test_readList_listLongerThan32Elements_reverts() (gas: 38571)
RLPReader_readList_Test:test_readList_listOfLists2_succeeds() (gas: 12124)
RLPReader_readList_Test:test_readList_listOfLists_succeeds() (gas: 9504)
RLPReader_readList_Test:test_readList_longList1_succeeds() (gas: 28372)
RLPReader_readList_Test:test_readList_longList2_succeeds() (gas: 196855)
RLPReader_readList_Test:test_readList_longListLessThan56Bytes_reverts() (gas: 4023)
RLPReader_readList_Test:test_readList_longStringLength_reverts() (gas: 3901)
RLPReader_readList_Test:test_readList_longStringLessThan56Bytes_reverts() (gas: 4009)
RLPReader_readList_Test:test_readList_multiList_succeeds() (gas: 11719)
RLPReader_readList_Test:test_readList_nonOptimalLongLengthArray1_reverts() (gas: 3999)
RLPReader_readList_Test:test_readList_nonOptimalLongLengthArray2_reverts() (gas: 4022)
RLPReader_readList_Test:test_readList_notEnoughContentForList1_reverts() (gas: 4115)
RLPReader_readList_Test:test_readList_notEnoughContentForList2_reverts() (gas: 4161)
RLPReader_readList_Test:test_readList_notEnoughContentForString1_reverts() (gas: 4072)
RLPReader_readList_Test:test_readList_notEnoughContentForString2_reverts() (gas: 4116)
RLPReader_readList_Test:test_readList_notLongEnough_reverts() (gas: 3955)
RLPReader_readList_Test:test_readList_shortListMax1_succeeds() (gas: 39724)
RLPWriter_writeList_Test:test_writeList_dictTest1_succeeds() (gas: 37112)
RLPWriter_writeList_Test:test_writeList_empty_succeeds() (gas: 1676)
RLPWriter_writeList_Test:test_writeList_listoflists2_succeeds() (gas: 16633)
RLPWriter_writeList_Test:test_writeList_listoflists_succeeds() (gas: 10879)
RLPWriter_writeList_Test:test_writeList_longlist1_succeeds() (gas: 40467)
RLPWriter_writeList_Test:test_writeList_longlist2_succeeds() (gas: 281258)
RLPWriter_writeList_Test:test_writeList_multiList_succeeds() (gas: 22546)
RLPWriter_writeList_Test:test_writeList_shortListMax1_succeeds() (gas: 36896)
RLPWriter_writeList_Test:test_writeList_stringList_succeeds() (gas: 10720)
RLPWriter_writeString_Test:test_writeString_bytestring00_succeeds() (gas: 954)
RLPWriter_writeString_Test:test_writeString_bytestring01_succeeds() (gas: 975)
RLPWriter_writeString_Test:test_writeString_bytestring7f_succeeds() (gas: 953)
RLPWriter_writeString_Test:test_writeString_empty_succeeds() (gas: 1621)
RLPWriter_writeString_Test:test_writeString_longstring2_succeeds() (gas: 258734)
RLPWriter_writeString_Test:test_writeString_longstring_succeeds() (gas: 16950)
RLPWriter_writeString_Test:test_writeString_shortstring2_succeeds() (gas: 15364)
RLPWriter_writeString_Test:test_writeString_shortstring_succeeds() (gas: 2502)
RLPWriter_writeUint_Test:test_writeUint_mediumint2_succeeds() (gas: 8714)
RLPWriter_writeUint_Test:test_writeUint_mediumint3_succeeds() (gas: 9091)
RLPWriter_writeUint_Test:test_writeUint_mediumint_succeeds() (gas: 8372)
RLPWriter_writeUint_Test:test_writeUint_smallint2_succeeds() (gas: 7279)
RLPWriter_writeUint_Test:test_writeUint_smallint3_succeeds() (gas: 7256)
RLPWriter_writeUint_Test:test_writeUint_smallint4_succeeds() (gas: 7280)
RLPWriter_writeUint_Test:test_writeUint_smallint_succeeds() (gas: 7258)
RLPWriter_writeUint_Test:test_writeUint_zero_succeeds() (gas: 7726)
ResourceMetering_Test:test_meter_initialResourceParams_succeeds() (gas: 8983)
ResourceMetering_Test:test_meter_updateNoGasDelta_succeeds() (gas: 2008119)
ResourceMetering_Test:test_meter_updateOneEmptyBlock_succeeds() (gas: 18148)
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts-bedrock/contracts/test/MerkleTrie.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
38 changes: 37 additions & 1 deletion packages/contracts-bedrock/contracts/test/MintManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -36,13 +46,20 @@ 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);
vm.expectRevert("Ownable: caller is not the owner");
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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -104,13 +133,20 @@ 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);
vm.expectRevert("Ownable: caller is not the owner");
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);
Expand Down
8 changes: 5 additions & 3 deletions packages/contracts-bedrock/contracts/test/RLPReader.t.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// 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");
}
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit a49e104

Please sign in to comment.