Repository navigation
Report contract state before a failure with --snapshot - #277
Open
DicksonWu654 wants to merge 1 commit into
Open
DicksonWu654 wants to merge 1 commit into
DicksonWu654 wants to merge 1 commit into
Conversation
Add opt-in --snapshot (config key `snapshot`). When a run fails, reset the session, replay the same seed up to the first failing run, and print the target contract's data variables before each call of that run. Passing runs do no extra work, as suggested in the issue, and nothing changes without the flag. If the replay does not fail at the same run, no state is reported. Refs stx-labs#145. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Context
When an invariant fails in a stateful run, the shrunk counterexample shows the
calls but not the contract state that led to the failure, which makes the cause
hard to see. #145 asks for exactly this.
This implements #145 the way it was suggested in the issue: instead of
taking a snapshot on every run, Rendezvous replays the failing seed and
reads the state only after a failure.
With the opt-in
--snapshotflag (config keysnapshot), when a run failsRendezvous:
run (stopping there, without shrinking or output), and
run, with the block heights:
For property tests the state is read right before the failing test function
is called. For invariant tests it is read before each public function call
of the failing run and before the invariant check, so the state changes can
be followed.
Cost: passing runs make no extra simnet calls and nothing is replayed. After
a failure, the replay runs the seed once more up to the failing run and
reads the variables only in that run. Without
--snapshot, nothing changes.Scope and limits:
define-data-var) are shown,as Clarity values. Maps cannot be enumerated through the SDK; constants,
token balances and other contracts are out of scope.
--bail, this is the run in the failure report; without it, the reportedcounterexample may be a shrunk version of that run.
behaves differently), Rendezvous says so and reports no state. A read
error is reported instead of the state and does not change the replay.
--regrtogether with--snapshotreports the state for each failingregression.
Tests cover the recorder (only the target run is read, data variables only,
read errors are kept), the reporter (no replay for passing runs, no state on
a mismatched replay or read error), end-to-end property and invariant
failures in a temporary project (exact values before each call, no duplicate
regression record), and that passing runs and runs without the flag print no
state. The README and the Usage chapter document the option, config key and
output.
🤖 Generated with Claude Code