Skip to content

test(governance): add proptest for quorum and timelock invariants (#635)#715

Merged
Jagadeeshftw merged 3 commits into
Fluxora-Org:mainfrom
Killerjunior:governance-proptest
Jun 25, 2026
Merged

test(governance): add proptest for quorum and timelock invariants (#635)#715
Jagadeeshftw merged 3 commits into
Fluxora-Org:mainfrom
Killerjunior:governance-proptest

Conversation

@Killerjunior

Copy link
Copy Markdown
Contributor

Pull Request

Description

Adds a property-based test suite for the FluxoraGovernance contract's approve/execute/QuorumReachedAt logic using the proptest crate. The suite randomises signer-set sizes, approval orderings, and time advances across 8 invariant properties to assert that:

  1. A proposal never executes below quorumexecute always returns QuorumNotReached when approvals < threshold, regardless of elapsed time.
  2. A proposal never executes before the timelock elapsesexecute always returns TimelockNotElapsed when now < quorum_at + GOVERNANCE_TIMELOCK_SECONDS.
  3. The executed flag is one-way — a second execute on the same proposal always returns AlreadyExecuted.

Boundary conditions at approvals == threshold and now == quorum_at + TIMELOCK are explicitly probed to catch off-by-one bugs. The full (quorum × timelock) truth-table is also covered via a cross-product property.

Documentation in docs/governance.md is extended with a dedicated Property-Based Tests section describing each invariant, security notes, and how to run the suite.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test coverage improvement
  • Refactoring (no functional changes)

Related Issues

Closes #635

Changes Made

  • Added contracts/stream/tests/governance_proptest.rs — new proptest-driven integration test module with 8 invariant properties across 5 proptest! blocks (256 cases each, deterministic via fixed source_file seed)
  • Extended docs/governance.md with a Property-Based Tests section documenting all invariants, security notes on the timelock and quorum boundaries, and instructions to run/reproduce failures

Testing

Test Coverage

  • All tests pass locally: cargo test -p fluxora_stream
  • New tests added for new functionality
  • Existing tests updated for changed functionality
  • Test coverage remains above 95%

Test properties added

Property Invariant
prop_execute_fails_below_quorum QuorumNotReached whenever approvals < threshold
prop_execute_fails_before_timelock_elapses TimelockNotElapsed for now < quorum_at + TIMELOCK
prop_execute_succeeds_at_timelock_boundary Success at exactly now == quorum_at + TIMELOCK
prop_execute_succeeds_after_timelock_boundary Success for all now > exec_after
prop_second_execute_always_returns_already_executed AlreadyExecuted on any repeat call
prop_execute_outcome_matches_quorum_and_timelock_conditions Full (quorum × timelock) truth table
prop_exactly_quorum_approvals_allows_execution Exactly threshold approvals + boundary time succeeds
prop_one_below_quorum_prevents_execution threshold - 1 approvals always blocks regardless of time

Run the suite with:

cargo test --test governance_proptest --package fluxora_stream

@drips-wave

drips-wave Bot commented Jun 24, 2026

Copy link
Copy Markdown

@Killerjunior 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

@Jagadeeshftw

Copy link
Copy Markdown
Contributor

the quorum and timelock invariant proptests are exactly the kind of coverage governance needs, and the formal-verification smoke test plus the adversarial-auth test round it out well. rebased onto the latest main and it merged cleanly.

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.

Property-test fluxora_governance approve/quorum/timelock invariants with proptest

3 participants