From e69a40c77899017db9a8a37ca341d6e5051437b3 Mon Sep 17 00:00:00 2001 From: Michalis Kargakis Date: Wed, 30 Oct 2024 12:28:10 +0100 Subject: [PATCH] Revert "[LILA-7980] Do not throw on zero fee returned" --- src/FeeCalculator.sol | 6 ++--- src/FlatFeeCalculator.sol | 6 ++--- .../FeeCalculator/AbstractFeeCalculator.t.sol | 16 +++++------- .../AbstractFeeCalculator.fuzzy.t.sol | 8 +++--- .../FeeCalculatorERC1155.fuzzy.t.sol | 25 +++++++++++-------- .../FeeCalculatorTCO2.fuzzy.t.sol | 25 +++++++++++-------- .../AbstractFeeCalculatorLaunchParams.t.sol | 16 +++++------- ...tractFeeCalculatorLaunchParams.fuzzy.t.sol | 8 +++--- ...eCalculatorLaunchParamsERC1155.fuzzy.t.sol | 15 ++++++----- .../FeeCalculatorLaunchParamsTCO2.fuzzy.t.sol | 15 ++++++----- .../FlatFeeCalculator.fuzzy.t.sol | 7 +++--- 11 files changed, 73 insertions(+), 74 deletions(-) diff --git a/src/FeeCalculator.sol b/src/FeeCalculator.sol index 2e4c309..9768a61 100644 --- a/src/FeeCalculator.sol +++ b/src/FeeCalculator.sol @@ -20,7 +20,7 @@ contract FeeCalculator is IFeeCalculator, Ownable { /// @dev Version-related parameters. VERSION keeps track of production /// releases. VERSION_RELEASE_CANDIDATE keeps track of iterations /// of a VERSION in our staging environment. - string public constant VERSION = "1.2.0"; + string public constant VERSION = "1.1.0"; uint256 public constant VERSION_RELEASE_CANDIDATE = 1; SD59x18 private _zero = sd(0); @@ -406,9 +406,7 @@ contract FeeCalculator is IFeeCalculator, Ownable { uint256 feeAmount = calculator(requestedAmount, projectSupply, totalPoolSupply); require(feeAmount <= requestedAmount, "Fee must be lower or equal to requested amount"); - if (feeAmount == 0) { - return FeeDistribution(new address[](0), new uint256[](0)); - } + require(feeAmount != 0, "Fee must be greater than 0"); return calculateFeeShares(feeAmount); } diff --git a/src/FlatFeeCalculator.sol b/src/FlatFeeCalculator.sol index 214b08a..4f40df7 100644 --- a/src/FlatFeeCalculator.sol +++ b/src/FlatFeeCalculator.sol @@ -19,7 +19,7 @@ contract FlatFeeCalculator is IFeeCalculator, Ownable { /// @dev Version-related parameters. VERSION keeps track of production /// releases. VERSION_RELEASE_CANDIDATE keeps track of iterations /// of a VERSION in our staging environment. - string public constant VERSION = "1.1.0"; + string public constant VERSION = "1.0.0"; uint256 public constant VERSION_RELEASE_CANDIDATE = 2; uint256 public feeBasisPoints = 300; @@ -158,9 +158,7 @@ contract FlatFeeCalculator is IFeeCalculator, Ownable { require(requestedAmount != 0, "requested amount must be > 0"); uint256 feeAmount = requestedAmount * feeBasisPoints / 10000; - if (feeAmount == 0) { - return FeeDistribution(new address[](0), new uint256[](0)); - } + require(feeAmount != 0, "Fee must be greater than 0"); return calculateFeeShares(feeAmount); } diff --git a/test/FeeCalculator/AbstractFeeCalculator.t.sol b/test/FeeCalculator/AbstractFeeCalculator.t.sol index c4b5411..53f55de 100644 --- a/test/FeeCalculator/AbstractFeeCalculator.t.sol +++ b/test/FeeCalculator/AbstractFeeCalculator.t.sol @@ -254,7 +254,7 @@ abstract contract AbstractFeeCalculatorTest is Test { assertEq(fees[0], 46413457506542766270); } - function testCalculateDepositFees_DepositOfOneWei_ShouldNotThrowException() public { + function testCalculateDepositFees_DepositOfOneWei_ShouldThrowException() public { // Arrange // Set up your test data uint256 depositAmount = 1; @@ -264,13 +264,11 @@ abstract contract AbstractFeeCalculatorTest is Test { setProjectSupply(address(mockToken), 1e4 * 1e18); // Act - FeeDistribution memory feeDistribution = - calculateDepositFees(address(mockPool), address(mockToken), depositAmount); - assertEq(feeDistribution.recipients.length, 0); - assertEq(feeDistribution.shares.length, 0); + vm.expectRevert("Fee must be greater than 0"); + calculateDepositFees(address(mockPool), address(mockToken), depositAmount); } - function testCalculateDepositFees_DepositOfHundredWei_ShouldNotThrowError() public { + function testCalculateDepositFees_DepositOfHundredWei_ShouldThrowError() public { //Note! This is a bug, where a very small deposit to a very large pool //causes a == b because of precision limited by ratioDenominator in FeeCalculator @@ -283,10 +281,8 @@ abstract contract AbstractFeeCalculatorTest is Test { setProjectSupply(address(mockToken), 1e4 * 1e18); // Act - FeeDistribution memory feeDistribution = - calculateDepositFees(address(mockPool), address(mockToken), depositAmount); - assertEq(feeDistribution.recipients.length, 0); - assertEq(feeDistribution.shares.length, 0); + vm.expectRevert("Fee must be greater than 0"); + calculateDepositFees(address(mockPool), address(mockToken), depositAmount); } function testCalculateDepositFees_DepositOfHundredThousandsPartOfOne_NonzeroFee() public { diff --git a/test/FeeCalculatorFuzzy/AbstractFeeCalculator.fuzzy.t.sol b/test/FeeCalculatorFuzzy/AbstractFeeCalculator.fuzzy.t.sol index d329989..bdf7cc2 100644 --- a/test/FeeCalculatorFuzzy/AbstractFeeCalculator.fuzzy.t.sol +++ b/test/FeeCalculatorFuzzy/AbstractFeeCalculator.fuzzy.t.sol @@ -50,7 +50,7 @@ abstract contract AbstractFeeCalculatorTestFuzzy is Test { uint256 total ) public virtual; - function testCalculateDepositFees_FuzzyExtremelySmallDepositsToLargePool_ShouldNotThrowError(uint256 depositAmount) + function testCalculateDepositFees_FuzzyExtremelySmallDepositsToLargePool_ShouldThrowError(uint256 depositAmount) public { vm.assume(depositAmount <= 1e-14 * 1e18); @@ -66,10 +66,8 @@ abstract contract AbstractFeeCalculatorTestFuzzy is Test { mockPool.setTotalSupply(1e12 * 1e18); setProjectSupply(address(mockToken), 1e9 * 1e18); - FeeDistribution memory feeDistribution = - calculateDepositFees(address(mockPool), address(mockToken), depositAmount); - assertEq(feeDistribution.recipients.length, 0); - assertEq(feeDistribution.shares.length, 0); + vm.expectRevert("Fee must be greater than 0"); + calculateDepositFees(address(mockPool), address(mockToken), depositAmount); } function testCalculateRedemptionFeesFuzzy_RedemptionDividedIntoOneChunkFeesGreaterOrEqualToOneRedemption( diff --git a/test/FeeCalculatorFuzzy/FeeCalculatorERC1155.fuzzy.t.sol b/test/FeeCalculatorFuzzy/FeeCalculatorERC1155.fuzzy.t.sol index 5ab1613..096cba7 100644 --- a/test/FeeCalculatorFuzzy/FeeCalculatorERC1155.fuzzy.t.sol +++ b/test/FeeCalculatorFuzzy/FeeCalculatorERC1155.fuzzy.t.sol @@ -43,8 +43,9 @@ contract FeeCalculatorERC1155TestFuzzy is AbstractFeeCalculatorTestFuzzy { try feeCalculator.calculateDepositFees(address(mockPool), address(mockToken), 1, depositAmount) {} catch Error(string memory reason) { assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount'" + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount'" ); } } @@ -94,8 +95,9 @@ contract FeeCalculatorERC1155TestFuzzy is AbstractFeeCalculatorTestFuzzy { } catch Error(string memory reason) { oneTimeRedemptionFailed = true; assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount'" + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount'" ); } @@ -123,8 +125,9 @@ contract FeeCalculatorERC1155TestFuzzy is AbstractFeeCalculatorTestFuzzy { } catch Error(string memory reason) { multipleTimesRedemptionFailedCount++; assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount'" + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount'" ); } } @@ -165,8 +168,9 @@ contract FeeCalculatorERC1155TestFuzzy is AbstractFeeCalculatorTestFuzzy { } catch Error(string memory reason) { oneTimeDepositFailed = true; assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount'" + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount'" ); } @@ -188,8 +192,9 @@ contract FeeCalculatorERC1155TestFuzzy is AbstractFeeCalculatorTestFuzzy { } catch Error(string memory reason) { multipleTimesDepositFailedCount++; assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount'" + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount'" ); } } diff --git a/test/FeeCalculatorFuzzy/FeeCalculatorTCO2.fuzzy.t.sol b/test/FeeCalculatorFuzzy/FeeCalculatorTCO2.fuzzy.t.sol index 4c016e5..ddaa5f3 100644 --- a/test/FeeCalculatorFuzzy/FeeCalculatorTCO2.fuzzy.t.sol +++ b/test/FeeCalculatorFuzzy/FeeCalculatorTCO2.fuzzy.t.sol @@ -40,8 +40,9 @@ contract FeeCalculatorTCO2TestFuzzy is AbstractFeeCalculatorTestFuzzy { try feeCalculator.calculateDepositFees(address(mockPool), address(mockToken), depositAmount) {} catch Error(string memory reason) { assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount'" + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount'" ); } } @@ -89,8 +90,9 @@ contract FeeCalculatorTCO2TestFuzzy is AbstractFeeCalculatorTestFuzzy { } catch Error(string memory reason) { oneTimeRedemptionFailed = true; assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount'" + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount'" ); } @@ -118,8 +120,9 @@ contract FeeCalculatorTCO2TestFuzzy is AbstractFeeCalculatorTestFuzzy { } catch Error(string memory reason) { multipleTimesRedemptionFailedCount++; assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount'" + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount'" ); } } @@ -160,8 +163,9 @@ contract FeeCalculatorTCO2TestFuzzy is AbstractFeeCalculatorTestFuzzy { } catch Error(string memory reason) { oneTimeDepositFailed = true; assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount'" + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount'" ); } @@ -183,8 +187,9 @@ contract FeeCalculatorTCO2TestFuzzy is AbstractFeeCalculatorTestFuzzy { } catch Error(string memory reason) { multipleTimesDepositFailedCount++; assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount'" + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)), + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount'" ); } } diff --git a/test/FeeCalculatorLaunchParams/AbstractFeeCalculatorLaunchParams.t.sol b/test/FeeCalculatorLaunchParams/AbstractFeeCalculatorLaunchParams.t.sol index 437dee6..6215b02 100644 --- a/test/FeeCalculatorLaunchParams/AbstractFeeCalculatorLaunchParams.t.sol +++ b/test/FeeCalculatorLaunchParams/AbstractFeeCalculatorLaunchParams.t.sol @@ -147,7 +147,7 @@ abstract contract AbstractFeeCalculatorLaunchParamsTest is Test { assertEq(fees[0], 53013879215838797358); } - function testCalculateDepositFees_DepositOfOneWei_ShouldNotThrowException() public { + function testCalculateDepositFees_DepositOfOneWei_ShouldThrowException() public { // Arrange // Set up your test data uint256 depositAmount = 1; @@ -157,13 +157,11 @@ abstract contract AbstractFeeCalculatorLaunchParamsTest is Test { setProjectSupply(address(mockToken), 1e4 * 1e18); // Act - FeeDistribution memory feeDistribution = - calculateDepositFees(address(mockPool), address(mockToken), depositAmount); - assertEq(feeDistribution.recipients.length, 0); - assertEq(feeDistribution.shares.length, 0); + vm.expectRevert("Fee must be greater than 0"); + calculateDepositFees(address(mockPool), address(mockToken), depositAmount); } - function testCalculateDepositFees_DepositOfHundredWei_ShouldNotThrowError() public { + function testCalculateDepositFees_DepositOfHundredWei_ShouldThrowError() public { //Note! This is a bug, where a very small deposit to a very large pool //causes a == b because of precision limited by ratioDenominator in FeeCalculator @@ -176,10 +174,8 @@ abstract contract AbstractFeeCalculatorLaunchParamsTest is Test { setProjectSupply(address(mockToken), 1e4 * 1e18); // Act - FeeDistribution memory feeDistribution = - calculateDepositFees(address(mockPool), address(mockToken), depositAmount); - assertEq(feeDistribution.recipients.length, 0); - assertEq(feeDistribution.shares.length, 0); + vm.expectRevert("Fee must be greater than 0"); + calculateDepositFees(address(mockPool), address(mockToken), depositAmount); } function testCalculateDepositFees_DepositOfHundredThousandsPartOfOne_NonzeroFee() public { diff --git a/test/FeeCalculatorLaunchParamsFuzzy/AbstractFeeCalculatorLaunchParams.fuzzy.t.sol b/test/FeeCalculatorLaunchParamsFuzzy/AbstractFeeCalculatorLaunchParams.fuzzy.t.sol index e63e708..9d91852 100644 --- a/test/FeeCalculatorLaunchParamsFuzzy/AbstractFeeCalculatorLaunchParams.fuzzy.t.sol +++ b/test/FeeCalculatorLaunchParamsFuzzy/AbstractFeeCalculatorLaunchParams.fuzzy.t.sol @@ -47,7 +47,7 @@ abstract contract AbstractFeeCalculatorLaunchParamsTestFuzzy is Test { uint256 total ) public virtual; - function testCalculateDepositFees_FuzzyExtremelySmallDepositsToLargePool_ShouldNotThrowError(uint256 depositAmount) + function testCalculateDepositFees_FuzzyExtremelySmallDepositsToLargePool_ShouldThrowError(uint256 depositAmount) public { vm.assume(depositAmount <= 1e-14 * 1e18); @@ -63,10 +63,8 @@ abstract contract AbstractFeeCalculatorLaunchParamsTestFuzzy is Test { mockPool.setTotalSupply(1e12 * 1e18); setProjectSupply(address(mockToken), 1e9 * 1e18); - FeeDistribution memory feeDistribution = - calculateDepositFees(address(mockPool), address(mockToken), depositAmount); - assertEq(feeDistribution.recipients.length, 0); - assertEq(feeDistribution.shares.length, 0); + vm.expectRevert("Fee must be greater than 0"); + calculateDepositFees(address(mockPool), address(mockToken), depositAmount); } function testCalculateDepositFeesFuzzy_DepositDividedIntoOneChunkFeesGreaterOrEqualToOneDeposit( diff --git a/test/FeeCalculatorLaunchParamsFuzzy/FeeCalculatorLaunchParamsERC1155.fuzzy.t.sol b/test/FeeCalculatorLaunchParamsFuzzy/FeeCalculatorLaunchParamsERC1155.fuzzy.t.sol index 8a142f5..563fdb9 100644 --- a/test/FeeCalculatorLaunchParamsFuzzy/FeeCalculatorLaunchParamsERC1155.fuzzy.t.sol +++ b/test/FeeCalculatorLaunchParamsFuzzy/FeeCalculatorLaunchParamsERC1155.fuzzy.t.sol @@ -40,9 +40,10 @@ contract FeeCalculatorLaunchParamsERC1155TestFuzzy is AbstractFeeCalculatorLaunc try feeCalculator.calculateDepositFees(address(mockPool), address(mockToken), 1, depositAmount) {} catch Error(string memory reason) { assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)) + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)) || keccak256(bytes("Deposit outside range")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount' or 'Deposit outside range'" + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount' or 'Deposit outside range'" ); } } @@ -79,9 +80,10 @@ contract FeeCalculatorLaunchParamsERC1155TestFuzzy is AbstractFeeCalculatorLaunc } catch Error(string memory reason) { oneTimeDepositFailed = true; assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)) + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)) || keccak256(bytes("Deposit outside range")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount' or 'Deposit outside range'" + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount' or 'Deposit outside range'" ); } @@ -103,9 +105,10 @@ contract FeeCalculatorLaunchParamsERC1155TestFuzzy is AbstractFeeCalculatorLaunc } catch Error(string memory reason) { multipleTimesDepositFailedCount++; assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)) + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)) || keccak256(bytes("Deposit outside range")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount' or 'Deposit outside range'" + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount' or 'Deposit outside range'" ); } } diff --git a/test/FeeCalculatorLaunchParamsFuzzy/FeeCalculatorLaunchParamsTCO2.fuzzy.t.sol b/test/FeeCalculatorLaunchParamsFuzzy/FeeCalculatorLaunchParamsTCO2.fuzzy.t.sol index 526d7a1..70b93de 100644 --- a/test/FeeCalculatorLaunchParamsFuzzy/FeeCalculatorLaunchParamsTCO2.fuzzy.t.sol +++ b/test/FeeCalculatorLaunchParamsFuzzy/FeeCalculatorLaunchParamsTCO2.fuzzy.t.sol @@ -40,9 +40,10 @@ contract FeeCalculatorLaunchParamsTCO2TestFuzzy is AbstractFeeCalculatorLaunchPa try feeCalculator.calculateDepositFees(address(mockPool), address(mockToken), depositAmount) {} catch Error(string memory reason) { assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)) + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)) || keccak256(bytes("Deposit outside range")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount' or 'Deposit outside range'" + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount' or 'Deposit outside range'" ); } } @@ -79,9 +80,10 @@ contract FeeCalculatorLaunchParamsTCO2TestFuzzy is AbstractFeeCalculatorLaunchPa } catch Error(string memory reason) { oneTimeDepositFailed = true; assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)) + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)) || keccak256(bytes("Deposit outside range")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount' or 'Deposit outside range'" + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount' or 'Deposit outside range'" ); } @@ -103,9 +105,10 @@ contract FeeCalculatorLaunchParamsTCO2TestFuzzy is AbstractFeeCalculatorLaunchPa } catch Error(string memory reason) { multipleTimesDepositFailedCount++; assertTrue( - keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)) + keccak256(bytes("Fee must be greater than 0")) == keccak256(bytes(reason)) + || keccak256(bytes("Fee must be lower or equal to requested amount")) == keccak256(bytes(reason)) || keccak256(bytes("Deposit outside range")) == keccak256(bytes(reason)), - "error should be 'Fee must be lower or equal to requested amount' or 'Deposit outside range'" + "error should be 'Fee must be greater than 0' or 'Fee must be lower or equal to requested amount' or 'Deposit outside range'" ); } } diff --git a/test/FlatFeeCalculatorFuzzy/FlatFeeCalculator.fuzzy.t.sol b/test/FlatFeeCalculatorFuzzy/FlatFeeCalculator.fuzzy.t.sol index 19693d7..7b2c7a5 100644 --- a/test/FlatFeeCalculatorFuzzy/FlatFeeCalculator.fuzzy.t.sol +++ b/test/FlatFeeCalculatorFuzzy/FlatFeeCalculator.fuzzy.t.sol @@ -129,15 +129,14 @@ contract FlatFeeCalculatorTestFuzzy is Test { assertEq(fees[0], expected); } - function testCalculateRedemptionFeesDustAmount_ShouldNotThrow() public { + function testCalculateRedemptionFeesDustAmount_ShouldThrow() public { // Arrange // Set up your test data uint256 depositAmount = 1; // Act - FeeDistribution memory feeDistribution = feeCalculator.calculateDepositFees(empty, empty, depositAmount); - assertEq(feeDistribution.recipients.length, 0); - assertEq(feeDistribution.shares.length, 0); + vm.expectRevert("Fee must be greater than 0"); + feeCalculator.calculateDepositFees(empty, empty, depositAmount); } function testCalculateDepositFee_TCO2(uint256 depositAmount) public {