property-based-testing
Guidance for implementing property-based testing (PBT) in software and smart contract development to improve code reliability and uncover edge-case bugs.
Introduction
This skill provides a systematic framework for integrating property-based testing (PBT) into development workflows. It is designed for software engineers and security researchers who need to verify critical code logic such as serialization, data parsing, complex algorithms, and smart contract state invariants. By shifting from example-based testing to property-based testing, users can leverage automated input generation to identify edge cases that traditional manual test suites often overlook. The skill guides you through selecting appropriate properties—such as roundtrip, idempotence, commutativity, and associativity—to validate functional correctness across multiple languages and protocols.
-
Automated detection of high-value testing patterns including serialization pairs (encode/decode), parsers, normalizers, and custom data structure operations.
-
Comprehensive property catalog featuring formal definitions and usage contexts for roundtrip testing, oracle-based verification, and state invariant checks in Solidity or Vyper contracts.
-
Integration with popular PBT libraries such as Hypothesis, fast-check, proptest, and Echidna to streamline the implementation of automated test generators.
-
Proactive decision-making support that helps determine when PBT is the optimal approach versus when example-based tests are sufficient for the task at hand.
-
Refactoring guidance for improving testability in codebases that contain mixed I/O or lack clear inverse operations.
-
Invoke this skill when implementing serialization logic (e.g., toJSON/fromJSON), protocol parsers, or security-sensitive smart contract invariants.
-
Follow the provided decision tree to navigate tasks from test generation and feature design to interpreting failure logs and selecting libraries.
-
Adhere to the strength hierarchy (No Exception → Type Preservation → Invariant → Idempotence → Roundtrip) to ensure tests provide maximum coverage.
-
Avoid using this skill for simple CRUD operations, integration testing, or code with non-deterministic side effects that cannot be isolated.
-
Prioritize HIGH-value targets like cryptographic functions, canonicalization routines, and state-changing entry points in decentralized applications.
Repository Stats
- Stars
- 4,857
- Forks
- 421
- Open Issues
- 29
- Language
- Python
- Default Branch
- main
- Sync Status
- Idle
- Last Synced
- Apr 28, 2026, 01:08 PM