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
Conversation
…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.
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. |
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.
Contributor
Author
|
Everything is now properly implemented |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #709
Important scope note
Issue #709 references a
RESTORINGlifecycle, archive manifest, andstate_restoringerror 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 toActivearchive_creator,begin_creator_restore,complete_creator_restore, plus indexer-friendlyget_creator_lifecycleread viewContractErrorper the repo's ABI stability rules:CreatorArchived = 38,StateRestoring = 39,InvalidLifecycleTransition = 40buy_key,sell_key,buyback) are gated whileArchived/Restoring; read-only views intentionally keep serving current values during the windowarchived,restoring,restored(single creator topic), following existing conventionsdocs/error-codes.md: rows added for codes 34–40Coverage vs acceptance criteria
archive_creatorthenbegin_creator_restore(strict state machine: invalid transitions rejected withInvalidLifecycleTransition)get_buy_quote(price) andget_key_balance(balance) return current values mid-restorationstate_restoringduring RESTORING — reverts withContractError::StateRestoring; supply/balance unchanged; sell is gated identicallybuy_keyaftercomplete_creator_restoresucceedsAlso 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 ✅