Skip to content

Add storage key XDR snapshot test (#331)#337

Open
legend-esc wants to merge 1 commit into
Stellar-split:mainfrom
legend-esc:issue-331-storage-snapshot
Open

Add storage key XDR snapshot test (#331)#337
legend-esc wants to merge 1 commit into
Stellar-split:mainfrom
legend-esc:issue-331-storage-snapshot

Conversation

@legend-esc

Copy link
Copy Markdown

Summary

Adds a snapshot test that serialises every storage key to XDR hex and compares against a committed baseline. Any accidental layout change (e.g. renamed symbol, added/removed field) fails CI, preventing silent data migrations.

Changes

New files

  • contracts/split/src/storage_snapshot.rs — snapshot test that serializes all 91 storage keys to XDR hex, asserts no collisions, and compares against the committed baseline
  • tests/snapshots/storage_keys.json — baseline snapshot with XDR hex for every key, sorted alphabetically

Modified files

  • contracts/split/src/lib.rs — added mod storage_snapshot in the cfg(test) block
  • .github/workflows/test.yml — added cargo test -p split storage_snapshot CI step
  • README.md — added "Storage Key Registry" section documenting the snapshot policy and how to update the baseline

Pre-existing fixes (included to unblock compilation)

Four bugs in lib.rs that prevented building were fixed:

  1. symbol_short!("arch_after")"arch_af" (10 chars exceeded 9-char max)
  2. Removed non-existent InvoiceExt2 fields (substitute_recipient_approvals, creation_timestamp, min_payment_increment)
  3. Removed duplicate code block in load_invoice causing unclosed delimiter
  4. Added missing closing brace for reveal_confidential_total function

Closes #331

- Add storage_snapshot.rs test that serializes every StorageKey
  variant to XDR hex and compares against committed baseline
- Create tests/snapshots/storage_keys.json baseline with all
  91 key XDR values, sorted alphabetically
- Collision check: no two keys produce identical XDR
- Add CI step: cargo test -p split storage_snapshot
- Add README Storage Key Registry section with policy docs
- Fix pre-existing compilation bugs blocking the build:
  - arch_after symbol too long (10 > 9) → arch_af
  - Remove non-existent InvoiceExt2 fields
  - Remove duplicate code block in load_invoice
  - Close unclosed reveal_confidential_total function
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@legend-esc 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.

Add contract storage layout snapshot test to detect breaking migrations

1 participant