From 09b756aeb9186a33eed0c71aa9c9c7a5448b6b91 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Fri, 23 Aug 2024 13:00:04 +0400 Subject: [PATCH] fix tests --- .gas-snapshot | 152 ++++++++++++++++++ ...DecimalFloatImplementation.normalize.t.sol | 2 +- 2 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 .gas-snapshot diff --git a/.gas-snapshot b/.gas-snapshot new file mode 100644 index 0000000..7e2596f --- /dev/null +++ b/.gas-snapshot @@ -0,0 +1,152 @@ +LibDecimalFloatAbsTest:testAbsMinValue(int256) (runs: 5101, μ: 4405, ~: 4405) +LibDecimalFloatAbsTest:testAbsNegative(int256,int256) (runs: 5101, μ: 9362, ~: 9559) +LibDecimalFloatAbsTest:testAbsNonNegative(int256,int256) (runs: 5101, μ: 8589, ~: 8351) +LibDecimalFloatDecimalAddTest:testAdd123456789987654321() (gas: 4792) +LibDecimalFloatDecimalAddTest:testAdd123456789e9987654321() (gas: 4845) +LibDecimalFloatDecimalAddTest:testAddNeverRevert(int256,int256,int256,int256) (runs: 5101, μ: 12719, ~: 12558) +LibDecimalFloatDecimalAddTest:testAddOneOneNotNormalized() (gas: 5339) +LibDecimalFloatDecimalAddTest:testAddOneOnePreNormalized() (gas: 4241) +LibDecimalFloatDecimalAddTest:testAddOneZero() (gas: 3679) +LibDecimalFloatDecimalAddTest:testAddSameExponentSameCoefficient(int256,int256) (runs: 5101, μ: 5734, ~: 5785) +LibDecimalFloatDecimalAddTest:testAddZero() (gas: 3654) +LibDecimalFloatDecimalAddTest:testAddZeroAnyExponent(int128) (runs: 5101, μ: 8902, ~: 8892) +LibDecimalFloatDecimalAddTest:testAddZeroOne() (gas: 3677) +LibDecimalFloatDecimalAddTest:testAddZeroToAnyNonZero(int256,int256,int256) (runs: 5101, μ: 13525, ~: 13432) +LibDecimalFloatDecimalAddTest:testAddingSmallToLargeReturnsLargeExamples() (gas: 19203) +LibDecimalFloatDecimalAddTest:testAddingSmallToLargeReturnsLargeFuzz(int256,int256,int256,int256) (runs: 5100, μ: 16584, ~: 16454) +LibDecimalFloatDecimalAddTest:testGasAddOne() (gas: 938) +LibDecimalFloatDecimalAddTest:testGasAddZero() (gas: 377) +LibDecimalFloatDecimalLosslessTest:testFromFixedDecimalLosslessFail(uint256,uint8) (runs: 5100, μ: 9228, ~: 9275) +LibDecimalFloatDecimalLosslessTest:testFromFixedDecimalLosslessPass(uint256,uint8) (runs: 5101, μ: 7293, ~: 7265) +LibDecimalFloatDecimalLosslessTest:testToFixedDecimalLosslessFail() (gas: 3855) +LibDecimalFloatDecimalLosslessTest:testToFixedDecimalLosslessPass(int256,int256,uint8) (runs: 5101, μ: 14690, ~: 14643) +LibDecimalFloatDecimalTest:testFixedDecimalRoundTripLossless(uint256,uint8) (runs: 5101, μ: 8820, ~: 8598) +LibDecimalFloatDecimalTest:testFromFixedDecimalLossyComplicated() (gas: 600531) +LibDecimalFloatDecimalTest:testFromFixedDecimalLossyNormalizedMax() (gas: 588079) +LibDecimalFloatDecimalTest:testFromFixedDecimalLossyNormalizedMaxPlusOne() (gas: 618935) +LibDecimalFloatDecimalTest:testFromFixedDecimalLossyOne() (gas: 600509) +LibDecimalFloatDecimalTest:testFromFixedDecimalLossyOneMillion() (gas: 600510) +LibDecimalFloatDecimalTest:testFromFixedDecimalLossyOverflow() (gas: 629579) +LibDecimalFloatDecimalTest:testFromFixedDecimalLossyTruncateOne(uint256,uint8) (runs: 5101, μ: 5564, ~: 5525) +LibDecimalFloatDecimalTest:testFromFixedDecimalLossyTruncateZero(uint256,uint8) (runs: 5101, μ: 7001, ~: 5537) +LibDecimalFloatDecimalTest:testToFixedDecimalLosslessScaleUp(int256,int256,uint8) (runs: 5098, μ: 14943, ~: 14883) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyExponentOverflow(int256,int256,uint8) (runs: 5101, μ: 13549, ~: 13322) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyIdentity(int256,uint8) (runs: 5101, μ: 9445, ~: 9214) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyNegative(int256,int256,uint8) (runs: 5101, μ: 9121, ~: 9323) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyScaleUpOverflow(int256,int256,uint8) (runs: 5099, μ: 12845, ~: 13054) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyTruncate(int256,int256,uint8) (runs: 5101, μ: 13450, ~: 13229) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyTruncateLossless() (gas: 13134) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyUnderflow(int256,int256,uint8) (runs: 5101, μ: 12488, ~: 12422) +LibDecimalFloatDecimalTest:testToFixedDecimalLossyZero(int256,uint8) (runs: 5101, μ: 4346, ~: 4346) +LibDecimalFloatDivideTest:testDivide1Over3() (gas: 5724) +LibDecimalFloatDivideTest:testDivide1Over3Gas0() (gas: 755) +LibDecimalFloatDivideTest:testDivide1Over3Gas10() (gas: 6851) +LibDecimalFloatDivideTest:testDivide1Over9Over1Over3() (gas: 8894) +LibDecimalFloatDivideTest:testDivide1e18Over3() (gas: 5736) +LibDecimalFloatDivideTest:testDivideNegative1Over3() (gas: 5793) +LibDecimalFloatDivideTest:testDivideOOMs5and2() (gas: 4601) +LibDecimalFloatDivideTest:testDivideOOMsOverTen() (gas: 5427) +LibDecimalFloatDivideTest:testDivideTenOverOOMs() (gas: 5353) +LibDecimalFloatDivideTest:testUnnormalizedThreesDivision0(int256,int256) (runs: 105, μ: 19644355, ~: 19644589) +LibDecimalFloatEqTest:testEqGasAZero() (gas: 425) +LibDecimalFloatEqTest:testEqGasBZero() (gas: 468) +LibDecimalFloatEqTest:testEqGasBothZero() (gas: 445) +LibDecimalFloatEqTest:testEqGasDifferentSigns() (gas: 477) +LibDecimalFloatEqTest:testEqGasExponentDiffOverflow() (gas: 572) +LibDecimalFloatEqTest:testEqNotReverts(int256,int256,int256,int256) (runs: 5101, μ: 647, ~: 671) +LibDecimalFloatEqTest:testEqOneEAny(int256,int256) (runs: 5101, μ: 3410, ~: 3410) +LibDecimalFloatEqTest:testEqReference(int256,int256,int256,int256) (runs: 5101, μ: 9885, ~: 11423) +LibDecimalFloatEqTest:testEqX(int256) (runs: 5101, μ: 3384, ~: 3384) +LibDecimalFloatEqTest:testEqXEAnyVsXEAny(int256,int256,int256) (runs: 5101, μ: 4699, ~: 4697) +LibDecimalFloatEqTest:testEqXEqY(int256,int256,int256,int256) (runs: 5101, μ: 724, ~: 744) +LibDecimalFloatEqTest:testEqXNotY(int256,int256,int256,int256) (runs: 5101, μ: 3918, ~: 3942) +LibDecimalFloatEqTest:testEqXNotYExponents(int256,int256,int256,int256) (runs: 5101, μ: 4223, ~: 4299) +LibDecimalFloatEqTest:testEqZero(int256,int256) (runs: 5101, μ: 3432, ~: 3432) +LibDecimalFloatFloorTest:testFloorExamples() (gas: 27720) +LibDecimalFloatFloorTest:testFloorGas0() (gas: 475) +LibDecimalFloatFloorTest:testFloorGasTiny() (gas: 384) +LibDecimalFloatFloorTest:testFloorGasZero() (gas: 378) +LibDecimalFloatFloorTest:testFloorInRange(int256,int256) (runs: 5101, μ: 10082, ~: 10094) +LibDecimalFloatFloorTest:testFloorLessThanMin(int256,int256) (runs: 5101, μ: 9311, ~: 9486) +LibDecimalFloatFloorTest:testFloorNonNegative(int256,int256) (runs: 5101, μ: 8751, ~: 8530) +LibDecimalFloatFloorTest:testFloorNotReverts(int256,int256) (runs: 5101, μ: 472, ~: 461) +LibDecimalFloatFracTest:testFracExamples() (gas: 27680) +LibDecimalFloatFracTest:testFracGas0() (gas: 498) +LibDecimalFloatFracTest:testFracGasTiny() (gas: 407) +LibDecimalFloatFracTest:testFracGasZero() (gas: 389) +LibDecimalFloatFracTest:testFracInRange(int256,int256) (runs: 5101, μ: 9925, ~: 9937) +LibDecimalFloatFracTest:testFracLessThanMin(int256,int256) (runs: 5101, μ: 9268, ~: 9443) +LibDecimalFloatFracTest:testFracNonNegative(int256,int256) (runs: 5101, μ: 8729, ~: 8508) +LibDecimalFloatFracTest:testFracNotReverts(int256,int256) (runs: 5101, μ: 451, ~: 440) +LibDecimalFloatGtTest:testGtGasAZero() (gas: 424) +LibDecimalFloatGtTest:testGtGasBZero() (gas: 423) +LibDecimalFloatGtTest:testGtGasBothZero() (gas: 447) +LibDecimalFloatGtTest:testGtGasDifferentSigns() (gas: 425) +LibDecimalFloatGtTest:testGtGasExponentDiffOverflow() (gas: 572) +LibDecimalFloatGtTest:testGtOneEAny(int256,int256) (runs: 5101, μ: 3437, ~: 3437) +LibDecimalFloatGtTest:testGtReference(int256,int256,int256,int256) (runs: 5101, μ: 9893, ~: 11517) +LibDecimalFloatGtTest:testGtX(int256) (runs: 5101, μ: 3409, ~: 3409) +LibDecimalFloatGtTest:testGtXEAnyVsXEAny(int256,int256,int256) (runs: 5101, μ: 9284, ~: 9054) +LibDecimalFloatGtTest:testGtXEAnyVsXEAnyNegative(int256,int256,int256) (runs: 5101, μ: 9768, ~: 9961) +LibDecimalFloatGtTest:testGtXNotY(int256,int256,int256,int256) (runs: 5101, μ: 4189, ~: 4264) +LibDecimalFloatGtTest:testGtXPositiveYNegative(int256,int256,int256,int256) (runs: 5101, μ: 11904, ~: 11865) +LibDecimalFloatGtTest:testGtXPositiveYZero(int256,int256,int256) (runs: 5101, μ: 9010, ~: 8783) +LibDecimalFloatGtTest:testGtZero(int256,int256) (runs: 5101, μ: 3457, ~: 3457) +LibDecimalFloatImplementationNormalizeTest:testExamples() (gas: 158985) +LibDecimalFloatImplementationNormalizeTest:testIsNormalizedReference(int256,int256) (runs: 5101, μ: 3516, ~: 3522) +LibDecimalFloatImplementationNormalizeTest:testNormalized(int256,int256) (runs: 5101, μ: 9148, ~: 8984) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentExamples() (gas: 12292) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentLargerExponentOverflowRescaleRevert(int256,int256,int256) (runs: 5096, μ: 12560, ~: 12463) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentLargerExponentVeryLargeDiffRevert(int256,int256,int256) (runs: 5101, μ: 11365, ~: 11301) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentLargerTargetExponentNoRevert(int256,int256,int256) (runs: 5101, μ: 10778, ~: 10966) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentSameExponentNoop(int256,int256) (runs: 5101, μ: 3562, ~: 3562) +LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentSmallerExponentNoRevert(int256,int256,int256) (runs: 5101, μ: 12976, ~: 12871) +LibDecimalFloatInvTest:testInvGas0() (gas: 726) +LibDecimalFloatInvTest:testInvReference(int256,int256) (runs: 5101, μ: 11731, ~: 11601) +LibDecimalFloatInvTest:testInvSlowGas0() (gas: 748) +LibDecimalFloatLog10Test:testExactLogs() (gas: 1225111) +LibDecimalFloatLog10Test:testExactLookups() (gas: 1241752) +LibDecimalFloatLog10Test:testInterpolatedLookups() (gas: 1219121) +LibDecimalFloatLog10Test:testSub1() (gas: 1216659) +LibDecimalFloatLtTest:testLtGasAZero() (gas: 445) +LibDecimalFloatLtTest:testLtGasBZero() (gas: 467) +LibDecimalFloatLtTest:testLtGasBothZero() (gas: 446) +LibDecimalFloatLtTest:testLtGasDifferentSigns() (gas: 468) +LibDecimalFloatLtTest:testLtGasExponentDiffOverflow() (gas: 529) +LibDecimalFloatLtTest:testLtNegativeVsPositive(int256,int256,int256,int256) (runs: 5101, μ: 11886, ~: 11844) +LibDecimalFloatLtTest:testLtNegativeVsZero(int256,int256,int256) (runs: 5101, μ: 9475, ~: 9671) +LibDecimalFloatLtTest:testLtOneEAny(int256,int256) (runs: 5101, μ: 3459, ~: 3459) +LibDecimalFloatLtTest:testLtReference(int256,int256,int256,int256) (runs: 5101, μ: 9887, ~: 11440) +LibDecimalFloatLtTest:testLtVsEqualVsGt(int256,int256,int256,int256) (runs: 5101, μ: 4238, ~: 4310) +LibDecimalFloatLtTest:testLtX(int256) (runs: 5101, μ: 3430, ~: 3430) +LibDecimalFloatLtTest:testLtXEAnyVsXEAny(int256,int256,int256) (runs: 5101, μ: 9305, ~: 9076) +LibDecimalFloatLtTest:testLtXEAnyVsXEAnyNegative(int256,int256,int256) (runs: 5101, μ: 9746, ~: 9939) +LibDecimalFloatLtTest:testLtZero(int256,int256) (runs: 5101, μ: 3434, ~: 3434) +LibDecimalFloatMixedTest:testDivide1Over3() (gas: 6557) +LibDecimalFloatMultiplyTest:testMultiply123456789987654321() (gas: 3712) +LibDecimalFloatMultiplyTest:testMultiply123456789987654321WithExponents(int128,int128) (runs: 5101, μ: 12502, ~: 12589) +LibDecimalFloatMultiplyTest:testMultiply1e181e19() (gas: 3716) +LibDecimalFloatMultiplyTest:testMultiplyGasOne() (gas: 379) +LibDecimalFloatMultiplyTest:testMultiplyGasZero() (gas: 342) +LibDecimalFloatMultiplyTest:testMultiplyNotRevertAnyExpectation(int256,int256,int256,int256) (runs: 5101, μ: 12879, ~: 12291) +LibDecimalFloatMultiplyTest:testMultiplyOneOne() (gas: 3689) +LibDecimalFloatMultiplyTest:testMultiplyOneZero() (gas: 3653) +LibDecimalFloatMultiplyTest:testMultiplyZero0Exponent() (gas: 3609) +LibDecimalFloatMultiplyTest:testMultiplyZeroAnyExponent(int64,int64) (runs: 5101, μ: 3896, ~: 3896) +LibDecimalFloatMultiplyTest:testMultiplyZeroOne() (gas: 3610) +LibDecimalFloatPackTest:testNormalizedRoundTrip(int256,int256) (runs: 5101, μ: 10216, ~: 10053) +LibDecimalFloatPackTest:testPartsRoundTrip(int128,int128) (runs: 5101, μ: 4493, ~: 4493) +LibDecimalFloatPower10Test:testExactLookups() (gas: 1253736) +LibDecimalFloatPower10Test:testExactPowers() (gas: 1228102) +LibDecimalFloatPower10Test:testInterpolatedLookupsPower() (gas: 1229822) +LibDecimalFloatPower10Test:testNoRevert(int256,int256) (runs: 5101, μ: 1218020, ~: 1218943) +LibDecimalFloatPowerTest:testPowers() (gas: 1223912) +LibDecimalFloatPowerTest:testRoundTrip() (gas: 1348368) +LibDecimalFloatSubTest:testMinusIsSubZero(int256,int256,int256) (runs: 5101, μ: 12441, ~: 12478) +LibDecimalFloatSubTest:testSubIsAdd(int256,int256,int256,int256) (runs: 5101, μ: 15474, ~: 15377) +LibDecimalFloatSubTest:testSubMinSignedValue(int256,int256,int256) (runs: 5101, μ: 15716, ~: 15619) +LibLogTableBytesTest:testToBytesAntiLogTableDec() (gas: 153225) +LibLogTableBytesTest:testToBytesAntiLogTableDecSmall() (gas: 158036) +LibLogTableBytesTest:testToBytesLogTableDec() (gas: 137284) +LibLogTableBytesTest:testToBytesLogTableDecSmall() (gas: 141767) +LibLogTableBytesTest:testToBytesLogTableDecSmallAlt() (gas: 18049) \ No newline at end of file diff --git a/test/src/lib/implementation/LibDecimalFloatImplementation.normalize.t.sol b/test/src/lib/implementation/LibDecimalFloatImplementation.normalize.t.sol index dd5f993..c7ac754 100644 --- a/test/src/lib/implementation/LibDecimalFloatImplementation.normalize.t.sol +++ b/test/src/lib/implementation/LibDecimalFloatImplementation.normalize.t.sol @@ -8,7 +8,7 @@ import { EXPONENT_MIN, EXPONENT_MAX } from "src/lib/implementation/LibDecimalFloatImplementation.sol"; -import {LibDecimalFloatImplementationSlow} from "../../lib/implementation/LibDecimalFloatImplementationSlow.sol"; +import {LibDecimalFloatImplementationSlow} from "../../../lib/implementation/LibDecimalFloatImplementationSlow.sol"; contract LibDecimalFloatImplementationNormalizeTest is Test { /// isNormalized reference.