Skip to content
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

fix: migrate contract test #470

Merged
merged 8 commits into from
Feb 20, 2025

Conversation

ptisserand
Copy link
Collaborator

@ptisserand ptisserand commented Feb 20, 2025

Summary by CodeRabbit

  • New Features

    • Introduced new smart contract modules that extend functionality with automated counting, greeting interactions, and token management.
  • Chores

    • Upgraded the development tool to version 2.6.2 for improved consistency.
  • Tests

    • Revamped and reorganized contract tests with updated paths and validations to ensure accurate deployment and functionality checks.

Copy link

docs-page bot commented Feb 20, 2025

To view this pull requests documentation preview, visit the following URL:

docs.page/focustree/starknet.dart~470

Documentation is deployed and generated using docs.page.

Copy link
Contributor

coderabbitai bot commented Feb 20, 2025

Walkthrough

This pull request updates the project's tool version management by specifying scarb 2.6.2 in the relevant configuration file. It introduces new modules (counter and hello) to the Cairo library, and updates JSON artifacts for contracts by adding fields and metadata for the newly added contracts (including Counter, hello, and MyToken). Additionally, the JSON representation of compiled contracts now includes additional fields (such as prime, compiler_version, etc.), the namespace for hello contracts is updated, an outdated artifact file is removed, and the related Dart test files have been restructured to use updated paths and test groupings.

Changes

File(s) Change Summary
contracts/v2.6.2/.tool-versions Added an entry specifying scarb 2.6.2 for tool version management.
contracts/v2.6.2/src/lib.cairo Introduced new module declarations for counter and hello.
contracts/v2.6.2/target/dev/contract2.starknet_artifacts.json Added metadata for contracts: Counter, hello, and MyToken with their module paths and artifact details.
contracts/v2.6.2/target/dev/contract2_[Counter,hello]*.json Updated compiled contract class details, including new fields (e.g., prime, compiler_version), added functions, constructor, event for Counter, and modified namespace details for hello.
contracts/v2.6.2/target/dev/starknet_dart.starknet_artifacts.json Removed obsolete contract metadata.
packages/starknet/test/contract/[contract_test.dart, parse_test.dart] Updated test cases with new contract file paths, restructured test groups (removing deprecated ones and adding new groups), and enabled tests by removing skip flags.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Counter
    Client->>Counter: Deploy Counter Contract (constructor)
    Client->>Counter: Call increment()
    Counter-->>Client: Return updated count
    Client->>Counter: Call decrement()
    Counter-->>Client: Return updated count
Loading
sequenceDiagram
    participant Client
    participant Hello
    Client->>Hello: Deploy Hello Contract (constructor)
    Client->>Hello: Call set_name("Alice")
    Hello-->>Client: Acknowledge name set
    Client->>Hello: Call get_name()
    Hello-->>Client: Return "Alice"
    Client->>Hello: Call sum(3,4)
    Hello-->>Client: Return 7
Loading

Possibly related PRs

  • Clean monorepo  #333: Updates to the tool version management coincide with specifying scarb 2.6.2 in this PR.

Suggested labels

package: starknet_provider

Poem

Oh, what a hop, what a cheer,
New modules and tools now appear,
The counter ticks and the hello sings,
JSON artifacts dance with shiny things,
Code Rabbit smiles with joyful delight—let’s code all night! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ptisserand ptisserand marked this pull request as ready for review February 20, 2025 14:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
contracts/v2.6.2/src/lib.cairo (1)

1-3: Consider alphabetizing module declarations.

For better organization and readability, consider ordering the modules alphabetically:

-mod counter;
-mod erc20;
-mod hello;
+mod counter;
+mod hello;
+mod erc20;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89ebec0 and a202703.

📒 Files selected for processing (10)
  • contracts/v2.6.2/.tool-versions (1 hunks)
  • contracts/v2.6.2/src/lib.cairo (1 hunks)
  • contracts/v2.6.2/target/dev/contract2.starknet_artifacts.json (1 hunks)
  • contracts/v2.6.2/target/dev/contract2_Counter.compiled_contract_class.json (1 hunks)
  • contracts/v2.6.2/target/dev/contract2_Counter.contract_class.json (1 hunks)
  • contracts/v2.6.2/target/dev/contract2_hello.compiled_contract_class.json (1 hunks)
  • contracts/v2.6.2/target/dev/contract2_hello.contract_class.json (1 hunks)
  • contracts/v2.6.2/target/dev/starknet_dart.starknet_artifacts.json (0 hunks)
  • packages/starknet/test/contract/contract_test.dart (3 hunks)
  • packages/starknet/test/contract/parse_test.dart (1 hunks)
💤 Files with no reviewable changes (1)
  • contracts/v2.6.2/target/dev/starknet_dart.starknet_artifacts.json
✅ Files skipped from review due to trivial changes (2)
  • contracts/v2.6.2/.tool-versions
  • contracts/v2.6.2/target/dev/contract2_hello.contract_class.json
