Skip to content

#495 Add test coverage for harvest() FIXED - #683

Merged
Abidoyesimze merged 2 commits into
Neurowealth:mainfrom
onakijames-droid:#495-Add-test-coverage-for-harvest()-FIX
Aug 29, 2026
Merged

#495 Add test coverage for harvest() FIXED#683
Abidoyesimze merged 2 commits into
Neurowealth:mainfrom
onakijames-droid:#495-Add-test-coverage-for-harvest()-FIX

Conversation

@onakijames-droid

@onakijames-droid onakijames-droid commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

CLOSED #495 Add test coverage for harvest()

Summary

Adds dedicated unit-test coverage for the agent-callable harvest() entrypoint (Issue #465 / PR #491). There was no test_harvest.rs before; harvest was only exercised incidentally (budget, pause matrix, cooldown, concurrent).

harvest() withdraws the full CurrentProtocol position and immediately re-supplies it, compounding yield in place. It is agent-gated (unlike owner-gated emergency_harvest) and shares the rebalance cooldown window.

Acceptance coverage

  1. Success: withdraws and re-supplies Blend/DEX, emits HarvestEvent with the correct protocol and amount_harvested.
  2. Rejects when paused: VaultError::Paused (#35).
  3. Rejects non-agent: require_is_agent (empty auth and attacker signer).
  4. Rejects negative min_out: VaultError::MinOutMustBeNonNegative (#16).
  5. Rejects CurrentProtocol == "none": VaultError::UnsupportedProtocol (#17).
  6. Rejects before cooldown elapses: VaultError::RebalanceCooldownActive (#43).

Also included so the lib test crate can compile and run these tests

  • Split a pre-existing merge in test_rebalance.rs (unclosed {).
  • Kept VaultError at the Soroban SDK 50-variant #[contracterror] cap by aliasing extra names (62–76) as associated constants (same pattern as InvalidWasmHash).
  • Imported missing event topic constants used by migration / share-lock / emergency-withdraw paths.
  • Left four already-broken test modules unregistered (test_concurrent_timelocks, test_reentrancy_defense, test_liquidity_mining_rewards, test_performance_fee).

harvest() itself is unchanged: no new public function, no new events, no harvest error-code changes, no get_version() bump.

Files

Status Path
Created neurowealth-vault/contracts/vault/src/tests/test_harvest.rs
Modified neurowealth-vault/contracts/vault/src/tests/mod.rs
Modified neurowealth-vault/contracts/vault/src/lib.rs
Modified neurowealth-vault/contracts/vault/src/tests/test_rebalance.rs

Validation

cargo test --package neurowealth-vault --lib comprehensive_tests::test_harvest::
test result: ok. 18 passed; 0 failed; 0 ignored

Checklist

  • I have updated CHANGELOG.md under [Unreleased] for any contract behavior, event, or error-code changes.
    N/A for harvest: no harvest() behavior, event, or harvest error-code change. get_version() is not bumped.
  • If this PR bumps get_version(), the new version number is noted in CHANGELOG.md.
    N/A — version not bumped.
  • I have confirmed the release entry matches the expected contract Version storage value.
    N/A — no release / version change.
  • I have included tests or documentation updates for new contract behavior.
    Dedicated test_harvest.rs (18 tests) covering ACs 1–6.
  • New or changed events are reflected in EVENTS.md.
    N/A — HarvestEvent / TOPIC_HARVEST already documented.
  • If this PR adds a new public contract function, I have added it to the pause-semantics matrix in SECURITY.md and added a corresponding test in test_pause.rs.
    N/A — harvest() already exists; already listed in SECURITY.md and covered by pause_matrix_harvest_blocked.

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@onakijames-droid 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

orebams pushed a commit to orebams/NeuroWealth-Smartcontract that referenced this pull request Aug 29, 2026
…1-614

fix(a11y): keyboard ops, focus rings, aria alerts, valid markup (Neurowealth#611Neurowealth#614)
@onakijames-droid

Copy link
Copy Markdown
Contributor Author

@robertocarlous PLEASE REVIEW AND MERGE

@Abidoyesimze
Abidoyesimze merged commit 385f8c8 into Neurowealth:main Aug 29, 2026
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 coverage for harvest()

2 participants