Skip to content

Fix: Handle edge case when all members leave during Forming#113

Open
WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
WuXieSec:fix/delete-empty-group
Open

Fix: Handle edge case when all members leave during Forming#113
WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
WuXieSec:fix/delete-empty-group

Conversation

@WuXieSec
Copy link
Copy Markdown

This PR fixes the edge case where all non-admin members leave a group during the Forming state, as requested in #22.

Changes:

  • Add delete_group(admin, group_id) function
  • Only works in Forming state with 1 member (admin)
  • Clean up all storage keys (group data and member index)
  • Add remove_group helper in storage.rs
  • Add comprehensive test coverage

Why this matters:
Without this fix, if all members leave a group during Forming:

  • The admin is stuck with an unusable group
  • Storage is wasted on orphaned groups
  • The admin can't clean up and start fresh

Implementation:
The delete_group function:

  • Requires admin authorization
  • Only works in Forming state
  • Only works when exactly 1 member remains (the admin)
  • Cleans up both the group data and member index

Test coverage:

  • ✅ Delete empty group (only admin remains)
  • ❌ Delete group with multiple members → InsufficientMembers
  • ❌ Non-admin tries to delete → Unauthorized
  • ❌ Delete active group → GroupNotForming

Closes #22

Changes:
- Add delete_group(admin, group_id) function
- Only works in Forming state with 1 member (admin)
- Clean up all storage keys (group data and member index)
- Add remove_group helper in storage.rs
- Add comprehensive test coverage

This allows admins to clean up groups when all other members
have left during the Forming phase, preventing orphaned groups.

Closes sorosave-protocol#22
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.

Fix: Handle edge case when all members leave during Forming

1 participant