feat(test): add deterministic test harness and swap_invariant example…#112
Merged
Merged
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.
Summary
Closes #8
Adds a
test-determinismfeature gate and a reusableTestHarnessthat provides deterministic ledger timestamps, event tracing, and Jest-style timing artifacts in CI.Changes
peerx-contracts/counter/Cargo.tomlAdded
test-determinism = []feature flag.peerx-contracts/counter/src/test_harness.rs(new)TestHarnessstruct with:1_700_000_000and sequence to 1 for bit-for-bit reproducibilityset_timestamp(ts)– advance the ledger mid-test (samewith_mutpattern fromrate_limit.rs)with_event_trace(f)– captures all Soroban events emitted duringf, so failing assertions can be tied to a specific event sequencegenerate_address()– convenience wrapper forAddress::generateDrop, writes$CARGO_TARGET_TMPDIR/timing/<name>.json(Jest-style)peerx-contracts/counter/src/lib.rsRegistered
mod test_harnessbehind#[cfg(all(test, feature = "test-determinism"))].peerx-contracts/counter/src/invariants.rsAdded
swap_invarianttest demonstrating the harness: happy path, timestamp determinism, event tracing (no-op + mint), and invariant verification.Acceptance Criteria
CARGO_TARGET_TMPDIR/timing) are publishedswap_invariantexample test demonstrates the harnessVerification
Cargo.tomlpasses TOML validation