Description
A silent rename of a storage key in src/storage.rs would orphan all existing data on a deployed contract. Add a snapshot test that serializes every storage-key constructor (InvoiceStorage::invoices_by_business, BidStorage::bids_by_invoice, etc.) for a fixed canonical input set and asserts the resulting key bytes against a committed snapshot. Any key drift becomes a deliberate, reviewable change.
Requirements and context
- Secure: snapshot deletions require admin review; renames force a migration plan.
- Tested: snapshot covers every public key-builder in
src/storage.rs.
- Documented:
docs/storage-key-stability.md.
- Reference:
src/storage.rs.
Suggested execution
git checkout -b feature/storage-key-snapshot
- Add
src/test_storage_key_layout.rs enumerating key builders.
- Persist snapshot under
src/test_snapshots/storage_keys.txt.
- Docs:
docs/storage-key-stability.md describing migration policy.
- Rust doc
/// comments on the key builders noting "BREAKING: rename requires migration".
- Validate that persistent vs instance vs temporary storage classes are tagged.
Test and commit
Run cargo test test_storage_key_layout. Cover edge cases for every storage class. Include security note about data orphaning risk.
Example commit message
test(storage): add storage-key layout snapshot to prevent silent migrations
Guidelines
- Minimum 95% test coverage
- Clear documentation in
docs/storage-key-stability.md
- Timeframe: 96 hours
Description
A silent rename of a storage key in
src/storage.rswould orphan all existing data on a deployed contract. Add a snapshot test that serializes every storage-key constructor (InvoiceStorage::invoices_by_business,BidStorage::bids_by_invoice, etc.) for a fixed canonical input set and asserts the resulting key bytes against a committed snapshot. Any key drift becomes a deliberate, reviewable change.Requirements and context
src/storage.rs.docs/storage-key-stability.md.src/storage.rs.Suggested execution
git checkout -b feature/storage-key-snapshotsrc/test_storage_key_layout.rsenumerating key builders.src/test_snapshots/storage_keys.txt.docs/storage-key-stability.mddescribing migration policy.///comments on the key builders noting "BREAKING: rename requires migration".Test and commit
Run
cargo test test_storage_key_layout. Cover edge cases for every storage class. Include security note about data orphaning risk.Example commit message
test(storage): add storage-key layout snapshot to prevent silent migrationsGuidelines
docs/storage-key-stability.md