Skip to content

Savings Goals: add remove_tags_from_goal idempotency and unknown-tag no-op tests with stale-index cleanup #758

@Baskarayelu

Description

@Baskarayelu

📋 Description

SavingsGoalContract::remove_tags_from_goal in savings_goals/src/lib.rs is the inverse of add_tags_to_goal and must keep the goal's tag set and any goal-by-tag index consistent. The add path and tag-charset canonicalization are tested, but removal has gaps: removing a tag that isn't present, removing the same tag twice, and removing the last tag should all be well-defined no-ops or clean deletions.

Why this matters: tag indexes feed off-chain search and the goals-by-tag lookup. A removal path that leaves a dangling index entry (or errors on an absent tag) produces ghost search results and confuses clients. Idempotent, index-clean removal is the contract clients depend on.

🎯 Requirements & Context

Functional requirements

  • Test removing a tag that is not on the goal — should be a no-op, not an error.
  • Test removing the same tag twice — second call is a no-op.
  • Test removing the last remaining tag leaves an empty, valid tag set.
  • Assert any goal-by-tag index entry is cleaned up so the goal no longer appears under the removed tag.
  • Assert owner-only authorization (Unauthorized for non-owner) and that canonicalization matches add_tags_to_goal.

Context & constraints

  • Soroban SDK =21.7.7, edition 2021. Reuse the shared canonicalize_tags helper from remitwise-common/src/lib.rs.
  • Test-only; do not change behavior unless a dangling-index bug is found, in which case document it.

🛠️ Suggested Execution

1. Fork & branch

git checkout -b test/savings-remove-tags-idempotency

2. Implement changes

  • Add the removal tests to savings_goals/src/test.rs with /// comments per scenario.
  • Document the idempotent-removal contract in docs/.

3. Test & commit

cargo test -p savings_goals remove_tags -- --nocapture
  • Edge cases: mixed-case tags that canonicalize to the same value, removing tags from an archived goal, and removing a tag whose index has already been cleaned.

Example commit message

test(savings): cover remove_tags_from_goal idempotency and stale-index cleanup

Adds no-op, double-remove, last-tag, and index-cleanup assertions plus
owner-auth checks.

✅ Acceptance Criteria & Guidelines

Requirement Target
Coverage of remove_tags_from_goal ≥ 95%
Idempotency + index-cleanup asserted Required
Owner-auth negative test Required
Doc comments + docs/ note Required
cargo test -p savings_goals + cargo clippy clean Required
Timeframe 96 hours from assignment

💬 Community & Support

Join the Remitwise contributor community on Discord: https://discord.gg/CtQuPZFMA

Comment when you pick this up. 🚀

Metadata

Metadata

Assignees

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions