Skip to content

test(integration): add rebalance protocol-path tests (#46)#80

Merged
Abidoyesimze merged 2 commits intoNeurowealth:mainfrom
Mrwicks00:test/issue-46-rebalance-protocol-path
Mar 30, 2026
Merged

test(integration): add rebalance protocol-path tests (#46)#80
Abidoyesimze merged 2 commits intoNeurowealth:mainfrom
Mrwicks00:test/issue-46-rebalance-protocol-path

Conversation

@Mrwicks00
Copy link
Copy Markdown
Contributor

Summary

Closes #46

Adds integration-level tests for all rebalance protocol-path transitions in the NeuroWealth Vault. These tests operate end-to-end using the existing mock/fixture pool (MockBlendPool, TestToken) to validate real on-chain fund movement, state changes, and emitted events.

Changes

  • New file: contracts/vault/src/tests/test_rebalance_integration.rs — 13 integration tests
  • Modified: contracts/vault/src/tests/mod.rs — registers the new test module

Tests Added

Test Covers
test_integration_rebalance_to_blend_with_pool_configured Happy-path: supplies all vault USDC to Blend, checks CurrentProtocol, asset accounting, and BlendSupplyEvent/RebalanceEvent
test_integration_rebalance_to_blend_already_in_blend_is_idempotent Re-entrant blend→blend call does not duplicate supply
test_integration_rebalance_to_blend_without_pool_panics_with_balance No pool + balance → explicit vault: blend pool not configured panic
test_integration_rebalance_to_blend_without_pool_panics_zero_balance No pool + zero balance → same panic (pool check is unconditional)
test_integration_rebalance_from_blend_to_none_withdraws_all Switches blend→none, withdraws all funds, validates BlendWithdrawEvent fields
test_integration_rebalance_none_to_none_is_noop none→none leaves funds untouched, still emits RebalanceEvent
test_integration_full_protocol_round_trip none→blend→none→blend end-to-end cycle
test_integration_rebalance_blend_zero_vault_balance_no_panic Zero-balance blend call completes without panic; CurrentProtocol stays none (deterministic)
test_integration_rebalance_unknown_protocol_is_explicit_failure Unknown protocol → vault: unsupported protocol
test_integration_rebalance_while_paused_explicit_failure Paused vault → vault: paused
test_integration_asset_accounting_invariant_across_full_cycle Two-user deposit → blend → partial withdraw → none; total assets conserved at every step
test_integration_rebalance_event_schema_correctness Three rebalances emit exactly 3 events with correct protocol + expected_apy fields
test_integration_blend_supply_event_fields_are_correct BlendSupplyEvent has correct asset, amount, success flag
test_integration_blend_withdraw_event_fields_on_protocol_switch BlendWithdrawEvent has correct requested_amount, amount_received, success flag

Test Results

test result: ok. 175 passed; 0 failed; 0 ignored

Acceptance Criteria

  • Integration tests run in CI (standard cargo test)
  • All critical rebalance protocol transitions covered
  • Failure-path assertions are explicit and deterministic
  • CurrentProtocol, asset accounting, and rebalance events validated

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 30, 2026

@Mrwicks00 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

@Abidoyesimze Abidoyesimze merged commit 154d166 into Neurowealth:main Mar 30, 2026
5 checks passed
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.

test(integration): add rebalance protocol-path tests with mock/fixture pool

2 participants