From 3a671bc0bde2593f1757c6e3f35b65a796cd168b Mon Sep 17 00:00:00 2001 From: "A.L." Date: Sun, 8 Dec 2024 14:26:57 +0800 Subject: [PATCH] test: assumeNotForgeAddress --- .gas-snapshot | 64 +++++++++++----------- test/large/ReservoirPriceOracleLarge.t.sol | 4 ++ test/unit/ReservoirPriceOracle.t.sol | 5 ++ 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 1afa0eb..2f10832 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,19 +1,19 @@ -QueryProcessorTest:testFindNearestSample_CanFindExactValue(uint32,uint256,uint256,uint256) (runs: 256, μ: 68323943, ~: 75988137) -QueryProcessorTest:testFindNearestSample_CanFindIntermediateValue(uint32,uint256,uint256,uint256) (runs: 256, μ: 68199477, ~: 76057768) +QueryProcessorTest:testFindNearestSample_CanFindExactValue(uint32,uint256,uint256,uint256) (runs: 257, μ: 68437350, ~: 75994076) +QueryProcessorTest:testFindNearestSample_CanFindIntermediateValue(uint32,uint256,uint256,uint256) (runs: 257, μ: 68313431, ~: 76223994) QueryProcessorTest:testFindNearestSample_NotInitialized() (gas: 1056944146) -QueryProcessorTest:testFindNearestSample_OneSample(uint256) (runs: 256, μ: 80620, ~: 80652) +QueryProcessorTest:testFindNearestSample_OneSample(uint256) (runs: 257, μ: 80620, ~: 80652) QueryProcessorTest:testGetInstantValue() (gas: 124418) -QueryProcessorTest:testGetInstantValue_NotInitialized(uint256) (runs: 256, μ: 19400, ~: 19400) -QueryProcessorTest:testGetInstantValue_NotInitialized_BeyondBufferSize(uint8,uint16) (runs: 256, μ: 69204594, ~: 69204518) -QueryProcessorTest:testGetPastAccumulator_BufferEmpty(uint8) (runs: 256, μ: 26912, ~: 26984) -QueryProcessorTest:testGetPastAccumulator_ExactMatch(uint32,uint256,uint256,uint16) (runs: 256, μ: 71558938, ~: 80209438) -QueryProcessorTest:testGetPastAccumulator_ExactMatch_LatestAccumulator(uint32,uint256,uint256) (runs: 256, μ: 70393014, ~: 80445450) -QueryProcessorTest:testGetPastAccumulator_ExactMatch_OldestAccumulator(uint32,uint256,uint256) (runs: 256, μ: 70423032, ~: 80477217) -QueryProcessorTest:testGetPastAccumulator_ExtrapolatesBeyondLatest(uint32,uint256,uint256,uint256) (runs: 256, μ: 68173090, ~: 76029150) -QueryProcessorTest:testGetPastAccumulator_InterpolatesBetweenPastAccumulators(uint32,uint256,uint256,uint256) (runs: 256, μ: 68207434, ~: 76064060) -QueryProcessorTest:testGetPastAccumulator_InvalidAgo(uint32,uint256,uint256,uint256) (runs: 256, μ: 68164662, ~: 76020502) -QueryProcessorTest:testGetPastAccumulator_QueryTooOld(uint32,uint256,uint256,uint256) (runs: 256, μ: 68176191, ~: 76030758) -QueryProcessorTest:testGetTimeWeightedAverage(uint32,uint256,uint256,uint256,uint256) (runs: 256, μ: 106049443, ~: 111585898) +QueryProcessorTest:testGetInstantValue_NotInitialized(uint256) (runs: 257, μ: 19400, ~: 19400) +QueryProcessorTest:testGetInstantValue_NotInitialized_BeyondBufferSize(uint8,uint16) (runs: 257, μ: 69204593, ~: 69204518) +QueryProcessorTest:testGetPastAccumulator_BufferEmpty(uint8) (runs: 257, μ: 26912, ~: 26984) +QueryProcessorTest:testGetPastAccumulator_ExactMatch(uint32,uint256,uint256,uint16) (runs: 257, μ: 71659782, ~: 80385588) +QueryProcessorTest:testGetPastAccumulator_ExactMatch_LatestAccumulator(uint32,uint256,uint256) (runs: 257, μ: 70498313, ~: 80481084) +QueryProcessorTest:testGetPastAccumulator_ExactMatch_OldestAccumulator(uint32,uint256,uint256) (runs: 257, μ: 70528337, ~: 80512851) +QueryProcessorTest:testGetPastAccumulator_ExtrapolatesBeyondLatest(uint32,uint256,uint256,uint256) (runs: 257, μ: 68287034, ~: 76195101) +QueryProcessorTest:testGetPastAccumulator_InterpolatesBetweenPastAccumulators(uint32,uint256,uint256,uint256) (runs: 257, μ: 68321382, ~: 76230286) +QueryProcessorTest:testGetPastAccumulator_InvalidAgo(uint32,uint256,uint256,uint256) (runs: 257, μ: 68278609, ~: 76186794) +QueryProcessorTest:testGetPastAccumulator_QueryTooOld(uint32,uint256,uint256,uint256) (runs: 257, μ: 68290130, ~: 76197049) +QueryProcessorTest:testGetTimeWeightedAverage(uint32,uint256,uint256,uint256,uint256) (runs: 257, μ: 106209680, ~: 111757971) QueryProcessorTest:testGetTimeWeightedAverage_BadSecs() (gas: 10981) ReservoirPriceOracleTest:testClearRoute() (gas: 52308) ReservoirPriceOracleTest:testClearRoute_AllWordsCleared() (gas: 160205) @@ -21,23 +21,23 @@ ReservoirPriceOracleTest:testDesignatePair() (gas: 29133) ReservoirPriceOracleTest:testDesignatePair_IncorrectPair() (gas: 21151) ReservoirPriceOracleTest:testDesignatePair_NotOwner() (gas: 17537) ReservoirPriceOracleTest:testDesignatePair_TokenOrderReversed() (gas: 30736) -ReservoirPriceOracleTest:testGetQuote(uint256,uint256) (runs: 256, μ: 33678, ~: 33784) +ReservoirPriceOracleTest:testGetQuote(uint256,uint256) (runs: 257, μ: 33676, ~: 33784) ReservoirPriceOracleTest:testGetQuote_AmountInTooLarge() (gas: 12996) -ReservoirPriceOracleTest:testGetQuote_BaseIsVault(uint256) (runs: 256, μ: 401348, ~: 401113) +ReservoirPriceOracleTest:testGetQuote_BaseIsVault(uint256) (runs: 257, μ: 401347, ~: 401113) ReservoirPriceOracleTest:testGetQuote_ComplicatedDecimals() (gas: 10362257) ReservoirPriceOracleTest:testGetQuote_ERC4626AssetFails() (gas: 21411) -ReservoirPriceOracleTest:testGetQuote_Inverse(uint256,uint256) (runs: 256, μ: 35859, ~: 36022) +ReservoirPriceOracleTest:testGetQuote_Inverse(uint256,uint256) (runs: 257, μ: 35857, ~: 36021) ReservoirPriceOracleTest:testGetQuote_MultipleHops() (gas: 111665) ReservoirPriceOracleTest:testGetQuote_MultipleHops_Inverse() (gas: 111959) ReservoirPriceOracleTest:testGetQuote_MultipleHops_PriceZero() (gas: 122258) ReservoirPriceOracleTest:testGetQuote_NoFallbackOracle() (gas: 20807) ReservoirPriceOracleTest:testGetQuote_PriceZero() (gas: 15919) -ReservoirPriceOracleTest:testGetQuote_RandomizeAllParam_1HopRoute(uint256,uint256,address,address,uint8,uint8) (runs: 256, μ: 5228818, ~: 5228843) -ReservoirPriceOracleTest:testGetQuote_RandomizeAllParam_2HopRoute(uint256,uint256,uint256,address,address,address,uint8,uint8,uint8) (runs: 256, μ: 10375806, ~: 10375962) -ReservoirPriceOracleTest:testGetQuote_SameBaseQuote(uint256,address) (runs: 256, μ: 8949, ~: 8949) +ReservoirPriceOracleTest:testGetQuote_RandomizeAllParam_1HopRoute(uint256,uint256,address,address,uint8,uint8) (runs: 257, μ: 5229794, ~: 5229817) +ReservoirPriceOracleTest:testGetQuote_RandomizeAllParam_2HopRoute(uint256,uint256,uint256,address,address,address,uint8,uint8,uint8) (runs: 257, μ: 10377272, ~: 10377464) +ReservoirPriceOracleTest:testGetQuote_SameBaseQuote(uint256,address) (runs: 257, μ: 8949, ~: 8949) ReservoirPriceOracleTest:testGetQuote_UseFallback() (gas: 38209) ReservoirPriceOracleTest:testGetQuote_ZeroIn() (gas: 36616) -ReservoirPriceOracleTest:testGetQuotes(uint256,uint256) (runs: 256, μ: 26257, ~: 26363) +ReservoirPriceOracleTest:testGetQuotes(uint256,uint256) (runs: 257, μ: 26255, ~: 26363) ReservoirPriceOracleTest:testName() (gas: 9355) ReservoirPriceOracleTest:testPriceCache_Inverted() (gas: 22028) ReservoirPriceOracleTest:testSetFallbackOracle_NotOwner() (gas: 10993) @@ -53,30 +53,30 @@ ReservoirPriceOracleTest:testSetRoute_OverwriteExisting() (gas: 173601) ReservoirPriceOracleTest:testSetRoute_SameToken() (gas: 13020) ReservoirPriceOracleTest:testUndesignatePair() (gas: 30263) ReservoirPriceOracleTest:testUndesignatePair_NotOwner() (gas: 15271) -ReservoirPriceOracleTest:testUpdatePrice_AboveThresholdBelowMaxReward(uint256) (runs: 256, μ: 162359, ~: 162386) -ReservoirPriceOracleTest:testUpdatePrice_BelowThreshold(uint256) (runs: 256, μ: 149778, ~: 149810) -ReservoirPriceOracleTest:testUpdatePrice_BeyondMaxReward(uint256) (runs: 256, μ: 159660, ~: 159609) +ReservoirPriceOracleTest:testUpdatePrice_AboveThresholdBelowMaxReward(uint256) (runs: 257, μ: 162359, ~: 162386) +ReservoirPriceOracleTest:testUpdatePrice_BelowThreshold(uint256) (runs: 257, μ: 149779, ~: 149810) +ReservoirPriceOracleTest:testUpdatePrice_BeyondMaxReward(uint256) (runs: 257, μ: 159659, ~: 159609) ReservoirPriceOracleTest:testUpdatePrice_FirstUpdate() (gas: 153341) ReservoirPriceOracleTest:testUpdatePrice_IntermediateRoutes() (gas: 11082517) ReservoirPriceOracleTest:testUpdatePrice_NoPath() (gas: 15942) ReservoirPriceOracleTest:testUpdatePrice_PriceOutOfRange() (gas: 5374183) ReservoirPriceOracleTest:testUpdatePrice_RewardEligible_ContractNoReceive() (gas: 150457) -ReservoirPriceOracleTest:testUpdatePrice_RewardEligible_InsufficientReward(uint256) (runs: 256, μ: 208788, ~: 208867) +ReservoirPriceOracleTest:testUpdatePrice_RewardEligible_InsufficientReward(uint256) (runs: 257, μ: 208786, ~: 208726) ReservoirPriceOracleTest:testUpdatePrice_RewardEligible_ZeroRecipient() (gas: 144136) ReservoirPriceOracleTest:testUpdatePrice_WriteToNonSimpleRoute() (gas: 502310) ReservoirPriceOracleTest:testUpdateRewardGasAmount() (gas: 19117) ReservoirPriceOracleTest:testUpdateRewardGasAmount_NotOwner() (gas: 11010) -ReservoirPriceOracleTest:testUpdateTwapPeriod(uint256) (runs: 256, μ: 21674, ~: 21756) -ReservoirPriceOracleTest:testUpdateTwapPeriod_InvalidTwapPeriod(uint256) (runs: 256, μ: 17851, ~: 18066) +ReservoirPriceOracleTest:testUpdateTwapPeriod(uint256) (runs: 257, μ: 21672, ~: 21756) +ReservoirPriceOracleTest:testUpdateTwapPeriod_InvalidTwapPeriod(uint256) (runs: 257, μ: 17852, ~: 18066) ReservoirPriceOracleTest:testValidatePair_NoDesignatedPair() (gas: 119138) -ReservoirPriceOracleTest:testWritePriceCache(uint256) (runs: 256, μ: 30010, ~: 29775) +ReservoirPriceOracleTest:testWritePriceCache(uint256) (runs: 257, μ: 30009, ~: 29775) RoutesLibTest:testGetDecimalDifference() (gas: 3966) RoutesLibTest:testIsCompositeRoute() (gas: 4332) -RoutesLibTest:testPackSimplePrice(int8,uint64,uint256) (runs: 256, μ: 8167, ~: 7915) +RoutesLibTest:testPackSimplePrice(int8,uint64,uint256) (runs: 257, μ: 8169, ~: 7915) SamplesTest:testAccumulator() (gas: 3930) SamplesTest:testAccumulator_BadVariableRequest() (gas: 3355) SamplesTest:testInstant() (gas: 3880) SamplesTest:testInstant_BadVariableRequest() (gas: 3376) -UtilsTest:testCalcPercentageDiff_Double(uint256) (runs: 256, μ: 7055, ~: 6836) -UtilsTest:testCalcPercentageDiff_Half(uint256) (runs: 256, μ: 7230, ~: 7432) -UtilsTest:testCalcPercentageDiff_NoDiff(uint256) (runs: 256, μ: 6836, ~: 6622) \ No newline at end of file +UtilsTest:testCalcPercentageDiff_Double(uint256) (runs: 257, μ: 7054, ~: 6836) +UtilsTest:testCalcPercentageDiff_Half(uint256) (runs: 257, μ: 7231, ~: 7432) +UtilsTest:testCalcPercentageDiff_NoDiff(uint256) (runs: 257, μ: 6835, ~: 6622) \ No newline at end of file diff --git a/test/large/ReservoirPriceOracleLarge.t.sol b/test/large/ReservoirPriceOracleLarge.t.sol index 1a7cf37..f3580ba 100644 --- a/test/large/ReservoirPriceOracleLarge.t.sol +++ b/test/large/ReservoirPriceOracleLarge.t.sol @@ -42,6 +42,10 @@ contract ReservoirPriceOracleLargeTest is ReservoirPriceOracleTest { assumeNotZeroAddress(aTokenBAddress); assumeNotZeroAddress(aTokenCAddress); assumeNotZeroAddress(aTokenDAddress); + assumeNotForgeAddress(aTokenAAddress); + assumeNotForgeAddress(aTokenBAddress); + assumeNotForgeAddress(aTokenCAddress); + assumeNotForgeAddress(aTokenDAddress); uint256 lPrice1 = bound(aPrice1, 1e12, 1e24); uint256 lPrice2 = bound(aPrice2, 1e12, 1e24); uint256 lPrice3 = bound(aPrice3, 1e12, 1e24); diff --git a/test/unit/ReservoirPriceOracle.t.sol b/test/unit/ReservoirPriceOracle.t.sol index eac916c..5a7ecc6 100644 --- a/test/unit/ReservoirPriceOracle.t.sol +++ b/test/unit/ReservoirPriceOracle.t.sol @@ -264,6 +264,8 @@ contract ReservoirPriceOracleTest is BaseTest { assumeNotPrecompile(aTokenBAddress); assumeNotZeroAddress(aTokenAAddress); assumeNotZeroAddress(aTokenBAddress); + assumeNotForgeAddress(aTokenAAddress); + assumeNotForgeAddress(aTokenBAddress); uint256 lPrice = bound(aPrice, 1, 1e36); uint256 lAmtIn = bound(aAmtIn, 0, 1_000_000_000); uint256 lTokenADecimal = bound(aTokenADecimal, 0, 18); @@ -316,6 +318,9 @@ contract ReservoirPriceOracleTest is BaseTest { assumeNotZeroAddress(aTokenAAddress); assumeNotZeroAddress(aTokenBAddress); assumeNotZeroAddress(aTokenCAddress); + assumeNotForgeAddress(aTokenAAddress); + assumeNotForgeAddress(aTokenBAddress); + assumeNotForgeAddress(aTokenCAddress); uint256 lPrice1 = bound(aPrice1, 1e9, 1e25); // need to bound price within this range as a price below this will go to zero as during the mul and div of prices uint256 lPrice2 = bound(aPrice2, 1e9, 1e25); uint256 lAmtIn = bound(aAmtIn, 0, 1_000_000_000);