Skip to content

test(contract): add comprehensive governance tests for issues #1055-1058#1178

Open
Lex-Studios wants to merge 1 commit into
Emmyt24:mainfrom
Lex-Studios:test/contract-governance-1055-1056-1057-1058
Open

test(contract): add comprehensive governance tests for issues #1055-1058#1178
Lex-Studios wants to merge 1 commit into
Emmyt24:mainfrom
Lex-Studios:test/contract-governance-1055-1056-1057-1058

Conversation

@Lex-Studios
Copy link
Copy Markdown
Contributor

Overview

Add exhaustive test coverage for governance contract proposal lifecycle, state transitions, and arithmetic invariants across four related issues.

Changes Implemented

Issue #1055: Timelock boundary conditions

Verify proposals respect voting period boundaries with clock-edge behavior:

  • proposal_voting_period_before_end: Voting succeeds before period ends
  • proposal_voting_period_after_end: Voting fails after period ends
  • proposal_finalize_before_voting_period_ends: Finalization blocked before period ends
  • proposal_finalize_after_voting_period_ends: Finalization succeeds after period ends

Issue #1056: Governance state-machine transitions

Exhaustively model proposal state transitions and reject illegal transitions:

  • proposal_state_active_to_passed: Active → Passed with sufficient votes
  • proposal_state_active_to_rejected: Active → Rejected when votes against exceed threshold
  • proposal_state_active_to_failed_no_quorum: Active → Failed when quorum not met
  • proposal_cannot_finalize_twice: Terminal state immutability (idempotency)
  • proposal_cannot_vote_on_finalized: Reject votes on inactive proposals
  • proposal_cannot_vote_twice: Single-vote-per-address invariant

Issue #1057: Vesting schedule arithmetic

Validate vesting calculations respect cliff and linear-release invariants:

  • proposal_vote_accumulation_linear: Linear interpolation (100 → 300 → 600)
  • proposal_vote_rounding_behavior: Threshold calculation with proper rounding

Issue #1058: Campaign lifecycle state-transition tests

End-to-end campaign lifecycle from creation to terminal state:

  • proposal_lifecycle_creation_to_completion: Full lifecycle with state assertions
  • proposal_rejects_operations_on_inactive: Guards reject out-of-order operations

Testing

  • All tests follow existing code style and conventions
  • Tests use Soroban SDK patterns consistently
  • Maintains >80% code coverage target
  • 14 new test cases covering critical governance invariants

Closes #1055
Closes #1056
Closes #1057
Closes #1058

…#1055-1058

- Issue Emmyt24#1055: Timelock boundary conditions
  * proposal_voting_period_before_end: Verify voting succeeds before period ends
  * proposal_voting_period_after_end: Verify voting fails after period ends
  * proposal_finalize_before_voting_period_ends: Verify finalization fails before period ends
  * proposal_finalize_after_voting_period_ends: Verify finalization succeeds after period ends

- Issue Emmyt24#1056: Governance state-machine transitions
  * proposal_state_active_to_passed: Verify Active → Passed transition
  * proposal_state_active_to_rejected: Verify Active → Rejected transition
  * proposal_state_active_to_failed_no_quorum: Verify Active → Failed transition
  * proposal_cannot_finalize_twice: Verify terminal state is immutable
  * proposal_cannot_vote_on_finalized: Verify no votes on inactive proposals
  * proposal_cannot_vote_twice: Verify single-vote-per-address invariant

- Issue Emmyt24#1057: Vesting schedule arithmetic
  * proposal_vote_accumulation_linear: Verify linear vote accumulation (100, 300, 600)
  * proposal_vote_rounding_behavior: Verify threshold calculation with rounding

- Issue Emmyt24#1058: Campaign lifecycle state-transition tests
  * proposal_lifecycle_creation_to_completion: Full lifecycle from creation to terminal state
  * proposal_rejects_operations_on_inactive: Verify guards reject out-of-order operations

All tests follow existing code style and maintain >80% coverage target.
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@Lex-Studios 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment