Skip to content

Recover a Proptest Suite Stranded Outside the Module Tree With an Orphaned Regression Seed #1828

Description

@Emmyt24

Description

contracts/governance/src/vote_accounting_test.rs — containing proptests property_one_vote_per_address, property_monotonic_vote_totals, property_quorum_threshold_outcomes, property_total_equals_sum, plus a unit_tests submodule — is, like test.rs, not declared via any mod statement in contracts/governance/src/lib.rs, so none of it compiles or runs. Yet contracts/governance/test_snapshots/vote_accounting_test/** (proptest regression snapshots for all four properties and all four unit_tests functions) and contracts/governance/proptest-regressions/vote_accounting_test.txt (a saved shrunk failure seed, weight = 1, in_favor = false) both still exist in the repo, confirming this module previously ran and found a real regression case that is now silently un-guarded. The file also uses the stale single-argument client.initialize(&token_address) call, incompatible with the current initialize(admin, total_supply) API, and one of its own unit tests (test_zero_balance_voting_rejected) is a literal no-op stub with a comment saying it's "skipped because our mock always returns 1000."

Requirements and Context

  • Must not change GovernanceContract's current public API — update the orphaned test file to match it.
  • The existing saved regression seed in proptest-regressions/vote_accounting_test.txt must continue to be honored (proptest reads it automatically once the module is wired back in) rather than deleted.
  • New/updated tests must be deterministic and reproducible.

Suggested Execution

Branch: test/revive-vote-accounting-test

Implement Changes

  • Update setup_test_contract() in contracts/governance/src/vote_accounting_test.rs to call the current initialize(admin, total_supply) and adopt the set_balance-based balance model the rest of the crate (e.g. governance_property_test.rs) already uses, since the old mock-balance assumption ("storage.rs returns a fixed balance of 1000") no longer reflects current storage.rs behavior.
  • Replace the test_zero_balance_voting_rejected no-op stub in the unit_tests submodule with a real assertion: give a voter a 0 balance via set_balance and assert try_cast_vote returns VoteError::InsufficientBalance.
  • Add #[cfg(test)] mod vote_accounting_test; to contracts/governance/src/lib.rs.
  • Run the proptests locally first with the existing seed in proptest-regressions/vote_accounting_test.txt present, to confirm the previously-found regression case still passes against current logic (or, if it now legitimately fails, document why in the PR rather than deleting the seed).

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): revive orphaned vote_accounting_test proptest module

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

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