Skip to content

Commit

Permalink
cleanup and fuzzer updates for core changes
Browse files Browse the repository at this point in the history
  • Loading branch information
androolloyd committed Nov 20, 2023
1 parent e952072 commit 8c1e9b3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/forge-std
18 changes: 12 additions & 6 deletions test/AstariaV1Test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,18 @@ contract AstariaV1Test is StarportTest {
(SpentItem[] memory considerationPayment, SpentItem[] memory carryPayment,) =
Pricing(loan.terms.pricing).getRefinanceConsideration(loan, pricingData, transactor);

loan = SP.applyRefinanceConsiderationToLoan(loan, considerationPayment, carryPayment, pricingData);
loan.issuer = transactor;
loan.start = 0;
loan.originator = address(0);

return LenderEnforcer.Details({loan: loan});
Starport.Loan memory refiLoan = loanCopy(loan);
console.log("carryPayment.length", carryPayment.length);
console.log("considerationPayment.amount", considerationPayment[0].amount);
console.log("carryPayment.amount", carryPayment[0].amount);

refiLoan.debt = SP.applyRefinanceConsiderationToLoan(considerationPayment, carryPayment);
refiLoan.terms.pricingData = pricingData;
refiLoan.issuer = transactor;
refiLoan.start = 0;
refiLoan.originator = address(0);

return LenderEnforcer.Details({loan: refiLoan});
}

// loan.borrower and signer.addr could be mismatched
Expand Down
11 changes: 11 additions & 0 deletions test/fuzz-testing/TestFuzzV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ contract TestFuzzV1 is AstariaV1Test, TestFuzzStarport {
amount: _boundMax(params.debtAmount, type(uint112).max),
token: address(erc20s[1])
});
BasePricing.Details memory pDetails = abi.decode(loan.terms.pricingData, (BasePricing.Details));
while (true) {
try AstariaV1Pricing(loan.terms.pricing).calculateInterest(
1, debt[0].amount, pDetails.rate, pDetails.decimals
) returns (uint256 interest) {
break;
} catch {
debt[0].amount += 100 ** pDetails.decimals;
continue;
}
}
loan.debt = debt;
loan.borrower = borrower.addr;
loan.custodian = SP.defaultCustodian();
Expand Down

0 comments on commit 8c1e9b3

Please sign in to comment.