Skip to content

test(token): verify yield attribution after mid-epoch share transfer#246

Open
Majormaxx wants to merge 3 commits into
StellarYield:mainfrom
Majormaxx:feat/transfer-mid-epoch-yield-test
Open

test(token): verify yield attribution after mid-epoch share transfer#246
Majormaxx wants to merge 3 commits into
StellarYield:mainfrom
Majormaxx:feat/transfer-mid-epoch-yield-test

Conversation

@Majormaxx
Copy link
Copy Markdown

Summary

  • Adds test_transfer_during_active_epoch_yield_attribution to test_token.rs
  • Tests the snapshot-based yield accounting when a transfer occurs mid-epoch:
    • Epoch 1 opens (100 yield / 1,000 shares); Alice transfers 400 shares to Bob
    • Snapshot fires pre-transfer → Alice's epoch-1 yield = 100, Bob's = 0
    • Epoch 2 opens (200 yield / 1,000 shares) with post-transfer balances
    • Alice epoch-2 yield = 120 (600/1,000 × 200), Bob epoch-2 yield = 80 (400/1,000 × 200)
    • Combined claims = 300 = total distributed
  • No non-test code changes

Test plan

  • New test passes: cargo test -p single_rwa_vault -- test_transfer_during_active_epoch_yield_attribution
  • Full suite passes: cargo test -p single_rwa_vault — 262 passed, 0 failed

Closes #197

Majormaxx added 3 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
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Mar 29, 2026

@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! 🚀

Learn more about application limits

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.

Add Test for Transfer of Shares During Active Epoch

1 participant