Skip to content

Add fuzz testing with property-based invariants #10

Description

@Prasiejames

Problem

Existing tests cover specific scenarios but do not explore the full state space. Critical invariants like "total supply always equals sum of all balances" or "dividend claims never exceed original amount" are not fuzzed.

Expected Behavior

A fuzz test harness that generates random sequences of operations and verifies invariants after each step.

Proposed Solution

Add a proptest or fuzz crate in the workspace that generates random command sequences:

enum FuzzOp {
    Mint(Address, i128),
    Transfer(Address, Address, i128),
    Approve(Address, Address, i128, u32),
    Burn(Address, i128),
    DistributeDividend(Address, i128),
    ClaimDividend(Address),
    SetPaused(bool),
    SetKycHook(Option<Address>),
    // ...
}

Invariants to verify after each step:

  • total_supply == sum of all balances
  • allowance <= max approved
  • dividend_remaining + claimed == original_amount
  • paused ? no transfers succeed : transfers may succeed
  • holding_limit never exceeded

Affected Files

  • New contracts/fuzz-tests/ or tests/fuzz/

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions