Skip to content

Add integration test for the contract correctly restoring a creator's state after a RESTORING lifecycle transition - #715

Open
devJaja wants to merge 3 commits into
accesslayerorg:mainfrom
devJaja:feat/creator-restoring-lifecycle-709
Open

Add integration test for the contract correctly restoring a creator's state after a RESTORING lifecycle transition#715
devJaja wants to merge 3 commits into
accesslayerorg:mainfrom
devJaja:feat/creator-restoring-lifecycle-709

Conversation

@devJaja

@devJaja devJaja commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Closes #709

Important scope note

Issue #709 references a RESTORING lifecycle, archive manifest, and state_restoring error that did not exist anywhere in this codebase. Following the precedent of feature+test contributions (e.g. #702 for the wallet blacklist), this PR implements the minimal lifecycle surface the issue's acceptance criteria require, then tests it.

Feature surface (minimal, ABI-safe)

  • CreatorLifecycleState (Active/Archived/Restoring) stored per creator; absent entries default to Active
  • Protocol-admin entrypoints: archive_creator, begin_creator_restore, complete_creator_restore, plus indexer-friendly get_creator_lifecycle read view
  • Error codes appended at the end of ContractError per the repo's ABI stability rules: CreatorArchived = 38, StateRestoring = 39, InvalidLifecycleTransition = 40
  • Trading entrypoints (buy_key, sell_key, buyback) are gated while Archived/Restoring; read-only views intentionally keep serving current values during the window
  • Events: archived, restoring, restored (single creator topic), following existing conventions
  • docs/error-codes.md: rows added for codes 34–40

Coverage vs acceptance criteria

  • Transition a creator's archive manifest to RESTORING statearchive_creator then begin_creator_restore (strict state machine: invalid transitions rejected with InvalidLifecycleTransition)
  • Read calls succeed during RESTORINGget_buy_quote (price) and get_key_balance (balance) return current values mid-restoration
  • Buy panics with state_restoring during RESTORING — reverts with ContractError::StateRestoring; supply/balance unchanged; sell is gated identically
  • Buy succeeds immediately after restoration completes — the very next buy_key after complete_creator_restore succeeds
  • Restored state matches pre-archive values — snapshot equality for supply/holder count/balance plus fee balance and handle

Also covered: non-admin rejection (Unauthorized), archiving unregistered creators (NotRegistered), archived-state gating (CreatorArchived), and one event emitted per lifecycle transition.

Verification

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace — all 164 test binaries pass ✅

…ccesslayerorg#709)

Introduce the minimal lifecycle surface issue accesslayerorg#709 tests against:
- CreatorLifecycleState (Active/Archived/Restoring) stored per creator,
  absent entries default to Active
- protocol-admin entrypoints: archive_creator, begin_creator_restore,
  complete_creator_restore plus get_creator_lifecycle read view
- appended ABI-safe error codes: CreatorArchived (38), StateRestoring (39),
  InvalidLifecycleTransition (40)
- buy/sell/buyback gated while Archived or Restoring; reads keep serving
  current values during the RESTORING window
- archived/restoring/restored events following repo event conventions
- docs/error-codes.md rows for codes 34-40

Integration test drives a creator through Archived -> Restoring -> Active
and asserts reads succeed mid-restoration, buys panic with StateRestoring,
trades resume immediately after completion, and restored state matches the
pre-archive snapshot.
@Chucks1093

Copy link
Copy Markdown
Member

The strict state machine approach here is solid. Gating buy and sell during both Archived and Restoring while keeping read only views like get_buy_quote and get_key_balance open means frontends can still show accurate data without triggering transactions during a sensitive window. The snapshot equality check after complete_creator_restore is also a strong guarantee to have locked in with a test.

devJaja and others added 2 commits August 24, 2026 19:57
The merge of main (3d7659d) kept SchemaVersionTooOld = 38 and
SchemaVersionUnsupported = 39 but dropped CreatorArchived,
StateRestoring, and InvalidLifecycleTransition while leaving their
usages intact, breaking compilation.

Re-append the lifecycle errors as codes 40-42 per the ABI stability
rules, renumber the docs table rows accordingly, and document main's
previously undocumented schema version errors.
@devJaja

devJaja commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@Chucks1093

Everything is now properly implemented

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 integration test for the contract correctly restoring a creator's state after a RESTORING lifecycle transition

2 participants