Skip to content

Property-based testing with proptest #299

Description

@mroczect

Summary

Add property-based testing using the proptest crate to validate core invariants and round-trip behavior of key components.

Context

Property tests complement unit tests by generating many random inputs and checking universal properties. This is especially valuable for serialization, hashing, and graph traversal.

Tasks

  • Add proptest as a dev-dependency to libvctrl_core, libvctrl_plumbing, or a dedicated test crate.
  • Write property tests for:
    • Encoder/Decoder round-trip: for any generated Commit, Tree, Tag, Blob, encoding then decoding yields the original value.
    • Hasher idempotence: hashing the same data twice yields the same hash; hashing different data yields different hashes (with high probability).
    • RevWalk traversal: for any generated graph, BFS and DFS visits all nodes exactly once; topological order respects dependencies.
  • Ensure tests are deterministic and fast enough for CI.
  • Add documentation explaining the properties.

Acceptance Criteria

  • cargo test includes property tests that pass.
  • The properties cover at least encoder/decoder and hasher.

Dependencies

  • Core implementations (Fase 2) and plumbing functions (Fase 3).

Metadata

Metadata

Assignees

Labels

proptestSee issues with this labeltestingSee issues with this label

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions