test(creditline): add unit tests for repay_installment error paths#25
Merged
EmeditWeb merged 1 commit intoJun 15, 2026
Conversation
12 tasks
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.
close #1
PR Description
Summary
Adds isolated unit tests for
repay_installment()in the creditlinecontract. Previously the function only had incidental coverage via
end-to-end flows, leaving all error paths untested.
Changes
contracts/creditline-contract/src/tests.rssetup_loan_with_schedule(t, borrower, n_installments)—helper that registers a vendor, builds an N-installment schedule,
and calls
create_loan. Returns(loan_id, vendor).test_repay_installment_happy_path— pays 500 forinstallment 0, asserts
paid == true,paid_at == 5000,remaining_balancedecremented by 500, second installmentuntouched, loan still
Active.test_repay_installment_double_pay_rejected— pays the sameslot twice; expects
InstallmentAlreadyPaid(core: add contract storage migration utilities #24).test_repay_installment_out_of_bounds— calls indexinstallments.len()(2) on a 2-installment loan; expectsInvalidInstallmentIndex(core: implement vendor verification and approval flow #23).test_repay_installment_non_borrower_rejected— calls fromintruderaddress; expectsUnauthorizedRepayer(core: implement interest accrual calculation on-chain #14).test_repay_installment_zero_amount_rejected— calls withamount = 0; expectsInvalidRepaymentAmount(core: implement guarantee deposit locking in creditline #13).context/progress-tracker.mdTesting
cargo build— zero errorscargo test -p creditline-contract— 101 passed, 0 failed, 4 ignored