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

refactor(testutil): Removing testutil integration #23091

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sontrinh16
Copy link
Member

@sontrinh16 sontrinh16 commented Dec 25, 2024

Description

ref: #22904


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • Bug Fixes

    • Removed outdated integration test files that were not ready for execution.
  • New Features

    • Introduced new benchmarking functions for account retrieval and setting in the authentication module.
    • Added a test for verifying module account creation during application initialization.
    • Created a new integration test file demonstrating the use of the integration test framework.
  • Chores

    • Deleted several helper and configuration files related to integration tests to streamline the codebase.

Copy link
Contributor

coderabbitai bot commented Dec 25, 2024

📝 Walkthrough

Walkthrough

This pull request involves a comprehensive reorganization and cleanup of integration tests within the Cosmos SDK, specifically focusing on the authentication and testing utility modules. The changes include removing several existing test files from the tests/integration/auth/keeper/ directory and creating new test files in the tests/integration/v2/auth/ directory. Additionally, test utility files in the testutil/integration/ directory were deleted, suggesting a refactoring of the integration testing framework.

Changes

File Path Change Summary
tests/integration/auth/keeper/*.go Multiple test files deleted, including account_retriever_test.go, accounts_retro_compatibility_test.go, app_config.go, fixture_test.go, keeper_bench_test.go, migrate_x_accounts_test.go, module_test.go, and msg_server_test.go
tests/integration/bank/keeper/deterministic_test.go Entire file removed
tests/integration/example/example_test.go Entire file removed
tests/integration/v2/auth/keeper_bench_test.go New benchmark functions added for account mapping performance testing
tests/integration/v2/auth/module_test.go New test function added to verify module account creation
tests/integration/v2/example/example_test.go New integration test example added
testutil/integration/*.go Multiple utility files deleted, including doc.go, helpers.go, options.go, and router.go

Suggested labels

backport/v0.52.x

Suggested reviewers

  • akhilkumarpilli
  • julienrbrt

Possibly related PRs

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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.

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.

@github-actions github-actions bot removed the C:x/bank label Dec 25, 2024
@sontrinh16 sontrinh16 marked this pull request as ready for review December 25, 2024 16:16
@sontrinh16 sontrinh16 requested a review from a team as a code owner December 25, 2024 16:16
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: 1

🧹 Nitpick comments (6)
tests/integration/v2/auth/module_test.go (1)

11-16: Consider validating additional properties of the created module account.

Currently, the test only verifies that the account is not nil. For more comprehensive coverage, consider adding assertions that verify the account address or other critical fields, ensuring the module account is truly initialized as expected.

tests/integration/v2/auth/keeper_bench_test.go (3)

18-68: Consider factoring out the repeated setup logic.

The code in lines 21-31 (module configuration) and lines 33-50 (keeper and app initialization) is almost identical to the setup logic in the second benchmark starting at lines 73-83 and 85-102. You could reduce duplication and improve maintainability by extracting this into a shared helper function.

- moduleConfigs := []configurator.ModuleOption{
-   ...
- }
- var accountKeeper keeper.AccountKeeper
- startupCfg := integration.DefaultStartUpConfig(b)
- app, err := integration.NewApp(
-   ...
- &accountKeeper)
- require.NoError(b, err)
- ctx := app.StateLatestContext(b)
+ app, ctx, accountKeeper, err := createTestApp(b)
+ require.NoError(b, err)

... // Reuse in both BenchmarkAccountMapperGetAccountFound and BenchmarkAccountMapperSetAccount

55-61: Optimize benchmark reliability.

Currently, we're setting accounts in the same iteration as we plan to retrieve them. This approach works for the benchmark but might over-inflate the cost. Consider isolating the setup of accounts in a separate phase to more accurately measure read performance only.


70-116: Document the <224 assumption.**

The assumption that b.N < 2**24 appears again for the second benchmark. Document or justify this limit to future maintainers who might need to raise it for larger-scale testing.

tests/integration/v2/example/example_test.go (2)

24-25: Avoid using panic in test code.
Using panic can obscure errors during test runs. For clarity and improved diagnostics, consider using require or assert methods from testify to handle errors and unexpected conditions.

-	panic(err)
+	require.NoError(t, err, "unexpected error while updating params")
🧰 Tools
🪛 golangci-lint (1.62.2)

25-25: tests: Example should be niladic

(govet)


28-28: Apply gofumpt formatting if desired.
A static analysis tool suggests that the file is not formatted using gofumpt -extra. While not strictly mandatory, you may apply it to ensure consistent styling across the codebase.

🧰 Tools
🪛 golangci-lint (1.62.2)

28-28: File is not gofumpt-ed with -extra

(gofumpt)

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ef2f8d and 4cb52b3.

📒 Files selected for processing (17)
  • tests/integration/auth/keeper/account_retriever_test.go (0 hunks)
  • tests/integration/auth/keeper/accounts_retro_compatibility_test.go (0 hunks)
  • tests/integration/auth/keeper/app_config.go (0 hunks)
  • tests/integration/auth/keeper/fixture_test.go (0 hunks)
  • tests/integration/auth/keeper/keeper_bench_test.go (0 hunks)
  • tests/integration/auth/keeper/migrate_x_accounts_test.go (0 hunks)
  • tests/integration/auth/keeper/module_test.go (0 hunks)
  • tests/integration/auth/keeper/msg_server_test.go (0 hunks)
  • tests/integration/bank/keeper/deterministic_test.go (0 hunks)
  • tests/integration/example/example_test.go (0 hunks)
  • tests/integration/v2/auth/keeper_bench_test.go (1 hunks)
  • tests/integration/v2/auth/module_test.go (1 hunks)
  • tests/integration/v2/example/example_test.go (1 hunks)
  • testutil/integration/doc.go (0 hunks)
  • testutil/integration/helpers.go (0 hunks)
  • testutil/integration/options.go (0 hunks)
  • testutil/integration/router.go (0 hunks)
💤 Files with no reviewable changes (14)
  • testutil/integration/doc.go
  • testutil/integration/helpers.go
  • tests/integration/auth/keeper/app_config.go
  • tests/integration/auth/keeper/module_test.go
  • testutil/integration/options.go
  • tests/integration/bank/keeper/deterministic_test.go
  • tests/integration/example/example_test.go
  • tests/integration/auth/keeper/accounts_retro_compatibility_test.go
  • tests/integration/auth/keeper/fixture_test.go
  • tests/integration/auth/keeper/keeper_bench_test.go
  • tests/integration/auth/keeper/migrate_x_accounts_test.go
  • tests/integration/auth/keeper/account_retriever_test.go
  • tests/integration/auth/keeper/msg_server_test.go
  • testutil/integration/router.go
🧰 Additional context used
📓 Path-based instructions (3)
tests/integration/v2/auth/module_test.go (3)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

tests/integration/v2/auth/keeper_bench_test.go (3)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

tests/integration/v2/example/example_test.go (3)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

🪛 golangci-lint (1.62.2)
tests/integration/v2/example/example_test.go

28-28: File is not gofumpt-ed with -extra

(gofumpt)


25-25: tests: Example should be niladic

(govet)

🔇 Additional comments (4)
tests/integration/v2/auth/module_test.go (2)

1-1: Good package naming.

Keeping the package name the same as the module under test aligns with Go best practices, facilitating clarity in the test structure and discoverability.


3-9: Imports look good.

External dependencies are properly scoped to the specific assertions (testify/require) and module types (cosmos-sdk/x/auth/types), maintaining clarity and minimalism in import usage.

tests/integration/v2/auth/keeper_bench_test.go (1)

1-2: Good package naming.

The file structure and package naming look consistent with the new v2 integration framework.

tests/integration/v2/example/example_test.go (1)

91-91: Ensure console prints align with your testing goals.
In typical Go tests, any printed output is captured but not displayed unless the test fails. If this print statement is purely illustrative for an example, it’s fine; otherwise, consider removing or converting to a test assertion.


// Example shows how to use the integration test framework to test the integration of SDK modules.
// Panics are used in this example, but in a real test case, you should use the testing.T object and assertions.
func Example(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider renaming or making the function niladic.
In Go, Example functions are expected to be niladic for the testing framework to parse their output as examples. If you intend to provide a classic test, rename it (e.g., TestMintIntegration) and keep a *testing.T parameter. If you genuinely want an example test recognized by Go’s toolchain, remove the *testing.T parameter and rely on output comparison to validate correctness.

-func Example(t *testing.T) {
+func TestMintIntegration(t *testing.T) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func Example(t *testing.T) {
func TestMintIntegration(t *testing.T) {
🧰 Tools
🪛 golangci-lint (1.62.2)

25-25: tests: Example should be niladic

(govet)

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

🚀

@julienrbrt julienrbrt changed the title refactor(testutil) Removing testutil integration refactor(testutil): Removing testutil integration Dec 28, 2024
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.

2 participants