Add proptest fuzz suite for reputation & score arithmetic (closes #833) - #909
Open
p4uld4vid016-code wants to merge 2 commits into
Open
Add proptest fuzz suite for reputation & score arithmetic (closes #833)#909p4uld4vid016-code wants to merge 2 commits into
p4uld4vid016-code wants to merge 2 commits into
Conversation
…ollback Voting posts to the backend and waits for the on-chain result, which takes seconds. The card gave no feedback for that whole window, so the vote button read as broken and invited double-clicks. Apply the vote optimistically on click: the reputation number updates instantly, a pending "casting vote" row appears, and the controls are disabled until the real result arrives. The optimistic value is then reconciled with the server-confirmed reputation, or rolled back with an explanation when the vote fails. The artificial 1.5s settle delay is removed since pending state now spans the actual request. Closes Stellar-Ecosystem#837 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
…llar-Ecosystem#833) Extract the pure scoring/reputation arithmetic out of the contracts so it can be property-tested directly: - agents: score_after_success/failure/flag, clamped to [0, MAX_SCORE], using saturating arithmetic so the bounds hold for every i32 input (the previous inline math could overflow at extremes and only clamped one side). - registry: reputation_after_vote clamped to [MIN_REPUTATION, MAX_REPUTATION]. Add proptest suites in both crates asserting: score/reputation stays within bounds for all generated inputs, repeated failures/flags/negative votes never underflow, and repeated successes/positive votes never exceed the ceiling. proptest is wired in as a dev-dependency and overflow-checks stay on for the test profile. Fixes Stellar-Ecosystem#833. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@p4uld4vid016-code 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! 🚀 |
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Summary
Adds a proptest-based fuzz suite for the reputation/scoring arithmetic, closing #833.
The score and reputation updates used inline, hand-tuned clamps — exactly where
integer overflow and sign errors hide, and only verified against a few
hand-picked values. This extracts the arithmetic into pure helpers and
property-tests them across the full
i32domain.Changes
contract/agents/src/lib.rsscore_after_success,score_after_failure, andscore_after_flagfrom
record_payment/flag_agent.[0, MAX_SCORE], sothe bounds hold for every
i32input — the previous math could overflowat
i32extremes and only clamped one side.mod proptestsasserting:[MIN_SCORE, MAX_SCORE]after any outcomeMAX_SCOREscore + deltanever overflowsi32contract/src/lib.rsreputation_after_votefromupdate_reputation.+1/-1clamped to[MIN_REPUTATION, MAX_REPUTATION].mod proptestsasserting:MAX_REPUTATIONMIN_REPUTATIONi32contract/Cargo.toml,contract/agents/Cargo.tomlproptestas a dev-dependency.overflow-checks = trueon the test profile so any hidden overflow iscaught by the fuzz tests instead of silently wrapping.
Verification
cargo +1.88 testpasses incontract/andcontract/agents/(39 and 23 tests incl. proptests).cargo teststeps.Closes #833