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

Update dependencies and fix test environment setup #324

Merged
merged 7 commits into from
Jan 26, 2024

Conversation

kpob
Copy link
Contributor

@kpob kpob commented Jan 19, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced continuous integration workflow to include test environment preparation and execution of tests.
  • Bug Fixes

    • Improved event emission logic in contract tests by refining argument handling.
    • Adjusted contract address passing in event-related function calls across various features and contracts.
  • Refactor

    • Updated linting and formatting tasks to ensure comprehensive code quality checks.
    • Streamlined attribute mapping in macro processing for better performance.
    • Refined storage value serialization for improved consistency and reliability.
  • Chores

    • Cleaned up references in test modules to simplify event emission code.
    • Aligned naming conventions and function calls with updated library paths for better clarity.

Copy link
Contributor

coderabbitai bot commented Jan 19, 2024

Walkthrough

The series of changes across various files reflect a consistent update to event handling and argument passing, particularly removing the reference operator when calling address() within event emission logic. Additionally, there's a general cleanup in linting configurations and simplification of attribute mapping in macros. The CI workflow has been updated to include test environment preparation and execution of tests.

Changes

Files Summary
.github/workflows/odra-ci.yml Enabled just prepare-test-env and just test commands in CI workflow.
examples/bin/build_schema.rs, examples/src/contracts/owned_token.rs, examples/src/contracts/tlw.rs,
examples/src/features/access_control.rs, examples/src/features/events.rs, examples/src/features/module_nesting.rs,
examples/src/features/native_token.rs, modules/src/access/ownable.rs
Removed & from contract.address() in emitted_event function calls. Added/changed clippy lint and removed & from certain function calls.
justfile Updated tasks with --all-targets flag and added cargo check to certain tasks.
odra-macros/src/ir/attr.rs Streamlined mapping of other_attrs to Attribute::Other.
odra-vm/src/vm/contract_container.rs Reorganized import statements, modified constants, and refactored functions.
odra-vm/src/vm/odra_vm.rs Modified constants, function calls, and CallDef instances.
odra-vm/src/vm/storage.rs Altered storage value setting logic from serialize(&next_value.clone()) to serialize(&next_value).
core/src/contract_context.rs, core/src/host_context.rs, core/src/lib.rs Added attributes and feature for conditional compilation and mocking in tests.
odra-macros/src/ast/deployer_item.rs, odra-macros/src/ast/test_parts.rs Significant modifications to struct methods and logic.
odra-test/src/lib.rs Modified the function signature of the env function.

"In the realm of code where the data hops around,
A rabbit tweaked functions, not a single frown.
🐇 With a hop and a skip, references took flight,
Now events emit cleanly, into the 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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 794ace9 and 994c204.
Files ignored due to path filters (1)
  • odra-vm/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (14)
  • .github/workflows/odra-ci.yml (1 hunks)
  • examples/bin/build_schema.rs (2 hunks)
  • examples/src/contracts/owned_token.rs (1 hunks)
  • examples/src/contracts/tlw.rs (2 hunks)
  • examples/src/features/access_control.rs (4 hunks)
  • examples/src/features/events.rs (1 hunks)
  • examples/src/features/module_nesting.rs (1 hunks)
  • examples/src/features/native_token.rs (1 hunks)
  • justfile (2 hunks)
  • modules/src/access/ownable.rs (4 hunks)
  • odra-macros/src/ir/attr.rs (1 hunks)
  • odra-vm/src/vm/contract_container.rs (3 hunks)
  • odra-vm/src/vm/odra_vm.rs (2 hunks)
  • odra-vm/src/vm/storage.rs (1 hunks)
Files skipped from review due to trivial changes (1)
  • odra-macros/src/ir/attr.rs
Additional comments: 38
.github/workflows/odra-ci.yml (1)
  • 29-30: The uncommenting of the just prepare-test-env and just test commands in the CI workflow file re-enables the test environment setup and the execution of tests. This is a positive change as it ensures that tests are run as part of the CI process, which is crucial for maintaining code quality.
