Skip to content

Establish Property-Based Coverage for the Proposal Finalization Decision Table #1831

Description

@Emmyt24

Description

contracts/governance/src/governance_property_test.rs is the only proptest module actually declared (#[cfg(test)] mod governance_property_test; in lib.rs) and executed for the governance crate, and its own doc comment lists exactly 8 properties — all about delegation, vote-power conservation, and snapshots. None of them exercise create_proposal, cast_vote, finalize_proposal, or execute_proposal. The only property-based coverage of that lifecycle lives in the orphaned, uncompiled vote_accounting_test.rs (tracked separately), which additionally models balances via a stale mock incompatible with the current admin/total_supply/set_balance API. That leaves the proposal/voting lifecycle with zero running property-based coverage today.

Requirements and Context

  • New proptests must reuse the existing make_contract()/c() helper pattern already defined at the top of governance_property_test.rs, for consistency with the file's other 8 properties.
  • Must be deterministic/reproducible under proptest's default seed handling (same as the existing properties in this file).

Suggested Execution

Branch: test/governance-proposal-lifecycle-proptest

Implement Changes

  • Add a new property to contracts/governance/src/governance_property_test.rs, e.g. prop_finalize_status_matches_decision_table, that generates random quorum, threshold_percent, and a small set of voter weights/directions, drives a proposal through create_proposalcast_vote (using set_balance to give voters real, current-model balances) → advance ledger time past voting_endfinalize_proposal, and asserts the resulting ProposalStatus matches the three-way decision table already documented in finalize_proposal's rustdoc in lib.rs (Failed if under quorum, Passed/Rejected split on threshold_percent otherwise).
  • Add a second property asserting cast_vote's weight-resolution rule from its own rustdoc: a voter with nonzero get_vote_power votes with that value, and only falls back to raw get_balance when vote power is exactly zero.

Test and Commit

Run cargo test --lib (and cargo test for proptest/fuzz targets where relevant) in the appropriate contracts/<governance|token-factory> directory, confirming the new coverage passes and cargo build --target wasm32v1-none --release --lib still succeeds.

Example Commit Message

test(contract): add proposal-lifecycle proptests to governance_property_test

Closes #<issue>

Guidelines

  • Branch from main, open a PR back to main
  • All new code must have corresponding tests
  • Run cargo fmt --check, cargo clippy, and cargo test --lib before pushing
  • Follow existing naming conventions and file structure
  • PR description must reference this issue number (e.g., Closes #<issue>)
  • Keep commits atomic and use conventional commit format

Activity

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

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcontractSoroban smart contract worktestingTesting-focused contribution

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions