From ad1993ce40fccb9eff6e37caa47b7333077157cc Mon Sep 17 00:00:00 2001 From: Andrew Redden Date: Sun, 5 Nov 2023 10:04:01 -0400 Subject: [PATCH] increase uint types to ensure we can better check for edge cases on interest --- test/fuzz-testing/TestFuzzOrigination.sol | 12 +++++++----- test/utils/Bound.sol | 8 ++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/test/fuzz-testing/TestFuzzOrigination.sol b/test/fuzz-testing/TestFuzzOrigination.sol index e84e54eb..ef265b4d 100644 --- a/test/fuzz-testing/TestFuzzOrigination.sol +++ b/test/fuzz-testing/TestFuzzOrigination.sol @@ -95,7 +95,7 @@ contract TestFuzzOrigination is StarportTest, Bound { debt[0] = SpentItem({ itemType: ItemType.ERC20, identifier: 0, - amount: _boundMin(1, type(uint64).max), + amount: _boundMin(1, type(uint128).max), token: address(erc20s[0]) }); loan.debt = debt; @@ -105,20 +105,22 @@ contract TestFuzzOrigination is StarportTest, Bound { return loan; } - function willArithmeticOverflow(Starport.Loan memory loan) internal view { + function willArithmeticOverflow(Starport.Loan memory loan) internal view returns (bool) { FixedTermStatus.Details memory statusDetails = abi.decode(loan.terms.statusData, (FixedTermStatus.Details)); BasePricing.Details memory pricingDetails = abi.decode(loan.terms.pricingData, (BasePricing.Details)); try BasePricing(loan.terms.pricing).getPaymentConsideration(loan) returns ( SpentItem[] memory repayConsideration, SpentItem[] memory carryConsideration - ) {} catch { - revert("arithmetic overflow"); + ) { + return false; + } catch { + return true; } } function testFuzzNewOrigination(FuzzLoan memory params) public { vm.assume(params.collateral.length > 1); Starport.Loan memory loan = boundFuzzLoan(params); - willArithmeticOverflow(loan); + vm.assume(!willArithmeticOverflow(loan)); _issueAndApproveTarget(loan.collateral, loan.borrower, address(SP)); _issueAndApproveTarget(loan.debt, loan.issuer, address(SP)); diff --git a/test/utils/Bound.sol b/test/utils/Bound.sol index 7b380766..4e630987 100644 --- a/test/utils/Bound.sol +++ b/test/utils/Bound.sol @@ -35,9 +35,9 @@ abstract contract Bound is StdUtils { used[input.identifier] = true; } else if (itemType == ItemType.ERC20) { input.identifier = 0; - input.amount = _boundMin(1, type(uint32).max); + input.amount = _boundMin(1, type(uint216).max); } else if (itemType == ItemType.ERC1155) { - input.amount = _boundMin(1, type(uint64).max); + input.amount = _boundMin(1, type(uint128).max); } ret = SpentItem({itemType: itemType, token: token, identifier: input.identifier, amount: input.amount}); @@ -54,10 +54,6 @@ abstract contract Bound is StdUtils { function _boundReceivedItem(Fuzz.ReceivedItem memory input) internal view returns (ReceivedItem memory ret) { ItemType itemType = _boundItemType(input.itemType); address token = _boundTokenByItemType(itemType); - // if (itemType == uint8(ItemType.ERC721)) { - // assert(!used[input.identifier]); - // used[itemType] = input.identifier; - // } ret = ReceivedItem({ itemType: itemType, token: token,