test(redemption): verify emergency_withdraw does not corrupt yield snapshots#247
Open
Majormaxx wants to merge 4 commits into
Open
test(redemption): verify emergency_withdraw does not corrupt yield snapshots#247Majormaxx wants to merge 4 commits into
Majormaxx wants to merge 4 commits into
Conversation
added 4 commits
March 29, 2026 23:12
Add test_partial_early_redemption_then_full_redemption_at_maturity to test_redemption.rs. The test covers: - Stage 1: user redeems half their shares early via request_early_redemption and process_early_redemption; asserts payout equals assets minus 2% fee - Yield distribution between the two redemption stages - Stage 2: user redeems remaining shares at maturity via redeem_at_maturity; asserts payout includes pending yield - Final state: user holds zero vault shares; total received >= deposited principal No non-test code changes. Closes StellarYield#194
…movals Add test_vault_count_correct_after_multiple_removals to tests.rs. Creates five vaults, removes the first, middle, and last vault in sequence, and after each removal asserts: - get_vault_count() decrements correctly - get_all_vaults() excludes removed vaults and retains the rest - get_single_rwa_vaults() reflects the same exclusions - is_registered_vault() returns false for removed vaults - instance-storage counter always equals the vault list length No non-test code changes. Closes StellarYield#192
Add test_transfer_during_active_epoch_yield_attribution to test_token.rs. Timeline: - Epoch 1 opens with 100 yield over 1_000 shares - Alice (1_000 shares) transfers 400 to Bob mid-epoch - Epoch 2 opens with 200 yield over 1_000 shares Asserts: - Alice epoch-1 yield = 100 (full; snapshot captured pre-transfer 1_000) - Bob epoch-1 yield = 0 (snapshot captured pre-transfer 0) - Alice epoch-2 yield = 120 (600/1_000 * 200) - Bob epoch-2 yield = 80 (400/1_000 * 200) - Combined = 300, equal to total distributed No non-test code changes. Closes StellarYield#197
…apshots Add test_emergency_withdraw_does_not_affect_remaining_user_yield_snapshot to test_redemption.rs. Two users deposit equal amounts and yield is distributed (epoch 1). The vault is then paused and emergency_withdraw drains all assets. Asserts: - Vault is empty and recipient received all funds - Remaining users' share balances are unchanged - pending_yield_for_epoch(1) still returns correct values for both users (snapshot storage is not touched by emergency_withdraw) No non-test code changes. Closes StellarYield#221
|
@Majormaxx Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
test_emergency_withdraw_does_not_affect_remaining_user_yield_snapshottotest_redemption.rsemergency_withdrawdrains all assets to a recipientemergency_withdrawnever burns shares)pending_yield_for_epoch(1)still returns correct snapshot-based values for both users — snapshot storage is untouchedTest plan
cargo test -p single_rwa_vault -- test_emergency_withdraw_does_not_affect_remaining_user_yield_snapshotcargo test -p single_rwa_vault— 263 passed, 0 failedCloses #221