🧰 Additional context used
🧠 Learnings (3)
contracts/v2.6.2/src/lib.cairo (1)
Learnt from: rukafe0x
PR: focustree/starknet.dart#411
File: contracts/v2.6.2/src/counter.cairo:28-31
Timestamp: 2024-11-12T04:15:58.361Z
Learning: The file `contracts/v2.6.2/src/counter.cairo` is an example file and doesn't need additional checks.
contracts/v2.6.2/target/dev/contract2.starknet_artifacts.json (3)
Learnt from: rukafe0x
PR: focustree/starknet.dart#412
File: contracts/v1/artifacts/contract2_Counter2.contract_class.json:1-1
Timestamp: 2024-11-12T04:15:58.361Z
Learning: Files in `contracts/v1/artifacts/` are automatically generated by the compiler and should not be modified directly.
Learnt from: rukafe0x
PR: focustree/starknet.dart#411
File: contracts/v1/artifacts/contract2_Counter.compiled_contract_class.json:1-1
Timestamp: 2024-11-12T04:15:58.361Z
Learning: The file `contracts/v1/artifacts/contract2_Counter.compiled_contract_class.json` contains the correct Counter contract implementation and does not contain ERC20 functions.
Learnt from: rukafe0x
PR: focustree/starknet.dart#412
File: contracts/v1/artifacts/contract2_Counter3.contract_class.json:1-1
Timestamp: 2024-11-12T04:15:58.361Z
Learning: Files in the `contracts/v1/artifacts/` directory are automatically generated by the compiler and should not be modified manually.
contracts/v2.6.2/target/dev/contract2_Counter.contract_class.json (1)
Learnt from: rukafe0x
PR: focustree/starknet.dart#412
File: contracts/v1/artifacts/contract2_Counter2.contract_class.json:1-1
Timestamp: 2024-11-12T04:15:58.361Z
Learning: Files in `contracts/v1/artifacts/` are automatically generated by the compiler and should not be modified directly.
🔇 Additional comments (7)
packages/starknet/test/contract/parse_test.dart (1)

7-21: LGTM! Test structure and path updates look good.

The changes properly update the contract path to the new structure and add appropriate test categorization tags.

packages/starknet/test/contract/contract_test.dart (2)

14-14: LGTM! Path updates align with the new structure.

The contract paths have been correctly updated to use the new v0/artifacts directory structure.

Also applies to: 25-25


38-86: LGTM! Well-structured tests for Cairo 2.6.2 contracts.

The new test group:

  • Properly documents the tool version used for hash computation
  • Comprehensively tests both contract and compiled contract class hashes
  • Uses a clean data-driven approach with a dictionary of expected hashes
  • Includes clear error messages for debugging
contracts/v2.6.2/target/dev/contract2.starknet_artifacts.json (1)

1-1: LGTM! Auto-generated artifact file with correct structure.

The artifact file contains the expected metadata for all contracts (Counter, hello, and MyToken) with proper module paths and artifact references.

contracts/v2.6.2/target/dev/contract2_hello.compiled_contract_class.json (1)

1-100: JSON Structure Completeness and Consistency
This new compiled contract class JSON file correctly introduces the expected fields for Cairo 2.6.2 contracts. The inclusion of the "prime", "compiler_version", "bytecode", "bytecode_segment_lengths", "hints", and "entry_points_by_type" keys appears comprehensive. Please verify that the values in "bytecode_segment_lengths" accurately reflect the segmentation of the long "bytecode" array as produced by the compiler.

contracts/v2.6.2/target/dev/contract2_Counter.contract_class.json (1)

1-120: Contract Class Schema and ABI Verification
This contract class JSON for the Counter contract is detailed and includes extensive information such as the "sierra_program", extensive debugging info under "sierra_program_debug_info", and an updated "contract_class_version": "0.1.0". The ABI section correctly lists the new functions (increment, decrement, increase_count_by, get_current_count), along with the constructor and event information. Ensure that the "function_idx" values and selectors in "entry_points_by_type" are fully aligned with the corresponding implementations in the Cairo source code.

contracts/v2.6.2/target/dev/contract2_Counter.compiled_contract_class.json (1)

1-100: Compiled Contract JSON Verification for Counter
This new JSON file for the compiled version of the Counter contract faithfully replicates the required structure for compiled contracts. It includes the "prime" and "compiler_version" fields along with the "bytecode", "bytecode_segment_lengths", and a comprehensive "hints" array. The "entry_points_by_type" field properly distinguishes between external entry points and the constructor. Please double-check that the numeric values (such as segment lengths and offsets) correctly match the output from the compiler and that the provided built-in requirements (e.g., "range_check") are as expected.

@ptisserand ptisserand merged commit 978a214 into focustree:main Feb 20, 2025
11 checks passed
@ptisserand ptisserand deleted the fix/migrate-contract-test branch February 20, 2025 15:19
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.

Migrate contract_test
1 participant