-
Notifications
You must be signed in to change notification settings - Fork 399
Check indexed keys #1472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check indexed keys #1472
Conversation
Add verification of indexed keys in event assertions
- Tests will fail if indexed fields are changed in event definitions - Must explicitly specify expected indexed fields
…into feature/check-indexed-keys-#1054
…into feature/check-indexed-keys-#1054
…into feature/check-indexed-keys-#1054
…luding AccessControl, Ownable, Account, EthAccount, Votes, Pausable, ERC1155, ERC20, ERC4626, and ERC721. Each test verifies the correct indexed keys for events such as role grants, ownership transfers, and token transfers.
…rki/cairo-contracts into feat/check-indexed-keys-#1054
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements the ability to check indexed keys in event assertions by migrating from component-specific event structures to a generic Event structure containing keys and data arrays. The migration enables more direct assertion of event keys, allowing tests to verify that events contain expected indexed values.
Key changes include:
- Migration from component-specific event structures to generic
Eventstructures with keys and data arrays - Updated Cairo compiler version from 2.11.4 to 2.12.0-rc.2
- Code formatting consolidation (combining array elements on single lines)
Reviewed Changes
Copilot reviewed 41 out of 44 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Various test files | Migrated event assertions to use generic Event structure with keys/data arrays |
| Scarb.toml | Updated Cairo version to 2.12.0-rc.2 |
| packages/macros/ | Updated to handle Cairo 2.12 API changes and removed with_components module |
| sncast_scripts/ | Consolidated array formatting |
Comments suppressed due to low confidence (6)
packages/macros/Cargo.toml:11
- The version "2.12.0-dev.1" is a development version that may not be stable or available in public registries. Consider using a stable release version instead.
cairo-lang-parser = "2.12.0-dev.1"
packages/macros/Cargo.toml:12
- The version "2.12.0-dev.1" is a development version that may not be stable or available in public registries. Consider using a stable release version instead.
cairo-lang-plugins = "2.12.0-dev.1"
packages/macros/Cargo.toml:13
- The version "2.12.0-dev.1" is a development version that may not be stable or available in public registries. Consider using a stable release version instead.
cairo-lang-syntax = "2.12.0-dev.1"
packages/macros/Cargo.toml:14
- The version "2.12.0-dev.1" is a development version that may not be stable or available in public registries. Consider using a stable release version instead.
cairo-lang-defs = "2.12.0-dev.1"
packages/macros/Cargo.toml:15
- The version "2.12.0-dev.1" is a development version that may not be stable or available in public registries. Consider using a stable release version instead.
cairo-lang-formatter = "2.12.0-dev.1"
packages/macros/Cargo.toml:16
- The version "2.12.0-dev.1" is a development version that may not be stable or available in public registries. Consider using a stable release version instead.
cairo-lang-starknet-classes = "2.12.0-dev.1"
|
This PR proposes a different pattern for testing events by constructing the expected one using the generic Event struct instead of the specific one from the components. We could create a macro to simplify the creation of this (even the creation of the spy event helpers in general). |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1472 +/- ##
==========================================
- Coverage 92.40% 92.35% -0.05%
==========================================
Files 82 82
Lines 2265 2264 -1
==========================================
- Hits 2093 2091 -2
- Misses 172 173 +1
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
…eat/check-indexed-keys-#1054
|
Introduced the ExpectedEventTrait |
…eat/check-indexed-keys-#1054
immrsd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done, Eric! The syntax really got better and less verbose after introducing the ExpectedEvent trait 👍
I haven't noticed any issues, just left a couple of suggestions for the doc
Also, there are still some places in tests where tests are checked with the old approach, I think we should update them for consistency
packages/governance/src/tests/governor/block_number/test_governor_settings.cairo
Outdated
Show resolved
Hide resolved
packages/governance/src/tests/governor/block_number/test_governor_votes_quorum_fraction.cairo
Outdated
Show resolved
Hide resolved
…eat/check-indexed-keys-#1054
immrsd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…eat/check-indexed-keys-#1054
🧪 Cairo Contract Size Benchmark Diff🧪 BYTECODE SIZE (felts)
🧪 SIERRA CONTRACT CLASS SIZE (bytes)
This comment was generated automatically from benchmark diffs. |
Fixes #1054
PR Checklist