Skip to content

feat(tests): add storage TTL verification tests (#480)#602

Merged
Vera3289 merged 2 commits into
Vera3289:mainfrom
Philzwrist07:issue-480-storage-ttl-tests
Jun 27, 2026
Merged

feat(tests): add storage TTL verification tests (#480)#602
Vera3289 merged 2 commits into
Vera3289:mainfrom
Philzwrist07:issue-480-storage-ttl-tests

Conversation

@Philzwrist07

@Philzwrist07 Philzwrist07 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #480 Adds storage TTL verification tests for the governance and token contracts, confirming that
entries expire or persist according to Soroban TTL expectations across the proposal lifecycle.

Changes

contracts/governance/src/test_ttl.rs (new)

7 tests covering all three Soroban storage tiers:

┌───────────────────────────┬──────────────────┐
│ Test │ What it verifies │
├───────────────────────────┼───────────────────────────────────────────────────────┤
│ test_proposal_initial_ttl │ Proposal entry starts at │
│ │ min_persistent_entry_ttl - 1 │
├─────────────────────────────────────────────┼─────────────────────────────────────────────┤
│ test_proposal_persists_after_ledger_advance │ Proposal entry survives partial TTL │
│ │ consumption │
├─────────────────────────────────────────────┼─────────────────────────────────────────────┤
│ test_has_voted_initial_ttl │ HasVoted entry gets the correct initial │
│ │ persistent TTL │
├─────────────────────────────────────────────┼─────────────────────────────────────────────┤
│ test_instance_initial_ttl │ Instance storage (Admin, VotingToken, │
│ │ ProposalCount) starts at correct TTL │
├─────────────────────────────────────────────┼─────────────────────────────────────────────┤
│ test_instance_persists_after_ledger_advance │ Instance storage remains accessible after │
│ │ ledger advancement │
├─────────────────────────────────────────────┼─────────────────────────────────────────────┤
│ test_temporary_allowance_expires │ Token allowance (temporary storage) reads 0 │
│ │ TTL elapses │
├───────────────────────────────────┼──────────────────────────────────────────────────────┤
│ test_proposal_accessible_thr │ Proposal persistent entry survives Active → Passed → │
│ ough_full_lifecycle │ Executed │
└───────────────────────────────────┴──────────────────────────────────────────────────────┘

Each test sets explicit min_persistent_entry_ttl / min_temp_entry_ttl values so assertions are
deterministic and independent of network defaults.

docs/adr/ADR-006-storage-ttl-patterns.md (new)

Documents the storage tier assignment for every entry in both contracts, expected TTL behaviour
per tier, and guidance for operators on extending TTLs in production.

contracts/governance/src/lib.rs — wires in mod test_ttl under #[cfg(test)]

docs/adr/README.md / README.md — ADR-006 added to index tables

Testing

Tests use env.ledger().with_mut(|l| l.sequence_number += N) to simulate ledger advancement and
env.as_contract(...) + get_ttl (Soroban SDK v21+) to assert TTL values directly.

Kiro and others added 2 commits June 26, 2026 21:45
- Add test_ttl.rs with 7 tests covering persistent, instance, and
  temporary storage TTL behaviour in the governance contract
- Tests verify initial TTL values match min_persistent/temp_entry_ttl
- Tests confirm proposal and HasVoted entries survive ledger advancement
- Tests confirm temporary allowance entry expires after TTL elapses
- Tests confirm proposal data is accessible through full voting lifecycle
- Wire test_ttl module into lib.rs
- Add ADR-006 documenting storage TTL patterns across both contracts
- Update ADR index and README
@Vera3289 Vera3289 self-requested a review as a code owner June 27, 2026 12:46
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Philzwrist07 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

@Vera3289 Vera3289 merged commit 84c4904 into Vera3289:main Jun 27, 2026
3 of 10 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.

Smart Contracts: Add storage TTL verification tests

2 participants