examples/bin/build_schema.rs (2)
  • 1-1: Adding clippy::single_component_path_imports to the allow attribute is appropriate if the project's linting rules have been updated to allow this pattern. This change should not affect the functionality of the code.
  • 18-18: Removing the reference operator & before the format! macro call is a minor change that simplifies the code. This change is syntactically correct as format! returns a String which does not need to be referenced when passed to File::create.
examples/src/features/native_token.rs (3)
  • 26-26: Removing the & operator from my_contract.address() in the balance check assertion is correct if the balance_of function now expects an Address value directly instead of a reference. This change should be consistent across all usages of balance_of.
  • 29-29: The same applies to the balance check assertion on line 29. The removal of the & operator is consistent with the previous change and is correct if the balance_of function's signature has been updated accordingly.
  • 32-32: Again, the removal of the & operator from my_contract.address() in the balance check assertion is consistent with the other changes and is correct if the balance_of function's signature has been updated to accept an Address value directly.
examples/src/features/events.rs (1)
  • 34-34: Modifying the argument passed to the emitted_event method to remove the reference to party_contract.address() is correct if the method's signature has been updated to accept an Address value directly. This change should be verified across all usages of emitted_event to ensure consistency.
justfile (5)
  • 5-5: Adding the --all-targets flag to the cargo clippy command in the clippy task ensures that lint checks are run on all targets, which is a good practice for comprehensive code quality checks.
  • 7-7: The addition of --all-targets to the cargo clippy command in the examples directory is consistent with the change made in the clippy task and is a good practice.
  • 8-8: The addition of --all-targets to the cargo clippy command in the modules directory is consistent with the changes made in the clippy and examples tasks and ensures that lint checks are run on all targets.
  • 20-20: Adding cargo check --all-targets to the modules task ensures that the code compiles for all targets, which is a good practice for maintaining code quality.
  • 22-22: Including cargo check --all-targets in the examples task is consistent with the addition made in the modules task and ensures that the code compiles for all targets.
examples/src/contracts/owned_token.rs (2)
  • 75-75: The change to the emitted_event function call to remove the reference to token.address() is correct if the emitted_event method's signature has been updated to accept an Address value directly. This change should be verified across all usages of emitted_event to ensure consistency.
  • 82-82: The same applies to the emitted_event function call on line 82. The removal of the & operator is consistent with the previous change and is correct if the emitted_event method's signature has been updated accordingly.
examples/src/features/module_nesting.rs (1)
  • 154-154: Modifying the argument passed to the emitted_event method from &nested_odra_types.address() to nested_odra_types.address() is correct if the method's signature has been updated to accept an Address value directly. This change should be verified across all usages of emitted_event to ensure consistency.
odra-vm/src/vm/contract_container.rs (3)
  • 86-86: Changing the TEST_ENTRYPOINT constant from &'static str to &str is a simplification that removes unnecessary lifetime specification. This change is syntactically correct and should not affect the functionality of the code.
  • 178-178: Replacing odra::odra_test::odra_env() with odra_test::env() is a simplification that likely reflects a change in the module structure or import paths. This change is syntactically correct and should not affect the functionality of the code.
  • 199-199: The same simplification is applied here, replacing odra::odra_test::odra_env() with odra_test::env(). This change is consistent with the previous one and is syntactically correct.
examples/src/contracts/tlw.rs (4)
  • 145-145: The change in functionality involves modifying the arguments passed to the emitted_event function within the mod test module. The &contract.address() calls have been replaced with contract.address() in multiple instances, affecting the event emission logic.
  • 152-152: The same applies to the emitted_event function call on line 152. The removal of the & operator is consistent with the previous change and is correct if the emitted_event method's signature has been updated accordingly.
  • 206-206: Again, the removal of the & operator from contract.address() in the emitted_event function call is consistent with the other changes and is correct if the emitted_event method's signature has been updated to accept an Address value directly.
  • 213-213: The same applies to the emitted_event function call on line 213. The removal of the & operator is consistent with the previous changes and is correct if the emitted_event method's signature has been updated accordingly.
