From 59cc3e20c4f56c72d67beb7b6696406f2a8e5207 Mon Sep 17 00:00:00 2001 From: Diana Kocsis Date: Wed, 24 Apr 2024 13:15:26 -0400 Subject: [PATCH 1/2] change test file name --- test/libraries/SwapFeeLibrary.t.sol | 81 ----------------------------- 1 file changed, 81 deletions(-) delete mode 100644 test/libraries/SwapFeeLibrary.t.sol diff --git a/test/libraries/SwapFeeLibrary.t.sol b/test/libraries/SwapFeeLibrary.t.sol deleted file mode 100644 index 67eca377c..000000000 --- a/test/libraries/SwapFeeLibrary.t.sol +++ /dev/null @@ -1,81 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; - -import "src/libraries/LPFeeLibrary.sol"; -import "forge-std/Test.sol"; - -contract LPFeeLibraryTest is Test { - function test_isDynamicFee_returnsTrue() public { - uint24 dynamicFee = 0x800000; - assertTrue(LPFeeLibrary.isDynamicFee(dynamicFee)); - } - - function test_isDynamicFee_returnsTrue_forMaxValue() public { - uint24 dynamicFee = 0xFFFFFF; - assertTrue(LPFeeLibrary.isDynamicFee(dynamicFee)); - } - - function test_isDynamicFee_returnsFalse() public { - uint24 dynamicFee = 0x7FFFFF; - assertFalse(LPFeeLibrary.isDynamicFee(dynamicFee)); - } - - function test_fuzz_isDynamicFee(uint24 fee) public { - assertEq((fee >> 23 == 1), LPFeeLibrary.isDynamicFee(fee)); - } - - function test_validate_doesNotRevertWithNoFee() public pure { - uint24 fee = 0; - LPFeeLibrary.validate(fee); - } - - function test_validate_doesNotRevert() public pure { - uint24 fee = 500000; // 50% - LPFeeLibrary.validate(fee); - } - - function test_validate_doesNotRevertWithMaxFee() public pure { - uint24 maxFee = 1000000; // 100% - LPFeeLibrary.validate(maxFee); - } - - function test_validate_revertsWithFeeTooLarge() public { - uint24 fee = 1000001; - vm.expectRevert(LPFeeLibrary.FeeTooLarge.selector); - LPFeeLibrary.validate(fee); - } - - function test_fuzz_validate(uint24 fee) public { - if (fee > 1000000) { - vm.expectRevert(LPFeeLibrary.FeeTooLarge.selector); - } - LPFeeLibrary.validate(fee); - } - - function test_getInitialLPFee_forStaticFeeIsCorrect() public { - uint24 staticFee = 3000; // 30 bps - assertEq(LPFeeLibrary.getInitialLPFee(staticFee), staticFee); - } - - function test_getInitialLPFee_revertsWithFeeTooLarge_forStaticFee() public { - uint24 staticFee = 1000001; - vm.expectRevert(LPFeeLibrary.FeeTooLarge.selector); - LPFeeLibrary.getInitialLPFee(staticFee); - } - - function test_getInitialLPFee_forDynamicFeeIsZero() public { - uint24 dynamicFee = 0x800BB8; - assertEq(LPFeeLibrary.getInitialLPFee(dynamicFee), 0); - } - - function test_fuzz_getInitialLPFee(uint24 fee) public { - if (fee >> 23 == 1) { - assertEq(LPFeeLibrary.getInitialLPFee(fee), 0); - } else if (fee > 1000000) { - vm.expectRevert(LPFeeLibrary.FeeTooLarge.selector); - LPFeeLibrary.getInitialLPFee(fee); - } else { - assertEq(LPFeeLibrary.getInitialLPFee(fee), fee); - } - } -} From 8e0fcb48932787c7071f7ead16053a1896478c7b Mon Sep 17 00:00:00 2001 From: Diana Kocsis Date: Wed, 24 Apr 2024 13:34:21 -0400 Subject: [PATCH 2/2] change name to lpfeelibrary.t.sol --- test/libraries/LPFeeLibrary.t.sol | 81 +++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 test/libraries/LPFeeLibrary.t.sol diff --git a/test/libraries/LPFeeLibrary.t.sol b/test/libraries/LPFeeLibrary.t.sol new file mode 100644 index 000000000..d29aa9584 --- /dev/null +++ b/test/libraries/LPFeeLibrary.t.sol @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.20; + +import "../../src/libraries/LPFeeLibrary.sol"; +import "forge-std/Test.sol"; + +contract LPFeeLibraryTest is Test { + function test_isDynamicFee_returnsTrue() public { + uint24 dynamicFee = 0x800000; + assertTrue(LPFeeLibrary.isDynamicFee(dynamicFee)); + } + + function test_isDynamicFee_returnsTrue_forMaxValue() public { + uint24 dynamicFee = 0xFFFFFF; + assertTrue(LPFeeLibrary.isDynamicFee(dynamicFee)); + } + + function test_isDynamicFee_returnsFalse() public { + uint24 dynamicFee = 0x7FFFFF; + assertFalse(LPFeeLibrary.isDynamicFee(dynamicFee)); + } + + function test_fuzz_isDynamicFee(uint24 fee) public { + assertEq((fee >> 23 == 1), LPFeeLibrary.isDynamicFee(fee)); + } + + function test_validate_doesNotRevertWithNoFee() public pure { + uint24 fee = 0; + LPFeeLibrary.validate(fee); + } + + function test_validate_doesNotRevert() public pure { + uint24 fee = 500000; // 50% + LPFeeLibrary.validate(fee); + } + + function test_validate_doesNotRevertWithMaxFee() public pure { + uint24 maxFee = 1000000; // 100% + LPFeeLibrary.validate(maxFee); + } + + function test_validate_revertsWithFeeTooLarge() public { + uint24 fee = 1000001; + vm.expectRevert(LPFeeLibrary.FeeTooLarge.selector); + LPFeeLibrary.validate(fee); + } + + function test_fuzz_validate(uint24 fee) public { + if (fee > 1000000) { + vm.expectRevert(LPFeeLibrary.FeeTooLarge.selector); + } + LPFeeLibrary.validate(fee); + } + + function test_getInitialLPFee_forStaticFeeIsCorrect() public { + uint24 staticFee = 3000; // 30 bps + assertEq(LPFeeLibrary.getInitialLPFee(staticFee), staticFee); + } + + function test_getInitialLPFee_revertsWithFeeTooLarge_forStaticFee() public { + uint24 staticFee = 1000001; + vm.expectRevert(LPFeeLibrary.FeeTooLarge.selector); + LPFeeLibrary.getInitialLPFee(staticFee); + } + + function test_getInitialLPFee_forDynamicFeeIsZero() public { + uint24 dynamicFee = 0x800BB8; + assertEq(LPFeeLibrary.getInitialLPFee(dynamicFee), 0); + } + + function test_fuzz_getInitialLPFee(uint24 fee) public { + if (fee >> 23 == 1) { + assertEq(LPFeeLibrary.getInitialLPFee(fee), 0); + } else if (fee > 1000000) { + vm.expectRevert(LPFeeLibrary.FeeTooLarge.selector); + LPFeeLibrary.getInitialLPFee(fee); + } else { + assertEq(LPFeeLibrary.getInitialLPFee(fee), fee); + } + } +}