Skip to content

Add contract test: leave group edge cases#111

Open
WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
WuXieSec:test/leave-group-edge-cases
Open

Add contract test: leave group edge cases#111
WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
WuXieSec:test/leave-group-edge-cases

Conversation

@WuXieSec
Copy link
Copy Markdown

This PR adds comprehensive edge case tests for the leave_group function, as requested in #29.

Changes:

  • Test admin cannot leave their own group → Unauthorized error
  • Test leaving during Active state fails → GroupNotForming error
  • Test non-member leaving fails → NotMember error
  • Test leaving updates member_groups index correctly

Test coverage:
These tests ensure leave_group properly:

  • Prevents admins from abandoning their own groups
  • Only allows leaving during the Forming phase
  • Rejects attempts from non-members
  • Maintains data consistency in the member index

Why this matters:
The leave function has several important constraints:

  • Admins must stay with their groups (they can transfer admin rights first)
  • Members can only leave before the group starts
  • The member index must stay in sync with group membership

These tests validate all these rules are enforced correctly.

Closes #29

Changes:
- Test admin cannot leave their own group (Unauthorized)
- Test leaving during Active state fails (GroupNotForming)
- Test non-member leaving fails (NotMember)
- Test leaving updates member_groups index correctly

These tests ensure the leave_group function properly handles
all edge cases and maintains data consistency.

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

Add contract test: leave group edge cases

1 participant