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
Description
contracts/governance/src/vote_accounting_test.rs— containing proptestsproperty_one_vote_per_address,property_monotonic_vote_totals,property_quorum_threshold_outcomes,property_total_equals_sum, plus aunit_testssubmodule — is, liketest.rs, not declared via anymodstatement incontracts/governance/src/lib.rs, so none of it compiles or runs. Yetcontracts/governance/test_snapshots/vote_accounting_test/**(proptest regression snapshots for all four properties and all fourunit_testsfunctions) andcontracts/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-argumentclient.initialize(&token_address)call, incompatible with the currentinitialize(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
GovernanceContract's current public API — update the orphaned test file to match it.proptest-regressions/vote_accounting_test.txtmust continue to be honored (proptest reads it automatically once the module is wired back in) rather than deleted.Suggested Execution
Branch:
test/revive-vote-accounting-testImplement Changes
setup_test_contract()incontracts/governance/src/vote_accounting_test.rsto call the currentinitialize(admin, total_supply)and adopt theset_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 currentstorage.rsbehavior.test_zero_balance_voting_rejectedno-op stub in theunit_testssubmodule with a real assertion: give a voter a0balance viaset_balanceand asserttry_cast_votereturnsVoteError::InsufficientBalance.#[cfg(test)] mod vote_accounting_test;tocontracts/governance/src/lib.rs.proptest-regressions/vote_accounting_test.txtpresent, 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(andcargo testfor proptest/fuzz targets where relevant) in the appropriatecontracts/<governance|token-factory>directory, confirming the new coverage passes andcargo build --target wasm32v1-none --release --libstill succeeds.Example Commit Message
Guidelines
main, open a PR back tomaincargo fmt --check,cargo clippy, andcargo test --libbefore pushingCloses #<issue>)