Skip to content

Add a property test proving update_user_volume tier transitions are monotonic and never regress within a periodΒ #1737

Description

@Baskarayelu

πŸ“‹ Description

update_user_volume in fees.rs accumulates a user's transaction volume into UserVolumeData and drives their VolumeTier, which feeds get_tier_discount. The tier must be monotonic in accumulated volume β€” adding volume can only keep or raise the tier, never lower it within a period. This is not yet asserted as a property.

Why this matters: a non-monotonic tier would mean a user's fee discount could randomly drop after they transact more β€” a correctness and fairness bug. A property test over arbitrary volume sequences proves monotonicity holds.

🎯 Requirements & Context

  • Add quicklendx-contracts/src/test_volume_tier_monotonic.rs under fuzz-tests.
  • Property: applying a sequence of non-negative volume increments never lowers the resulting VolumeTier.
  • Property: get_tier_discount is non-decreasing as tier rises.
  • Property: tier boundaries are correct (just below vs just above each threshold).

Context & constraints

  • proptest 1.4; bound increments to avoid overflow-checks panics on accumulation.

πŸ› οΈ Suggested Execution

git checkout -b test/volume-tier-monotonic
cargo test -p quicklendx-contracts --features fuzz-tests test_volume_tier_monotonic -- --nocapture
cargo clippy -p quicklendx-contracts --all-targets -- -D warnings
  • Edge cases: increments of zero (no tier change); crossing exactly one threshold; saturating to the top tier.

Example commit message

test(fees): prove update_user_volume tier transitions are monotonic

Property test over arbitrary increment sequences asserting tier and discount
never regress.

βœ… Acceptance Criteria & Guidelines

Requirement Target
Tier + discount monotonicity asserted Required
Boundary correctness covered Required
Coverage of tier logic β‰₯ 95%
cargo clippy clean Required
Timeframe 96 hours from assignment

πŸ’¬ Community & Support

Join Discord: https://discord.gg/VpngvTjWa β€” comment to claim. πŸš€

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions