Skip to content

fix(contract): make storage TTL tests assert real TTL, not record pre… - #346

Merged
MaryammAli merged 1 commit into
BlockDash-Studios:mainfrom
Alanwiz00:feat/TTL-expiration-behaviour
Jul 26, 2026
Merged

fix(contract): make storage TTL tests assert real TTL, not record pre…#346
MaryammAli merged 1 commit into
BlockDash-Studios:mainfrom
Alanwiz00:feat/TTL-expiration-behaviour

Conversation

@Alanwiz00

Copy link
Copy Markdown
Contributor

Summary

  • Added test-only TTL utilities that use Soroban's real storage TTL APIs (get_ttl) and ledger sequence numbers, replacing timestamp-based assumptions with deterministic TTL assertions.
  • Reworked the escrow and privacy TTL tests to verify actual TTL behaviour, including decay over time, extension on activity, and expiry behaviour in the local Soroban test environment.
  • Clarified the distinction between business-level expiry (expires_at) and storage-layer TTL in the contract types and documentation.
  • Updated the project documentation to explain why storage TTL is driven by ledger sequence numbers rather than timestamps, and documented the local sandbox's auto-restore behaviour for expired persistent entries.

Linked Issue

Validation

  • cargo test -p rust_academy --lib passes (349/349)
  • New behaviour is covered by tests
  • Documentation updated to reflect the verified TTL semantics

Notes

The previous TTL tests advanced env.ledger().set_timestamp(), which does not affect Soroban storage TTL. As a result, they could pass without exercising the TTL implementation. This PR replaces those implicit assumptions with deterministic assertions based on the storage API and ledger sequence numbers, making the tests accurately reflect the contract's TTL behaviour in the Soroban test environment.

@MaryammAli MaryammAli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MaryammAli
MaryammAli merged commit 3c397f7 into BlockDash-Studios:main Jul 26, 2026
2 checks passed
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.

TTL expiration behavior is only simulated in tests and not reflected by contract storage assertions

2 participants