test: add coverage for LendingBorrowing.sol - #24
Open
ayushsingh82 wants to merge 1 commit into
Open
Conversation
The repo had no test suite. Adds a Hardhat/Mocha test file covering: - constructor validation (zero-address tokens, collateral factor 1-100) - setCollateralFactor bounds + owner-only access - takeLoan up to and past maxBorrow, duplicate active loans, insufficient pool liquidity - repayLoan over-repayment, no active loan, full vs. partial repayment (collateral stays locked until fully repaid) - withdrawCollateral of locked vs. unlocked collateral 16 tests, all passing.
Author
|
@akelani-circle Repo had no test suite, so this adds Hardhat/Chai coverage for LendingBorrowing.sol — constructor validation, collateral factor bounds/owner access, takeLoan limits + liquidity checks, repayLoan (full/partial), and withdrawCollateral locking. 16 tests, all passing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The repo had no test suite. This adds a Hardhat/Mocha/Chai test file (
test/LendingBorrowing.test.ts) coveringcontracts/LendingBorrowing.sol:setCollateralFactor: bounds enforcement and owner-only accesstakeLoan: borrowing exactly up tomaxBorrow, reverting past it, blocking a second active loan, reverting on insufficient pool liquidityrepayLoan: reverting on over-repayment and with no active loan, full repayment clearing the loan and unlocking collateral, partial repayment keeping collateral lockedwithdrawCollateral: reverting on withdrawing locked collateral, allowing withdrawal of unlocked collateralAlso added a
testscript (hardhat test) topackage.json.Test plan
npx hardhat compile— cleannpx hardhat test— 16/16 passingnpx eslint test/LendingBorrowing.test.ts— clean