add state-machine tests and fuzz harness for lifecycle/payout invariants#130
Open
Adeolu01 wants to merge 1 commit into
Open
add state-machine tests and fuzz harness for lifecycle/payout invariants#130Adeolu01 wants to merge 1 commit into
Adeolu01 wants to merge 1 commit into
Conversation
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.
Add deterministic state-machine tests and proptest fuzz harness for lifecycle and payout invariants
closes #103
closes #102
Changes
contracts/src/tests/state_machine_tests.rs (new)
Introduces a 34-test state-machine suite that documents the full protocol
transition graph as inline comments and encodes every edge as a concrete test.
Allowed transitions covered (both UpDown and Precision modes):
Rejected transitions (each asserts the exact error variant):
Regression cases included: sequential round-id monotonicity, cross-round nonce
scope, and precision mode full lifecycle.
contracts/src/tests/fuzz_harness.rs (new)
Adds 8 proptest suites (64–256 cases each by default; overridable via
PROPTEST_CASES) covering five encoded invariants:
Additional fuzz scenarios:
contracts/src/tests/mod.rs
Registers fuzz_harness and state_machine_tests modules.
contracts/src/tests/cost_benchmarks.rs
Fixes a pre-existing compiler error (let → let mut for Budget variable).
.github/workflows/ci.yml
Adds a fuzz-harness CI job that runs the harness with PROPTEST_CASES=256 and
PROPTEST_DISABLE_FAILURE_PERSISTENCE=true for deterministic, bounded CI
execution. The job is wired into ci-success so a fuzz regression blocks merge.
Run the fuzz harness locally with more cases:
PROPTEST_CASES=512 cargo test --package xelma-contract fuzz_harness -- --nocapture