examples/src/features/access_control.rs (7)
  • 122-122: The removal of the reference operator (&) before the contract.address() calls within the emitted_event function is correct if the method's signature has been updated to accept an Address value directly. This change should be verified across all usages of emitted_event to ensure consistency.
  • 166-166: The same applies to the emitted_event function call on line 166. The removal of the & operator is consistent with the previous change and is correct if the emitted_event method's signature has been updated accordingly.
  • 174-174: Again, the removal of the & operator from contract.address() in the emitted_event function call is consistent with the other changes and is correct if the emitted_event method's signature has been updated to accept an Address value directly.
  • 182-182: The same applies to the emitted_event function call on line 182. The removal of the & operator is consistent with the previous changes and is correct if the emitted_event method's signature has been updated accordingly.
  • 209-209: The removal of the & operator from contract.address() in the emitted_event function call is correct if the method's signature has been updated to accept an Address value directly. This change should be verified across all usages of emitted_event to ensure consistency.
  • 238-238: The same applies to the emitted_event function call on line 238. The removal of the & operator is consistent with the previous change and is correct if the emitted_event method's signature has been updated accordingly.
  • 246-246: Again, the removal of the & operator from contract.address() in the emitted_event function call is consistent with the other changes and is correct if the emitted_event method's signature has been updated to accept an Address value directly.
odra-vm/src/vm/storage.rs (1)
  • 168-168: The simplification of the serialize call from serialize(&next_value.clone()) to serialize(&next_value) is correct and removes unnecessary cloning of the value before serialization. This change improves performance by avoiding an extra clone operation.
modules/src/access/ownable.rs (6)
  • 174-174: The removal of the reference operator (&) before ownable.address() is consistent with the summary indicating an API change or refactor for cleaner code.
  • 175-175: The removal of the reference operator (&) before ownable_2step.address() is consistent with the summary indicating an API change or refactor for cleaner code.
  • 191-191: The removal of the reference operator (&) before contract.address() is consistent with the summary indicating an API change or refactor for cleaner code.
  • 218-218: The removal of the reference operator (&) before contract.address() is consistent with the summary indicating an API change or refactor for cleaner code.
  • 225-225: The removal of the reference operator (&) before contract.address() is consistent with the summary indicating an API change or refactor for cleaner code.
  • 291-291: The removal of the reference operator (&) before contract.address() is consistent with the summary indicating an API change or refactor for cleaner code.
odra-vm/src/vm/odra_vm.rs (2)
  • 316-316: The change of TEST_ENTRY_POINT from &'static str to &str is a simplification that removes unnecessary lifetime specification. This is a good change if the constant does not need to have a 'static lifetime.
  • 563-563: The function test_caller now calls odra_test::env() instead of odra::odra_test::odra_env(). This change simplifies the call and is consistent with the summary indicating a refactor for cleaner code.

This was linked to issues Jan 19, 2024
@kpob
Copy link
Contributor Author

kpob commented Jan 19, 2024

