From 351675789660d08a55424cda3dd9aa0b319eefcb Mon Sep 17 00:00:00 2001 From: katzman Date: Thu, 13 Jun 2024 14:53:17 -0700 Subject: [PATCH] CI (#30) * Set CI to run on main branches * Setup CI to run on branches * Add additional checks * Added gas snapshot * Fix flaky test * remove snapshot tolerance for now * Remove snapshotting entirely for now --- .gas-snapshot | 200 ++++++++++++++++++++++++++ .github/workflows/test.yml | 17 ++- test/BaseRegistrar/RegisterOnly.t.sol | 2 +- 3 files changed, 212 insertions(+), 7 deletions(-) create mode 100644 .gas-snapshot diff --git a/.gas-snapshot b/.gas-snapshot new file mode 100644 index 00000000..312a66a9 --- /dev/null +++ b/.gas-snapshot @@ -0,0 +1,200 @@ +AddController:test_allowsOwnerToSetController(address) (runs: 256, μ: 39152, ~: 39152) +AddController:test_reverts_whenCalledByNonOwner(address) (runs: 256, μ: 13540, ~: 13540) +AdminMethods:test_addSigners(address[]) (runs: 256, μ: 141779, ~: 140942) +AdminMethods:test_constructor() (gas: 1177376) +AdminMethods:test_removeSigner() (gas: 27194) +AdminMethods:test_setRootResolver(address) (runs: 256, μ: 26371, ~: 26371) +AdminMethods:test_setUrl(string) (runs: 256, μ: 52646, ~: 29368) +Approve:test_allowsSenderToSetDelegate(address) (runs: 256, μ: 42952, ~: 42952) +Approve:test_constructor() (gas: 27352) +Approve:test_revertsIfCalledForSelf() (gas: 13279) +Available:test_controller_constructor() (gas: 40453) +Available:test_returnsFalse_whenInvalidLength() (gas: 41476) +Available:test_returnsFalse_whenNotAvailableOnBase() (gas: 23329) +Available:test_returnsTrue_whenValidAndAvailable() (gas: 43262) +Claim:test_allowsUser_toClaim() (gas: 111412) +Claim:test_constructor() (gas: 16031) +ClaimForAddr:test_allowsOperator_toClaimForAddr_forUserAddress() (gas: 111292) +ClaimForAddr:test_allowsOwnerOfContract_toClaimForAddr_forOwnedContractAddress() (gas: 293178) +ClaimForAddr:test_allowsUser_toClaimForAddr_forUserAddress() (gas: 82978) +ClaimForAddr:test_constructor() (gas: 16119) +ClaimForAddr:test_reverts_ifNotAuthorized() (gas: 24420) +ClaimWithResolver:test_allowsUser_toClaimWithResolver() (gas: 82589) +ClaimWithResolver:test_constructor() (gas: 16031) +DiscountedRegister:test_controller_constructor() (gas: 40711) +DiscountedRegister:test_registersWithDiscountSuccessfully() (gas: 407611) +DiscountedRegister:test_reverts_ifTheDiscountIsInactive() (gas: 136181) +DiscountedRegister:test_reverts_whenDurationTooShort() (gas: 189860) +DiscountedRegister:test_reverts_whenInvalidDiscountRegistration() (gas: 157108) +DiscountedRegister:test_reverts_whenNameNotAvailble() (gas: 169919) +DiscountedRegister:test_reverts_whenValueTooSmall() (gas: 221891) +DiscountedRegister:test_sendsARefund_ifUserOverpayed() (gas: 407315) +Fallback:test_constructor() (gas: 1177132) +Fallback:test_forwardsAddrCall_whenResolvingRootName() (gas: 16230) +Fallback:test_forwardsTextCall_whenResolvingRootName() (gas: 18927) +IsAuthorised:test_constructor() (gas: 27484) +IsAuthorised:test_returnsTrue_ifSenderIDelegateOfNode(address) (runs: 256, μ: 118641, ~: 118641) +IsAuthorised:test_returnsTrue_ifSenderIOperatorOfNode(address) (runs: 256, μ: 115383, ~: 115383) +IsAuthorised:test_returnsTrue_ifSenderIOwnerOfNode() (gas: 88455) +IsAuthorised:test_returnsTrue_ifSenderIsController() (gas: 49269) +IsAuthorised:test_returnsTrue_ifSenderIsReverse() (gas: 51557) +IsAvailable:test_returnsAvailabilityAsExpected() (gas: 162862) +IsValidDiscountRegistration:test_returnsFalse_forInvalidProof(address) (runs: 256, μ: 19323, ~: 19323) +IsValidDiscountRegistration:test_returnsTrue_forValidProof() (gas: 28522) +L1ResolverTestBase:test_constructor() (gas: 1177023) +L2ResolverBase:test_constructor() (gas: 27352) +MakeSignatureHash:test_constructor() (gas: 1177184) +MakeSignatureHash:test_makesValidSignatureHash(address,uint64,bytes,bytes) (runs: 256, μ: 12271, ~: 12165) +Node:test_constructor() (gas: 16031) +Node:test_returnsExpectedNode(address) (runs: 256, μ: 14644, ~: 14644) +OwnerOf:test_returnsTheOwner(address) (runs: 256, μ: 157387, ~: 157387) +OwnerOf:test_reverts_whenNameHasExpired() (gas: 159743) +Premium:test_constructor() (gas: 26743) +Premium:test_premium() (gas: 8922) +Price:test_constructor() (gas: 26765) +Price:test_price_calculatePrice_oneLetter() (gas: 14816) +Price:test_price_calculatesPrice_fiveLetters() (gas: 15948) +Price:test_price_calculatesPrice_fourLetters() (gas: 15661) +Price:test_price_calculatesPrice_moreThanFive_lessThanTenLetters() (gas: 15941) +Price:test_price_calculatesPrice_moreThanTenLetters() (gas: 17377) +Price:test_price_calculatesPrice_tenLetters() (gas: 17470) +Price:test_price_calculatesPrice_threeLetters() (gas: 15442) +Price:test_price_calculatesPrice_twoLetters() (gas: 15156) +Reclaim:test_reclaimsOwnership_whenCalledByOperator_approvedForAll(address) (runs: 256, μ: 198214, ~: 198214) +Reclaim:test_reclaimsOwnership_whenCalledByOperator_beforeExpiry(address) (runs: 256, μ: 194115, ~: 194115) +Reclaim:test_reclaimsOwnership_whenCalledByOwner_beforeExpiry() (gas: 167271) +Reclaim:test_reverts_whenCalledAfterExpiry() (gas: 161872) +Reclaim:test_reverts_whenCalledByNonOwnerOrApprovedOperator(address) (runs: 256, μ: 166938, ~: 166938) +Reclaim:test_reverts_whenNotLive() (gas: 32543) +Register:test_controller_constructor() (gas: 40689) +Register:test_registersSuccessfully() (gas: 271788) +Register:test_reverts_ifTheNameIsNotAvailable(address) (runs: 256, μ: 162486, ~: 162486) +Register:test_reverts_ifTheNameIsNotAvailable_duringGracePeriod(address) (runs: 256, μ: 163325, ~: 163325) +Register:test_reverts_whenCalledByNonController(address) (runs: 256, μ: 27453, ~: 27453) +Register:test_reverts_whenDurationTooShort() (gas: 79441) +Register:test_reverts_whenNameNotAvailble() (gas: 59475) +Register:test_reverts_whenResolverRequiredAndNotSupplied() (gas: 48100) +Register:test_reverts_whenTheRegistrarIsNotLive() (gas: 35084) +Register:test_reverts_whenValueTooSmall() (gas: 81660) +Register:test_sendsARefund_ifUserOverpayed() (gas: 267540) +Register:test_successfullyRegisters() (gas: 168768) +Register:test_successfullyRegisters_afterExpiry(address) (runs: 256, μ: 193967, ~: 193967) +RegisterOnly:test_reverts_ifTheNameIsNotAvailable(address) (runs: 256, μ: 134694, ~: 134694) +RegisterOnly:test_reverts_ifTheNameIsNotAvailable_duringGracePeriod(address) (runs: 256, μ: 135446, ~: 135446) +RegisterOnly:test_reverts_whenCalledByNonController(address) (runs: 256, μ: 27411, ~: 27411) +RegisterOnly:test_reverts_whenTheRegistrarIsNotLive() (gas: 34987) +RegisterOnly:test_successfullyRegistersOnly() (gas: 138506) +RegisterOnly:test_successfullyRegisters_afterExpiry(address) (runs: 256, μ: 157934, ~: 157934) +RegisterPrice:test_controller_constructor() (gas: 40397) +RegisterPrice:test_fuzz_returnsRegisterPrice_fromPricingOracle(uint256,uint256) (runs: 256, μ: 72677, ~: 72755) +RegisterPrice:test_returnsRegisterPrice_fromPricingOracle() (gas: 33097) +RegisterWithRecord:test_reverts_ifTheNameIsNotAvailable(address) (runs: 256, μ: 164842, ~: 164842) +RegisterWithRecord:test_reverts_ifTheNameIsNotAvailable_duringGracePeriod(address) (runs: 256, μ: 165681, ~: 165681) +RegisterWithRecord:test_reverts_whenCalledByNonController(address) (runs: 256, μ: 29774, ~: 29774) +RegisterWithRecord:test_reverts_whenTheRegistrarIsNotLive() (gas: 37393) +RegisterWithRecord:test_successfullyRegisters() (gas: 202186) +RegisterWithRecord:test_successfullyRegisters_afterExpiry(address) (runs: 256, μ: 227268, ~: 227268) +RegistrarControllerBase:test_controller_constructor() (gas: 40429) +RegistryBase:test_constructor_setsTheRootNodeOwner() (gas: 12744) +RemoveController:test_allowsOwnerToRemoveController(address) (runs: 256, μ: 30547, ~: 30533) +RemoveController:test_reverts_whenCalledByNonOwner(address) (runs: 256, μ: 13538, ~: 13538) +Renew:test_renewsOwnershipSuccessfully_whenInGracePeriod() (gas: 167816) +Renew:test_renewsOwnershipSuccessfully_whenNotExpired() (gas: 167783) +Renew:test_reverts_whenCalledByNonController(address) (runs: 256, μ: 27694, ~: 27694) +Renew:test_reverts_whenNotInGracePeriod() (gas: 161989) +Renew:test_reverts_whenNotLive() (gas: 32390) +Renew:test_reverts_whenNotRegistered() (gas: 59548) +RentPrice:test_controller_constructor() (gas: 40462) +RentPrice:test_fuzz_returnsPrice_fromPricingOracle(uint256,uint256) (runs: 256, μ: 73027, ~: 73105) +RentPrice:test_returnsPrice_fromPricingOracle() (gas: 33416) +Resolve:test_constructor() (gas: 1177226) +Resolve:test_resolvesAddr_whenCallingforRootName() (gas: 21499) +Resolve:test_resolvesText_whenCallingforRootName() (gas: 25157) +Resolve:test_revertsWithOffchainLookup_whenResolvingName(string) (runs: 256, μ: 37374, ~: 37238) +ResolveWithProof:test_constructor() (gas: 1177402) +ResolveWithProof:test_returnsResultsWithValidSignature(string) (runs: 256, μ: 48234, ~: 47479) +ResolveWithProof:test_revertsWhenTheSignatureIsExpired(string) (runs: 256, μ: 47050, ~: 46293) +ResolveWithProof:test_revertsWhenTheSignerIsInvalid(string) (runs: 256, μ: 47089, ~: 46332) +ReverseRegistrarBase:test_constructor() (gas: 16031) +SetApprovalForAll:test_allowsSenderToSetApproval(address) (runs: 256, μ: 39746, ~: 39746) +SetApprovalForAll:test_constructor() (gas: 27352) +SetApprovalForAll:test_revertsIfCalledForSelf() (gas: 11215) +SetDefaultResolver:test_constructor() (gas: 16097) +SetDefaultResolver:test_reverts_whenCalledByNonOwner(address) (runs: 256, μ: 15369, ~: 15369) +SetDefaultResolver:test_reverts_whenPassedZeroAddress() (gas: 13139) +SetDefaultResolver:test_setsTheDefaultResolver() (gas: 40755) +SetDiscountDetails:test_addsAndRemoves_fromActiveDiscounts() (gas: 112484) +SetDiscountDetails:test_controller_constructor() (gas: 40709) +SetDiscountDetails:test_reverts_ifCalledByNonOwner(address) (runs: 256, μ: 20903, ~: 20903) +SetDiscountDetails:test_reverts_ifTheDiscounValidatorIsInvalid() (gas: 21263) +SetDiscountDetails:test_reverts_ifTheDiscountIsZero() (gas: 21182) +SetDiscountDetails:test_reverts_ifTheDiscountKeysMismatch() (gas: 21114) +SetDiscountDetails:test_setsTheDetailsAccordingly() (gas: 120721) +SetName:test_constructor() (gas: 16031) +SetName:test_setsName() (gas: 146292) +SetNameForAddr:test_allowsOperator_toSetName_forUserAddress() (gas: 177376) +SetNameForAddr:test_allowsOwnerOfContract_toSetName_forOwnedContractAddress() (gas: 326472) +SetNameForAddr:test_allowsUser_toSetName_forUserAddress() (gas: 149121) +SetNameForAddr:test_constructor() (gas: 16097) +SetOwner:test_constructor_setsTheRootNodeOwner() (gas: 12773) +SetOwner:test_reverts_whenTheCallerIsNotAuthroized(address) (runs: 256, μ: 18113, ~: 18113) +SetOwner:test_setsOwnerCorrectly() (gas: 23171) +SetPriceOracle:test_controller_constructor() (gas: 40407) +SetPriceOracle:test_reverts_ifCalledByNonOwner(address) (runs: 256, μ: 218941, ~: 218941) +SetPriceOracle:test_setsThePriceOracleAccordingly() (gas: 227285) +SetRecord:test_constructor_setsTheRootNodeOwner() (gas: 12795) +SetRecord:test_reverts_whenTheCallerIsNotAuthroized(address) (runs: 256, μ: 20567, ~: 20567) +SetRecord:test_setsTheRecordCorrectly() (gas: 58605) +SetRegistrarController:test_constructor() (gas: 27374) +SetRegistrarController:test_reverts_ifCalledByNonOwner(address,address) (runs: 256, μ: 13641, ~: 13641) +SetRegistrarController:test_setsTheRegistrarControllerAccordingly(address) (runs: 256, μ: 22066, ~: 22066) +SetResolver:test_allowsTheOwnerToSetTheResolver(address) (runs: 256, μ: 51718, ~: 51718) +SetResolver:test_constructor_setsTheRootNodeOwner() (gas: 12773) +SetResolver:test_constructor_setsTheRootNodeOwner() (gas: 12800) +SetResolver:test_reverts_whenCalledByNonOwner(address) (runs: 256, μ: 13569, ~: 13569) +SetResolver:test_reverts_whenTheCallerIsNotAuthroized(address) (runs: 256, μ: 18224, ~: 18224) +SetResolver:test_revokesApprovalCorrectly() (gas: 62026) +SetResolver:test_setsApprovalCorrectly() (gas: 72101) +SetResolver:test_setsTheResolverCorrectly() (gas: 42281) +SetReverseRegistrar:test_constructor() (gas: 27374) +SetReverseRegistrar:test_controller_constructor() (gas: 40429) +SetReverseRegistrar:test_reverts_ifCalledByNonOwner(address) (runs: 256, μ: 325507, ~: 325507) +SetReverseRegistrar:test_reverts_ifCalledByNonOwner(address,address) (runs: 256, μ: 13707, ~: 13707) +SetReverseRegistrar:test_setsTheReverseRegistrarAccordingly() (gas: 333790) +SetReverseRegistrar:test_setsTheReverseRegistrarAccordingly(address) (runs: 256, μ: 22068, ~: 22068) +SetRoot:test_allowsTheOwnerToSetTheRoot(bytes32) (runs: 256, μ: 17839, ~: 17839) +SetRoot:test_reverts_ifCalledByNonowner(address) (runs: 256, μ: 13486, ~: 13486) +SetSubnodeOwner:test_constructor_setsTheRootNodeOwner() (gas: 12773) +SetSubnodeOwner:test_reverts_whenTheCallerIsNotAuthroized(address) (runs: 256, μ: 20318, ~: 20318) +SetSubnodeOwner:test_setsSubnodeOwnerCorrectly() (gas: 45753) +SetSubnodeRecord:test_constructor_setsTheRootNodeOwner() (gas: 12795) +SetSubnodeRecord:test_reverts_whenTheCallerIsNotAuthroized(address) (runs: 256, μ: 22688, ~: 22688) +SetSubnodeRecord:test_setsTheSubnodeRecordCorrectly() (gas: 80980) +SetTTL:test_constructor_setsTheRootNodeOwner() (gas: 12795) +SetTTL:test_reverts_whenTheCallerIsNotAuthroized(address) (runs: 256, μ: 18246, ~: 18246) +SetTTL:test_setsTheTTLCorrectly() (gas: 40082) +StablePriceFuzzTest:test_price(string,uint256,uint256,uint256) (runs: 256, μ: 372709, ~: 372548) +StablePriceOracleBase:test_constructor() (gas: 26743) +SupportsInterface:test_constructor() (gas: 1177083) +SupportsInterface:test_constructor() (gas: 27375) +SupportsInterface:test_doesNotSupportArbitraryInterfaceId(bytes4) (runs: 256, μ: 14785, ~: 14785) +SupportsInterface:test_supportsABIResolver() (gas: 9378) +SupportsInterface:test_supportsAddrResolver() (gas: 9280) +SupportsInterface:test_supportsContentHashResolver() (gas: 9202) +SupportsInterface:test_supportsDNSRecordResolver() (gas: 9084) +SupportsInterface:test_supportsDNSZoneResolver() (gas: 9076) +SupportsInterface:test_supportsERC165() (gas: 8585) +SupportsInterface:test_supportsExtendedResolver() (gas: 8556) +SupportsInterface:test_supportsForwarding_toIAddrCompliantRootResolver() (gas: 14095) +SupportsInterface:test_supportsForwarding_toITextCompliantRootResolver() (gas: 14090) +SupportsInterface:test_supportsInterfaceResolver() (gas: 8940) +SupportsInterface:test_supportsMulticallable() (gas: 9608) +SupportsInterface:test_supportsNameResolver() (gas: 8869) +SupportsInterface:test_supportsPubkeyResolver() (gas: 8796) +SupportsInterface:test_supportsTextResolver() (gas: 8679) +Valid:test_controller_constructor() (gas: 40442) +Valid:test_returnsFalse_whenInvalid() (gas: 13775) +Valid:test_returnsTrue_whenValid() (gas: 20503) +discountedRegisterPrice:test_controller_constructor() (gas: 40462) +discountedRegisterPrice:test_returnsADiscountedPrice_whenThePriceIsGreaterThanTheDiscount(uint256) (runs: 256, μ: 161725, ~: 161725) +discountedRegisterPrice:test_returnsZero_whenThePriceIsLessThanOrEqualToTheDiscount(uint256) (runs: 256, μ: 161218, ~: 161468) \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9282e829..a02e71fa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,16 +1,16 @@ name: test -on: workflow_dispatch +on: + pull_request: + branches: + - main env: FOUNDRY_PROFILE: ci jobs: - check: - strategy: - fail-fast: true - - name: Foundry project + forge-test: + name: Run Forge Tests and Checks runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -32,3 +32,8 @@ jobs: run: | forge test -vvv id: test + + - name: Check formatting + run: | + forge fmt --check + id: fmt diff --git a/test/BaseRegistrar/RegisterOnly.t.sol b/test/BaseRegistrar/RegisterOnly.t.sol index 04530224..bb77006f 100644 --- a/test/BaseRegistrar/RegisterOnly.t.sol +++ b/test/BaseRegistrar/RegisterOnly.t.sol @@ -39,7 +39,7 @@ contract RegisterOnly is BaseRegistrarBase { } function test_successfullyRegisters_afterExpiry(address newOwner) public { - vm.assume(newOwner != user); + vm.assume(newOwner != user && newOwner != address(0)); _registrationSetup(); vm.warp(blockTimestamp);