Skip to content

Add regression test that anchor_balances' pagination cursor stays stable when a new asset is added mid-pagination #148

Description

@Jagadeeshftw

📌 Description

anchor_balances(provider, start, limit) pages through storage::get_asset_list, which is append-only (new assets are always added at the end via remember_asset). There is no existing test confirming that if a new asset is added (via some other provider's provide_liquidity) between two paginated calls to anchor_balances for a given provider, the provider's in-progress pagination cursor (start) still correctly resumes without skipping or duplicating any of the provider's own existing non-zero balances.

🧩 Requirements and context

  • Add a regression test that begins paginating anchor_balances for a provider with several existing balances, then — between two paginated calls — has a different provider call provide_liquidity for a brand-new asset, then resumes pagination for the first provider and asserts no existing entries were skipped or duplicated.
  • Confirm the newly-added asset does not appear in the first provider's results unless that provider also happens to hold a balance in it.
  • Document the append-only-list assumption this pagination relies on in anchor_balances's doc comment if not already explicit.

🛠️ Suggested execution

  • Add the test to src/test.rs near existing anchor_balances coverage.
  • Simulate the interleaving explicitly: call anchor_balances for page 1, then mutate global asset state via a second provider, then call anchor_balances for page 2 using the start cursor returned/inferred from page 1.
  • No production code changes expected given AssetList's append-only design, unless the test uncovers an actual off-by-one at the append boundary.

✅ Acceptance criteria

  • A regression test confirms anchor_balances pagination remains stable across an asset-list mutation occurring between paginated calls.
  • No existing balance entries are skipped or duplicated across the two calls.
  • The append-only assumption underpinning this stability is documented.

🔒 Security notes

Silent pagination instability under concurrent asset onboarding would be a frustrating, hard-to-reproduce bug for any off-chain client incrementally rendering a provider's balances while other unrelated activity continues on the contract.

📋 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 issuesmart-contractSoroban/Rust smart contract worktestingTests and coverage

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions