Skip to content

test: verify protocol initialisation sets and preserves all state fields - #729

Merged
Chucks1093 merged 8 commits into
accesslayerorg:mainfrom
mayborn005:fix/issue-723
Aug 25, 2026
Merged

test: verify protocol initialisation sets and preserves all state fields#729
Chucks1093 merged 8 commits into
accesslayerorg:mainfrom
mayborn005:fix/issue-723

Conversation

@mayborn005

Copy link
Copy Markdown

Closes #723

What

Unit tests confirming every protocol state field is readable immediately after contract initialisation, and that re-initialisation cannot corrupt state.

Issue-to-API mapping (important for reviewers)

The issue describes an initialise() function panicking with already_initialised. The actual contract has no such guard: initialisation is the four-setter sequence — set_protocol_admin, set_key_price, set_fee_config, set_treasury_address — and the setters are idempotent by design (no AlreadyInitialized error variant exists). Per the issue's tests-only scope, the second-initialise criterion is asserted as idempotence + state invariance rather than a panic. If maintainers prefer a hard guard + error variant, happy to follow up in a separate contract PR.

Acceptance criteria coverage

  • All fields readable from state after initialisation — admin, fee config (creator+protocol bps), protocol fee bps, treasury address, key price (via query_price AND direct KEY_PRICE storage read), is_protocol_config_initialized() == true
  • Second initialise attempt leaves state unchanged — all four setters re-invoked with same values → Ok(()), every field identical afterwards
  • ✅ Exactly one CONTRACT_INITIALIZED event across both passes (complements existing field-level event tests)

Extra

  • Pre-init defaults: views return None/false, FeeConfigNotSet / KeyPriceNotSet errors
  • Documents actual semantics of is_protocol_config_initialized (fee-config presence only)

Tests-only change; follows repo conventions (contract_test_env helpers, doc-commented tests). Ready for CI.

- full init sequence makes admin, fee config, protocol fee bps,
  treasury, key price readable; is_protocol_config_initialized true
- pre-init views return None/false defaults with FeeConfigNotSet /
  KeyPriceNotSet errors
- repeated initialisation is idempotent: all setters Ok, every field
  unchanged, exactly one ContractInitialized event
- is_protocol_config_initialized tracks fee-config presence only

Note: contract has no already_initialised guard by design (idempotent
setters), so second-init assertions cover state invariance instead.

Closes accesslayerorg#723
@drips-wave

drips-wave Bot commented Aug 24, 2026

Copy link
Copy Markdown

@mayborn005 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 fd4b107 into accesslayerorg:main Aug 25, 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 unit tests for the contract initialisation function setting all state fields correctly

3 participants