Skip to content

test: add coverage for LendingBorrowing.sol - #24

Open
ayushsingh82 wants to merge 1 commit into
circlefin:masterfrom
ayushsingh82:test/lending-borrowing-coverage
Open

test: add coverage for LendingBorrowing.sol#24
ayushsingh82 wants to merge 1 commit into
circlefin:masterfrom
ayushsingh82:test/lending-borrowing-coverage

Conversation

@ayushsingh82

Copy link
Copy Markdown

Summary

The repo had no test suite. This adds a Hardhat/Mocha/Chai test file (test/LendingBorrowing.test.ts) covering contracts/LendingBorrowing.sol:

  • Constructor validation: zero-address collateral/lending token, collateral factor outside 1-100
  • setCollateralFactor: bounds enforcement and owner-only access
  • takeLoan: borrowing exactly up to maxBorrow, reverting past it, blocking a second active loan, reverting on insufficient pool liquidity
  • repayLoan: reverting on over-repayment and with no active loan, full repayment clearing the loan and unlocking collateral, partial repayment keeping collateral locked
  • withdrawCollateral: reverting on withdrawing locked collateral, allowing withdrawal of unlocked collateral

Also added a test script (hardhat test) to package.json.

Test plan

  • npx hardhat compile — clean
  • npx hardhat test — 16/16 passing
  • npx eslint test/LendingBorrowing.test.ts — clean

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.
@ayushsingh82

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant