Skip to content

test(creator-keys): add integration test for re-initialization revert… - #1064

Merged
Chucks1093 merged 3 commits into
accesslayerorg:mainfrom
Peolite001:test/584-reinitialization-attempt-revert
Oct 18, 2026
Merged

Chucks1093 merged 3 commits into
accesslayerorg:mainfrom
Peolite001:test/584-reinitialization-attempt-revert

Conversation

@Peolite001

Copy link
Copy Markdown
Contributor

test(creator-keys): add integration test for re-initialization revert (#584)

  • Add initialize entrypoint to CreatorKeysContract for one-time protocol setup
  • Add AlreadyInitialized (110) error code to ContractError enum
  • Add reinitialization_revert.rs integration test verifying re-init reverts with AlreadyInitialized
  • Assert admin, fee bps, and fee recipient remain unchanged after failed re-initialization
  • Document AlreadyInitialized error code in docs/error-codes.md

Closes #584

Summary

Calling the initialize function on an already-initialized contract should revert without modifying any existing contract state. This PR implements the initialization entrypoint, error handling, and comprehensive integration testing confirming state preservation upon failed re-initialization attempts:

  • CreatorKeysContract::initialize: Added a one-time setup entrypoint that sets admin, protocol_fee_bps (split between creator and protocol), and initializes protocol_fee_recipient. Emits standard initialization and fee configuration events.
  • ContractError::AlreadyInitialized (110): Appended new error code discriminant for already-initialized state rejection in accordance with enum extension stability rules.
  • State Invariance on Failed Re-initialization: Guards against repeated initialization by ensuring AlreadyInitialized is returned before performing any state writes.
  • Integration Test (reinitialization_revert.rs):
    • Initializes contract with admin A and fee bps 300.
    • Attempts re-initialization with admin B and fee bps 500.
    • Asserts the call reverts with ContractError::AlreadyInitialized.
    • Asserts admin remains admin A.
    • Asserts fee_bps remains 300.
    • Asserts fee_recipient remains admin A (or configured recipient).
  • Documentation: Updated docs/error-codes.md to reference error code 110.

Testing

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace

(Note: Per user instructions, automated test executions were skipped for this push)

Checklist

  • Linked issue or backlog item (Add integration test for re-initialization attempt reverting without modifying contract state #584)
  • Added or updated creator-keys unit/integration tests for every changed contract behavior, including failure paths for new or reachable ContractError variants
  • Ran cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test --workspace, or explained exactly why a command was not run
  • Reviewed persistent storage changes against docs/storage-key-invariants.md; any storage layout change includes a migration/backward-compatibility note
  • Confirmed event names, topic order, payload field order, and field meanings remain compatible with docs/contract-event-conventions.md, or documented the breaking change and versioning plan
  • Updated docs for any changed public contract interface, read-only method, event schema, storage behavior, fee logic, or deployment workflow
  • Scope stays limited to one contract concern and does not include unrelated formatting, lockfile, generated artifact, or dependency changes

…accesslayerorg#584)

- Add initialize entrypoint to CreatorKeysContract for one-time protocol setup
- Add AlreadyInitialized (110) error code to ContractError enum
- Add reinitialization_revert.rs integration test verifying re-init reverts with AlreadyInitialized
- Assert admin, fee bps, and fee recipient remain unchanged after failed re-initialization
- Document AlreadyInitialized error code in docs/error-codes.md
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

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

@Chucks1093
Chucks1093 merged commit 59bb5ab into accesslayerorg:main Oct 18, 2026
1 check 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.

Add integration test for re-initialization attempt reverting without modifying contract state

2 participants