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

chore: make all keeper testsuite vars pointer receivers #5961

Merged
merged 2 commits into from
Mar 12, 2024

Conversation

damiannolan
Copy link
Member

@damiannolan damiannolan commented Mar 11, 2024

Description

Tech debt cleanup.

closes: #XXXX


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Summary by CodeRabbit

  • Tests
    • Improved test functions for better reliability and performance across various modules.

Copy link
Contributor

coderabbitai bot commented Mar 11, 2024

Walkthrough

The modifications involve updating test function receiver types from value to pointer across various test files in the IBC Go modules. This change enhances consistency and potentially improves test performance by ensuring the test suites use pointer receivers uniformly.

Changes

File Path Change Summary
.../02-client/keeper/keeper_test.go Converted test function receivers to pointers
.../03-connection/keeper/keeper_test.go Updated receiver types from value to pointer in test functions
.../04-channel/keeper/keeper_test.go Changed receiver type in test functions to *KeeperTestSuite

Related issues

  • Refactor 02-client keeper to use testing pkg #4013 - This PR could potentially address the objective of removing the usage of pre-testing package fields in the keeper test suite, as it involves a refactor of test functions to use pointer receivers, aligning with modern Go testing practices.

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.
    • 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 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 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.

@damiannolan damiannolan marked this pull request as ready for review March 11, 2024 15:53
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.yml

Commits Files that changed from the base of the PR and between 44a7254 and 8225c4d.
Files selected for processing (3)
  • modules/core/02-client/keeper/keeper_test.go (5 hunks)
  • modules/core/03-connection/keeper/keeper_test.go (2 hunks)
  • modules/core/04-channel/keeper/keeper_test.go (3 hunks)
Additional comments: 8
modules/core/03-connection/keeper/keeper_test.go (2)
  • 64-64: The conversion of the receiver type from value to pointer in TestGetAllConnections is consistent with the PR's objective to enhance efficiency and maintainability by using pointer receivers in test suite variables. This change allows for direct manipulation of the KeeperTestSuite's state within the test, which can be beneficial for setting up or modifying the test environment in a more efficient manner.
  • 96-96: The conversion of the receiver type from value to pointer in TestGetAllClientConnectionPaths aligns with the goal of improving the test suite's performance and consistency. By using pointer receivers, the test functions can directly affect the suite's state, facilitating more dynamic and efficient test setups. This change is a good practice for test suites where the state is expected to change across different tests.
modules/core/02-client/keeper/keeper_test.go (5)
  • 232-232: The conversion of the receiver type from value to pointer in TestGetAllGenesisClients is in line with the PR's objectives. This change enhances the test suite by allowing direct manipulation of the KeeperTestSuite's state, which can lead to more efficient and flexible test setups. Using pointer receivers in test functions is a good practice for improving test suite maintainability.
  • 255-255: The conversion of the receiver type from value to pointer in TestGetAllGenesisMetadata aligns with the PR's goal of improving the test suite's efficiency and consistency. This change enables the test functions to directly modify the suite's state, which is beneficial for setting up tests in a more dynamic manner. It's a positive step towards enhancing the maintainability of the test suite.
  • 311-311: The conversion of the receiver type from value to pointer in TestGetConsensusState is consistent with the PR's objective to enhance the test suite's performance and maintainability. By using pointer receivers, the test functions can directly affect the suite's state, facilitating more efficient test setups. This change is a good practice for test suites where the state is expected to change across different tests.
  • 339-339: The conversion of the receiver type from value to pointer in TestGetAllConsensusStates aligns with the goal of improving the test suite's efficiency and consistency. This change allows for direct manipulation of the KeeperTestSuite's state within the test, which can be beneficial for setting up or modifying the test environment in a more efficient manner. It's a positive step towards enhancing the test suite's maintainability.
  • 388-388: The conversion of the receiver type from value to pointer in TestIterateClientStates is in line with the PR's objectives. This change enhances the test suite by allowing direct manipulation of the KeeperTestSuite's state, which can lead to more efficient and flexible test setups. Using pointer receivers in test functions is a good practice for improving test suite maintainability.
modules/core/04-channel/keeper/keeper_test.go (1)
  • 170-176: > 📝 NOTE

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

The conversion of receiver types from value receivers to pointer receivers in the test suite is a positive change that aligns with Go best practices for struct methods that modify the receiver's state or for efficiency reasons when the receiver is a large struct. This change should improve the performance of the test suite by avoiding unnecessary copying of the KeeperTestSuite struct. However, ensure that all methods on KeeperTestSuite that were intended to modify the receiver's state are correctly updated to reflect this change. Additionally, review all usages of KeeperTestSuite to ensure that pointer semantics are correctly handled, especially in cases where the test suite is passed to functions or methods expecting a value receiver.

@damiannolan damiannolan enabled auto-merge (squash) March 12, 2024 08:46
@damiannolan damiannolan merged commit 3318278 into main Mar 12, 2024
78 of 79 checks passed
@damiannolan damiannolan deleted the damian/keeper-testsuite-recvrs branch March 12, 2024 08:52
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.

4 participants