Skip to content

feat(stellar): add differential test harness for stealth-registry vs reference impl#142

Open
Tenny150 wants to merge 1 commit into
wraith-protocol:developfrom
Tenny150:feat/differential-test-stealth-registry
Open

feat(stellar): add differential test harness for stealth-registry vs reference impl#142
Tenny150 wants to merge 1 commit into
wraith-protocol:developfrom
Tenny150:feat/differential-test-stealth-registry

Conversation

@Tenny150

Copy link
Copy Markdown

Summary

Closes #110

Adds a property-based differential test comparing the on-chain stealth-registry Soroban contract against a pure-Rust reference implementation.

Changes

New files

stellar/stealth-registry/tests/reference/mod.rs — Pure-Rust reference implementation

  • Models all contract operations: Register, Remove, Lookup, AdvanceLedger
  • Faithfully models Soroban TTL semantics (extend threshold, expiry)
  • Tracks application-level events (Register, Remove)
  • Includes 8 comprehensive unit tests
  • Documented as normative specification for expected on-chain behavior

stellar/stealth-registry/tests/differential.rs — Proptest differential test

  • Generates random sequences of Register/Remove/Lookup operations (weighted 5:2:4)
  • Executes each operation against both on-chain contract AND reference impl
  • Asserts identical per-operation results including return values and error codes
  • Asserts identical final state across all touched (registrant, scheme_id) pairs
  • Respects WRAITH_PROPTEST_CASES env var (default 1024, nightly 16384)

Modified files

  • .gitignore: Anchored reference/ pattern to root only, added patterns for test_snapshots/ and proptest-regressions/

Design Decisions

  • AdvanceLedger excluded from proptest strategies due to Soroban SDK TTL invariants in the test environment. TTL expiration is modeled in the reference unit tests.
  • Event comparison deferred to existing properties.rs tests. The reference tracks events internally for documentation and future use.
  • Snapshot suppression via EnvTestConfig { capture_snapshot_at_drop: false } matching the existing properties.rs pattern.

Test Results

cargo test -p stealth-registry
# 34 passed, 0 failed, 3 ignored
# (audit: 4, differential: 11, properties: 6, registry: 6, upgrade_auth: 7)

Acceptance (from #110)

  • Reference impl under stealth-registry/tests/reference/
  • proptest generator emits sequences of ops; runs both, asserts identical final state
  • Cover: register, revoke, expire, re-register
  • cargo test --test differential passes with 1024 cases
  • Reference impl documented as normative for expected semantics
  • Failures print a minimized reproduction (proptest built-in)

…reference impl

Adds a property-based differential test comparing the on-chain
stealth-registry contract against a pure-Rust reference implementation.

- reference/mod.rs: normative reference impl with TTL model, event
  tracking, and 8 unit tests covering register/remove/lookup/expiry
- differential.rs: proptest harness generating random op sequences,
  asserting identical per-operation results and final state
- Uses WRAITH_PROPTEST_CASES env var (default 1024, nightly 16384)
- Excludes TTL expiration from proptest strategies (Soroban SDK
  invariant); modelled in reference unit tests
- Updates .gitignore: anchors reference/ to root, adds test_snapshots
  and proptest-regressions patterns

Closes wraith-protocol#110
@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@Tenny150 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Differential test harness: stealth-registry vs reference impl

1 participant