test(governance): add proptest for quorum and timelock invariants (#635)#715
Merged
Merged
Conversation
|
@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! 🚀 |
4 tasks
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Adds a property-based test suite for the
FluxoraGovernancecontract'sapprove/execute/QuorumReachedAtlogic using theproptestcrate. The suite randomises signer-set sizes, approval orderings, and time advances across 8 invariant properties to assert that:executealways returnsQuorumNotReachedwhenapprovals < threshold, regardless of elapsed time.executealways returnsTimelockNotElapsedwhennow < quorum_at + GOVERNANCE_TIMELOCK_SECONDS.executeon the same proposal always returnsAlreadyExecuted.Boundary conditions at
approvals == thresholdandnow == quorum_at + TIMELOCKare 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.mdis extended with a dedicated Property-Based Tests section describing each invariant, security notes, and how to run the suite.Type of Change
Related Issues
Closes #635
Changes Made
contracts/stream/tests/governance_proptest.rs— new proptest-driven integration test module with 8 invariant properties across 5proptest!blocks (256 cases each, deterministic via fixedsource_fileseed)docs/governance.mdwith a Property-Based Tests section documenting all invariants, security notes on the timelock and quorum boundaries, and instructions to run/reproduce failuresTesting
Test Coverage
cargo test -p fluxora_streamTest properties added
prop_execute_fails_below_quorumQuorumNotReachedwheneverapprovals < thresholdprop_execute_fails_before_timelock_elapsesTimelockNotElapsedfornow < quorum_at + TIMELOCKprop_execute_succeeds_at_timelock_boundarynow == quorum_at + TIMELOCKprop_execute_succeeds_after_timelock_boundarynow > exec_afterprop_second_execute_always_returns_already_executedAlreadyExecutedon any repeat callprop_execute_outcome_matches_quorum_and_timelock_conditionsprop_exactly_quorum_approvals_allows_executionthresholdapprovals + boundary time succeedsprop_one_below_quorum_prevents_executionthreshold - 1approvals always blocks regardless of timeRun the suite with:
cargo test --test governance_proptest --package fluxora_stream