test: verify protocol initialisation sets and preserves all state fields - #729
Merged
Merged
Conversation
- 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
|
@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! 🚀 |
Closed
3 tasks
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 #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 withalready_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 (noAlreadyInitializederror 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
query_priceAND directKEY_PRICEstorage read),is_protocol_config_initialized() == trueOk(()), every field identical afterwardsCONTRACT_INITIALIZEDevent across both passes (complements existing field-level event tests)Extra
None/false,FeeConfigNotSet/KeyPriceNotSeterrorsis_protocol_config_initialized(fee-config presence only)Tests-only change; follows repo conventions (contract_test_env helpers, doc-commented tests). Ready for CI.