Skip to content

Add regression test that deregistering and re-registering an anchor leaves its existing balances untouched #156

Description

@Jagadeeshftw

📌 Description

deregister_anchor only flips the Anchor(address) flag to false via set_anchor_flag; it does not touch Balance(anchor, asset) entries, per its own doc comment ("Existing pool liquidity is unaffected; the anchor simply cannot open new positions"). There is no explicit regression test confirming a deregistered-then-re-registered anchor's balance/anchor_balances are exactly what they were before deregistration, with no double-counting in pool.providers from the re-registration.

🧩 Requirements and context

  • Add a regression test: provide liquidity as an anchor, deregister it, confirm balance/anchor_balances are unchanged and pool.providers still counts it, then re-register the same anchor and confirm balance/anchor_balances/pool.providers remain exactly as they were (no reset, no double-count).
  • Confirm the anchor can immediately withdraw its pre-existing balance after re-registration without needing to provide liquidity again first.
  • Confirm the anchor cannot provide_liquidity/open_settlement while deregistered, per existing AnchorNotRegistered behavior.

🛠️ Suggested execution

  • Add the test to src/test.rs, likely adjacent to the existing 're-registered anchor doesn't inherit stale fee-waiver state' test tracked in this repo's backlog, but scoped to balance/pool-provider bookkeeping instead of fee-waiver state.
  • No production code changes expected given deregister_anchor's documented scope; this closes a test-coverage gap on already-intended behavior.
  • Reuse existing anchor registration/deregistration test helpers.

✅ Acceptance criteria

  • A regression test confirms balances and pool-provider counts are fully preserved across a deregister/re-register cycle.
  • The anchor can withdraw its preserved balance immediately after re-registration.
  • The anchor is correctly blocked from liquidity/settlement actions while deregistered.

🔒 Security notes

If deregistration ever accidentally touched balance state in a future refactor, an anchor's funds could become temporarily or permanently inaccessible purely from an administrative registration action — a serious fund-availability risk this test explicitly guards against.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issuesecuritySecurity hardening / audittestingTests and coverage

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions