Skip to content

test: add quorum boundary edge case tests for governance proposals#2252

Merged
Baskarayelu merged 1 commit into
QuickLendX:mainfrom
owohdora-stack:test-for-quorum-case-1957
Jul 27, 2026
Merged

test: add quorum boundary edge case tests for governance proposals#2252
Baskarayelu merged 1 commit into
QuickLendX:mainfrom
owohdora-stack:test-for-quorum-case-1957

Conversation

@owohdora-stack

Copy link
Copy Markdown

Add tests for quorum edge cases

Closes #1957

Summary

Adds 6 deterministic unit tests to src/test_governance.rs that lock down the quorum boundary logic in Governable::finalize_proposal (governance.rs:262):

let total = proposal.votes_for.saturating_add(proposal.votes_against);
let passed = total >= Self::quorum() && proposal.votes_for > proposal.votes_against;

The test harness uses a quorum of 3.

Tests added

Test Total votes For Against Expected
finalize_proposal_passes_when_exactly_at_quorum_with_majority_for 3 (at quorum) 2 1 Passed
finalize_proposal_rejects_when_exactly_at_quorum_with_majority_against 3 (at quorum) 1 2 Rejected
finalize_proposal_rejects_when_one_vote_below_quorum_even_with_majority_for 2 (below quorum) 2 0 Rejected
finalize_proposal_rejects_when_one_vote_below_quorum_with_split_votes 2 (below quorum) 1 1 Rejected
finalize_proposal_passes_when_one_vote_above_quorum_with_majority_for 4 (above quorum) 3 1 Passed
finalize_proposal_rejects_when_one_vote_above_quorum_but_tied 4 (above quorum) 2 2 Rejected

Coverage

  • Happy path: Quorum met with majority for passes (at and above threshold).
  • Sad paths: Quorum not met (even with majority for), quorum met but tied, quorum met with majority against — all correctly reject.

Verification

  • All tests follow existing patterns: use setup(), proposal_id(), cast_vote(), finalize_proposal() helpers.
  • Deterministic: no Date.now() / Math.random() — uses injected Address::generate and fixed ledger sequences.
  • #![no_std] discipline maintained: only soroban_sdk primitives used.
  • Test names are assertive and descriptive.
  • Only test_governance.rs modified; no unrelated refactors.

Note

The crate has pre-existing compilation errors on main (duplicate definitions, missing enum variants, unclosed delimiter in settlement.rs) that prevent cargo test from running. These are unrelated to quorum logic and tracked separately.

@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@owohdora-stack 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

@Baskarayelu
Baskarayelu merged commit d62f4c0 into QuickLendX:main Jul 27, 2026
0 of 2 checks passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jul 27, 2026
5 tasks
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 tests for the quorum edge cases

3 participants