Skip to content

Contract test coverage reporting#925

Merged
Xoulomon merged 182 commits into
Xoulomon:mainfrom
firstJOASH:contract-test-coverage-reporting
May 30, 2026
Merged

Contract test coverage reporting#925
Xoulomon merged 182 commits into
Xoulomon:mainfrom
firstJOASH:contract-test-coverage-reporting

Conversation

@firstJOASH
Copy link
Copy Markdown
Contributor

Closes #882

observerr411 and others added 30 commits February 21, 2026 04:21
- Add GroupCreated event for new group creation
- Add MemberJoined event for member additions
- Add ContributionMade event for tracking contributions
- Add PayoutExecuted event for payout operations
- Add GroupCompleted event for group completion
- Add GroupStatusChanged event for status transitions
- Implement EventEmitter utility for consistent event emission
- Add comprehensive event structures with all required fields
- Update lib.rs to include events module
…t-types

feat: Define event types for contract state changes
Wireframe - Dashboard/Home Page
- Define GroupStatus enum with lifecycle states: Pending, Active, Paused, Completed, Cancelled
- Implement state transition validation with proper error handling
- Add helper methods for status checks (is_terminal, can_accept_contributions, etc.)
- Add display implementation (as_str, description) for status representation
- Define comprehensive storage key structure with enums for all data types
- Add StorageKeyBuilder utility for clean key generation API
- Define event structures for all contract actions (GroupCreated, MemberJoined, etc.)
- Add EventEmitter utility for consistent event publishing
- Include comprehensive test suites for all modules (20+ tests per module)
…age-keys

feat: Add GroupStatus enum, storage keys, and events
Manuel1234477 and others added 28 commits February 23, 2026 14:07
- Add validate_contribution_amount function to validate contribution amounts against group requirements
- Load group from storage and compare amounts
- Return validation result (Ok or InvalidAmount/GroupNotFound error)
- Add 8 comprehensive tests covering:
  - Success case with correct amount
  - Invalid amount (too low, too high, zero, negative)
  - Group not found error
  - Multiple groups with different amounts
  - Edge case with 1 stroop minimum

Resolves Xoulomon#76
- Add get_missed_contributions function to identify members who haven't contributed in a cycle
- Get all members from group storage
- Filter members who don't have contribution records for the specified cycle
- Return vector of addresses for non-contributors
- Add 8 comprehensive tests covering:
  - All members contributed (empty result)
  - Some members missed
  - All members missed
  - Group not found error
  - Different cycles
  - Empty group
  - Single member group
  - Large group with partial contributions

The function is useful for:
- Tracking delinquent members
- Sending contribution reminders
- Determining cycle completion status
- Enforcing contribution deadlines
- Add record_contribution internal helper function to record contributions in storage
- Create ContributionRecord with validation
- Store contribution with proper key (contribution_individual)
- Update cycle total amount (contribution_cycle_total)
- Update cycle contributor count (contribution_cycle_count)
- Prevent duplicate contributions with AlreadyContributed error
- Handle arithmetic overflow with checked operations
- Add 9 comprehensive tests covering:
  - Successful contribution recording
  - Duplicate contribution prevention
  - Multiple members contributing
  - Contributions across different cycles
  - Different contribution amounts
  - Updating existing totals
  - Zero initial totals
  - Large contribution amounts
  - Proper storage key usage

The function ensures data consistency by atomically updating:
1. Individual contribution record
2. Cycle total amount
3. Cycle contributor count

This helper will be used by the main contribute() function to maintain
proper accounting and prevent double-counting.
- Added get_contribution_deadline function to calculate deadline timestamps for cycle contributions
- Formula: deadline = started_at + (cycle_number * cycle_duration) + cycle_duration
- Verifies group exists and has been started before calculation
- Uses checked arithmetic operations to prevent overflow
- Returns Unix timestamp (u64) or appropriate errors

Error handling:
- GroupNotFound: When group doesn't exist
- InvalidState: When group hasn't been started yet
- Overflow: When timestamp calculation overflows

