test: add can_withdraw default behaviour tests - #572
Open
ghg001 wants to merge 8 commits into
Open
Conversation
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.
Overview
This PR adds explicit tests for
can_withdrawdefault behaviour in the savings vault. It verifies the function returns predictable values for a new user with no balance, a user with an available balance but no lock, and a user after a lock has been set up where applicable. The default logic incontracts/savings_vault/src/lib.rsis also made explicit so the tested defaults are intentional rather than incidental.Related Issue
Closes the bounty issue: Add tests for can_withdraw default behaviour
Changes
🧪 Explicit
can_withdrawDefault Tests[ADD]
contracts/savings_vault/src/test/mod.rs[ADD]
contracts/savings_vault/src/test/withdraw_lock.rscan_withdraw_new_user_returns_false— no balance, no lock, expected defaultfalse.can_withdraw_available_balance_no_lock_returns_true— funds available, no lock, expected defaulttrue.[ADD]
contracts/savings_vault/src/test/lock_maturity_boundary.rscan_withdraw_locked_balance_before_unlock_returns_false— lock created but not yet mature, expectedfalse.can_withdraw_after_unlock_returns_true— boundary check for comparison.[MODIFY]
contracts/savings_vault/src/lib.rscan_withdrawhandling explicit for zero-balance and no-lock cases.[MODIFY]
contracts/savings_vault/src/test/test_helpers.rsVerification Results
can_withdrawfor a new user is testedcan_withdraw_new_user_returns_falsecan_withdrawfor a user with available balance and no lock is testedcan_withdraw_available_balance_no_lock_returns_trueCloses #100