odradev/cargo-odra#64 needs to be merged first

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 994c204 and 64458cd.
Files selected for processing (1)
  • justfile (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • justfile

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 64458cd and 35d97c8.
Files selected for processing (1)
  • justfile (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • justfile

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 35d97c8 and 0659376.
Files ignored due to path filters (2)
  • core/Cargo.toml is excluded by: !**/*.toml
  • odra-vm/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (9)
  • core/src/contract_container.rs (5 hunks)
  • core/src/contract_context.rs (1 hunks)
  • core/src/host_context.rs (1 hunks)
  • core/src/lib.rs (1 hunks)
  • examples/src/features/module_nesting.rs (1 hunks)
  • odra-macros/src/ast/deployer_item.rs (6 hunks)
  • odra-macros/src/ast/test_parts.rs (6 hunks)
  • odra-test/src/lib.rs (1 hunks)
  • odra-vm/src/vm/odra_vm.rs (7 hunks)
Files skipped from review as they are similar to previous changes (2)
  • examples/src/features/module_nesting.rs
  • odra-vm/src/vm/odra_vm.rs
Additional comments: 10
odra-test/src/lib.rs (1)
  • 11-11: The change in the env function signature to return HostEnv directly is noted. Ensure that all calls to this function are updated to reflect this change.
Verification successful

---



---

The ripgrep search has produced a substantial output, showing numerous instances where the `env()` function is called throughout various files in the codebase. The results include calls to `odra_test::env()`, which is the function signature mentioned in the review comment, as well as other variations of `env()` calls within different contexts and files.

Given the extensive references to `env()` and related functions across multiple files, it is clear that the `env()` function is widely used throughout the codebase. This confirms that the change in the function signature to return `HostEnv` directly is significant and that all calls to this function should indeed be updated to reflect this change, as initially commented.

Based on the provided output, the review comment is verified to be consistent with the codebase.



</details>

<details>
<summary>Scripts Executed</summary>

The following scripts were executed for the analysis:



---

Script:
```shell
#!/bin/bash
# Search for calls to the `env` function to ensure they are updated.
ast-grep --lang rust --pattern $'env()'

Length of output: 40



Script:

#!/bin/bash
# Search for any potential calls to the `env` function within the Rust codebase.
ast-grep --lang rust --pattern $'_ = env()'

Length of output: 44



Script:

#!/bin/bash
# Broaden the search to capture all possible usages of the `env` function.
ast-grep --lang rust --pattern $'env($_)'

Length of output: 42



Script:

#!/bin/bash
# Use ripgrep to perform a text-based search for "env" to ensure no usage is missed.
rg 'env\(\)'

Length of output: 27058

core/src/contract_context.rs (1)
  • 4-5: The addition of #[cfg_attr(test, allow(unreachable_code))] and #[cfg_attr(test, mockall::automock)] attributes to the ContractContext trait is correct for enabling conditional compilation and mocking in tests.
core/src/host_context.rs (1)
  • 9-9: The addition of the #[cfg_attr(test, mockall::automock)] attribute to the HostContext trait is appropriate for enabling mocking in tests.
core/src/lib.rs (1)
  • 1-1: The use of #![cfg_attr(not(test), no_std)] is correct for conditionally enabling the standard library for non-test builds.
core/src/contract_container.rs (3)
  • 79-79: The modification of the TEST_ENTRYPOINT constant from &'static str to &str is correct and should not cause any issues as long as the constant is used consistently throughout the codebase.
  • 113-113: The addition of a boolean argument in the CallDef::new calls is noted. Ensure that the new argument is correctly handled wherever CallDef::new is called.
  • 171-172: Refactoring of the ContractContainer::empty function to use a mock context and environment is appropriate for testing purposes.
odra-macros/src/ast/deployer_item.rs (2)
  • 134-178: The addition of the epc method to the Erc20Deployer struct, which initializes and returns an odra::EntryPointsCaller, is a significant change. Ensure that this new method is integrated correctly with the rest of the codebase.
  • 265-297: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [264-274]

The redefinition of the init method to return an Erc20HostRef and the introduction of the load method are significant changes. Verify that these methods are used correctly and that the init method no longer requires the total_supply parameter.

odra-macros/src/ast/test_parts.rs (1)
  • 232-238: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [219-261]

The refactoring of the Erc20Deployer struct's methods, including the altered init method signature and the new epc and load methods, is noted. Ensure that these changes are consistent with the intended usage patterns and that they are correctly reflected in the test parts.

core/src/lib.rs Outdated Show resolved Hide resolved
core/src/lib.rs Outdated Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0659376 and 232de7e.
Files selected for processing (1)
  • core/src/lib.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • core/src/lib.rs

@kpob kpob merged commit 97c0b0f into release/0.8.0 Jan 26, 2024
1 check passed
@kpob kpob deleted the feature/config-cleanup branch January 26, 2024 07:53
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.

Cleanup justfile Reenable lint and tests in ci for release 0.8.0
3 participants