Added 11 comprehensive tests:
- test_get_contribution_deadline_cycle_0: Verify cycle 0 deadline calculation
- test_get_contribution_deadline_cycle_1: Verify cycle 1 deadline calculation
- test_get_contribution_deadline_multiple_cycles: Test multiple cycles (0-4)
- test_get_contribution_deadline_group_not_found: Error handling for non-existent group
- test_get_contribution_deadline_group_not_started: Error handling for unstarted group
- test_get_contribution_deadline_different_durations: Test with different cycle durations
- test_get_contribution_deadline_time_remaining: Calculate time remaining in cycle
- test_get_contribution_deadline_expired_cycle: Check if cycle has expired
- test_get_contribution_deadline_high_cycle_number: Test with high cycle numbers (50)
- test_get_contribution_deadline_short_duration: Test with short durations (1 hour)
- test_get_contribution_deadline_consistency: Verify function returns consistent results

Use cases:
- Display countdown timers to users
- Enforce contribution deadlines
- Determine if a cycle has expired
- Schedule automated reminders
…ribution-amount-v2

Implement validate_contribution_amount helper function (Xoulomon#76)
…ibutions

Feature/get missed contributions
…-deadline

Feature/get contribution deadline
feat: Add step-by-step deployment guide for testnet and mainnet
…-component

feat(dropdown): create accessible dropdown component with keyboard su…
…on-component

feat(pagination): create reusable pagination component with page cont…
…-component

feat(dropdown): create accessible dropdown component with keyboard su…
…r-component

feature/140-searchbar-component
…d-component

feat(ui): implement GroupCard component with summary stats and actions
…e-reporting

# Conflicts:
#	.github/workflows/coverage.yml
#	Cargo.lock
#	Wireframe - Loading & Empty States.txt
#	contracts/stellar-save/src/cycle_advancement.rs
#	contracts/stellar-save/src/error.rs
#	contracts/stellar-save/src/events.rs
#	contracts/stellar-save/src/group.rs
#	contracts/stellar-save/src/lib.rs
#	contracts/stellar-save/src/pool.rs
#	contracts/stellar-save/src/status.rs
#	contracts/stellar-save/src/storage.rs
#	contracts/stellar-save/test_snapshots/tests/test_get_total_groups_created.1.json
#	design/Design System & Style Guide.txt
#	design/Empty scrreens.txt
#	design/Mobile Navigation
#	design/Profile Ui.txt
#	design/Wallet Ui.txt
#	design/Wireframe
#	design/Wireframe - Loading & Empty States.txt
#	design/Wireframe - Mobile Navigation
#	design/creatingintertiveprptotype
#	design/dashboard.txt
#	design/wireframe.txt
#	docs/architecture.md
#	docs/deployment.md
#	docs/storage-layout.md
#	docs/threat-model.md
#	frontend/index.html
#	frontend/package-lock.json
#	frontend/package.json
#	frontend/src/App.tsx
#	frontend/src/components/Avatar.css
#	frontend/src/components/Avatar.tsx
#	frontend/src/components/Badge.css
#	frontend/src/components/Badge.tsx
#	frontend/src/components/Button.css
#	frontend/src/components/Button.tsx
#	frontend/src/components/Card.css
#	frontend/src/components/Card.tsx
#	frontend/src/components/ErrorBoundary/ErrorBoundary.css
#	frontend/src/components/ErrorBoundary/ErrorBoundary.tsx
#	frontend/src/components/GroupCard.css
#	frontend/src/components/GroupCard.tsx
#	frontend/src/components/Header.css
#	frontend/src/components/Header.tsx
#	frontend/src/components/SearchBar.css
#	frontend/src/components/SearchBar.tsx
#	frontend/src/components/Skeleton/GroupCardSkeleton.tsx
#	frontend/src/components/WalletButton.tsx
#	frontend/src/components/index.ts
#	frontend/src/index.css
#	frontend/src/main.tsx
#	frontend/src/test/Avatar.test.tsx
#	frontend/src/test/Badge.test.tsx
#	frontend/src/test/SearchBar.test.tsx
#	frontend/src/test/Tooltip.test.tsx
#	frontend/src/test/WalletButton.test.tsx
#	frontend/src/ui/layout/AppLayout.tsx
#	frontend/src/ui/providers/AppThemeProvider.tsx
#	frontend/src/ui/theme/theme.ts
#	frontend/src/wallet/WalletProvider.tsx
#	frontend/src/wallet/types.ts
#	frontend/tsconfig.json
#	frontend/vitest.config.ts
#	rust-toolchain.toml
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@firstJOASH Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Xoulomon Xoulomon merged commit c7ac7cb into Xoulomon:main May 30, 2026
13 of 44 checks passed
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.

[Testing] Add contract test coverage reporting