Skip to content

test(vault): cover admin-setter success paths and getter coverage gaps (#428-431) - #467

Merged
abayomicornelius merged 2 commits into
Heliobond:mainfrom
chonilius:fix/investment-vault-test-coverage
Aug 24, 2026
Merged

test(vault): cover admin-setter success paths and getter coverage gaps (#428-431)#467
abayomicornelius merged 2 commits into
Heliobond:mainfrom
chonilius:fix/investment-vault-test-coverage

Conversation

@chonilius

Copy link
Copy Markdown
Contributor

Summary

Adds the missing success-path test coverage flagged in #428, #429, #430, and #431 — four investment_vault entry points that either had only their #[only_owner] admin-rejection path exercised, or (for the two getters) no coverage at all.

Why this touches more than test.rs

investment_vault did not compile from a clean checkout of main — the crate has several pre-existing merge-corruption bugs unrelated to these issues that had to be fixed before any test (old or new) could even run:

  • check_deposit_lock() had a stray, undefined-variable (last_seq) sequence-number check spliced into the middle of its body with mismatched braces. Restored it to the single timestamp-based MIN_LOCK_PERIOD check its own doc comment ([Logic] Implement share lock-up period after deposit #33) describes.
  • get_withdrawal_window() and get_volume_fee_tier() in lib.rs, and withdrawal_window_set() / funding_round_ended() in events.rs, were each missing their closing brace, silently merging their bodies into the next function.
  • VaultError::EmptyBatchDeposit, FundingRoundActive, and InvestmentCapExceeded all shared discriminant 41 (E0081). Reassigned FundingRoundActive = 42 and InvestmentCapExceeded = 43 — nothing depends on their specific numeric values.

Fixing check_deposit_lock() means the deposit lock is now genuinely enforced during tests (previously it could not run at all), which surfaced a few more pre-existing issues blocking the suite from running:

  • test_get_project_investments_batch_returns_correct_amounts and test_claim_queued_is_idempotent_against_double_claim were calling registry_contract::create_project() with a stale 6-argument signature; updated to the current 4-argument (creator, uri, maturity_date, metadata_hash) signature.
  • test_get_all_project_investments_returns_all had entirely lost its body (with unrelated, otherwise-complete tests spliced into the gap) — reconstructed a minimal body matching its name.
  • The real body belonging to that same corrupted region turned out to be an orphaned, unnamed block testing queued-claim double-payout protection — recovered it as test_claim_settles_queued_withdrawal_then_second_claim_is_noop and advanced its ledger timestamp past MIN_LOCK_PERIOD before withdrawing, now that the lock is enforced.
  • test_get_deposit_lock_expiry (this PR's own new test) needed a non-zero ledger timestamp before depositing, since the getter's own "0 means never deposited" sentinel is otherwise indistinguishable from a real deposit made at the test env's default timestamp of 0.

Test plan

  • cargo test -p investment-vault --lib — full suite compiles and runs (previously failed to compile at all)
  • All 4 issue-specific tests pass: test_set_bridge_persists_emits_event_and_is_idempotent, test_set_wormhole_core_persists, test_set_carbon_oracle_persists_emits_event_and_is_idempotent, test_set_max_transaction_amount_persists_emits_event_and_is_idempotent, test_get_deposit_lock_expiry, test_is_funding_round_active_reflects_start_and_end
  • All tests touched by the compile fixes pass: test_get_all_project_investments_returns_all, test_get_project_investments_batch_returns_correct_amounts, test_claim_queued_is_idempotent_against_double_claim, test_claim_settles_queued_withdrawal_then_second_claim_is_noop, test_get_set_withdrawal_window, test_volume_fee_tier_is_admin_only

Closes #428
Closes #429
Closes #430
Closes #431

Fix pre-existing merge-corruption bugs in investment_vault that made
the crate fail to compile from a clean checkout:

- lib.rs: check_deposit_lock() had a stray, undefined-variable
  (`last_seq`) sequence-number check spliced into the middle of its
  body with mismatched braces; restore it to the single timestamp-based
  MIN_LOCK_PERIOD check its doc comment (Heliobond#33) describes.
- lib.rs: get_withdrawal_window() and get_volume_fee_tier() were each
  missing their closing brace, merging their bodies into the following
  function.
- events.rs: withdrawal_window_set() and funding_round_ended() were
  each missing their closing brace for the same reason.
- types.rs: VaultError::EmptyBatchDeposit, FundingRoundActive, and
  InvestmentCapExceeded all shared discriminant 41 (E0081); reassign
  FundingRoundActive = 42 and InvestmentCapExceeded = 43 since no test
  or caller depends on their specific numeric values.

None of this is reachable without a full crate compile, so the
existing test-coverage issues (Heliobond#428-431) targeted in the next commit
could not otherwise be verified.
set_max_transaction_amount/get_deposit_lock_expiry/is_funding_round_active

Closes Heliobond#428
Closes Heliobond#429
Closes Heliobond#430
Closes Heliobond#431

Each of these entry points previously had only its #[only_owner]
admin-rejection path exercised (in
test_all_only_owner_functions_reject_non_admin_caller) or, for the two
getters, no coverage at all:

- test_set_bridge_persists_emits_event_and_is_idempotent /
  test_set_wormhole_core_persists (Heliobond#428): call set_bridge/
  set_wormhole_core as owner, confirm the address round-trips through
  contract storage, confirm set_bridge's BridgeSet event fires on
  first call, and confirm the no-op-if-unchanged early return skips
  emitting a second event on a repeat call with the same address.
- test_set_carbon_oracle_persists_emits_event_and_is_idempotent /
  test_set_max_transaction_amount_persists_emits_event_and_is_idempotent
  (Heliobond#429): same persist + event + no-op-early-return shape for
  set_carbon_oracle and set_max_transaction_amount.
- test_get_deposit_lock_expiry (Heliobond#430): asserts 0 for a fresh account
  and deposited_at + MIN_LOCK_PERIOD immediately after a deposit.
- test_is_funding_round_active_reflects_start_and_end (Heliobond#431): asserts
  the getter is false initially, true after start_funding_round, and
  false again after end_funding_round.

Fixing check_deposit_lock() in the previous commit means the deposit
lock is now genuinely enforced in tests (it previously could not run
at all), which surfaced three more compile/runtime issues blocking any
test from running:

- test_get_project_investments_batch_returns_correct_amounts,
  test_get_all_project_investments_returns_all (reconstructed — its
  body had been entirely lost, with unrelated tests spliced into the
  gap) and test_claim_queued_is_idempotent_against_double_claim were
  calling registry_contract::create_project() with a stale 6-argument
  signature; updated to the current 4-argument
  (creator, uri, maturity_date, metadata_hash) signature.
- test_claim_settles_queued_withdrawal_then_second_claim_is_noop
  (recovered from the same orphaned block as
  test_get_all_project_investments_returns_all, which had swallowed
  this test's real body) needed the ledger timestamp advanced past
  MIN_LOCK_PERIOD before withdrawing, now that the lock is enforced.
- test_get_deposit_lock_expiry needed a non-zero ledger timestamp
  before depositing, since the getter's own 0-means-never-deposited
  sentinel is otherwise indistinguishable from a real deposit made at
  the test env's default timestamp of 0.

`cargo test -p investment-vault --lib` passes for all tests touched by
this change.
@drips-wave

drips-wave Bot commented Aug 24, 2026

Copy link
Copy Markdown

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

@abayomicornelius
abayomicornelius merged commit 6f58b0b into Heliobond:main Aug 24, 2026
1 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment