fix(#461): add regression tests for verify_with_votes overflow handling - #729
fix(#461): add regression tests for verify_with_votes overflow handling#729OpensrcLord wants to merge 5 commits into
Conversation
… handling The checked_add guards in verify_with_votes are already in place; these tests lock in the behavior so vote-count and token-weight aggregation return Error::Overflow instead of silently wrapping on i128/u32 overflow.
|
@OpensrcLord 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! 🚀 |
PR Iris-IV#618 accidentally added a draft snippet as src/campaigns.rs, which duplicates the real src/campaigns/mod.rs. Rust (E0761) and rustfmt both reject resolving `mod campaigns` to two files, breaking every CI run. The category-cap feature it sketches is implemented in src/admin.rs.
PR Iris-IV#618 left src/admin.rs and src/lib.rs failing `cargo fmt --all -- --check` (import ordering, missing trailing newlines). Format them so the fmt CI gate passes; also collapse the storage import in the new test file.
PR Iris-IV#618 added duplicate #[contract] ProofOfHeartContract blocks to src/lib.rs and src/admin.rs alongside the real ProofOfHeart contractimpl. They reference symbols that do not exist (campaign.tags, DataKey::Campaigns, DataKey::CategoryMaxGoalCap, Self::verify_admin) and duplicate the soroban generated modules, breaking the build (E0252/E0428/E0433/E0609) for every PR against main. Remove them so the crate compiles again.
Iris-IV#510 changed the campaign_metadata_updated event payload from (new_title, new_description) to (old_title, old_description, new_title, new_description) for indexers. Two tests in test_campaign_update still unpacked the old 2-tuple, causing UnexpectedSize host errors. Update them to the 4-tuple.
|
solid regression coverage. both tests directly seed the aggregate counters via
gate: branch is DIRTY against main, so please resolve conflicts and rebase; after that this is good to merge from my side. |
Summary
Fixes #461
The checked-arithmetic fix for
verify_with_voteswas already in place — both aggregations usechecked_add(...).ok_or(Error::Overflow)?:src/voting.rs—approve_votes + reject_votes(vote-count total)src/voting.rs—approve_weight + reject_weight(token-weighted total)This PR adds regression tests to lock in that behavior so aggregation returns
Error::Overflowinstead of silently wrapping onu32/i128overflow:test_verify_with_votes_count_overflow_returns_overflow— forcesapprove_votes + reject_votespastu32::MAXtest_verify_with_votes_weight_overflow_returns_overflow— forcesapprove_weight + reject_weightpasti128::MAXTest plan
cargo test --features testutils(CI runs this)