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!: remove testutil/network #22392

Merged
merged 24 commits into from
Dec 11, 2024
Merged

refactor!: remove testutil/network #22392

merged 24 commits into from
Dec 11, 2024

Conversation

akhilkumarpilli
Copy link
Contributor

@akhilkumarpilli akhilkumarpilli commented Oct 29, 2024

Description

Closes: #22384


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

  • New Features

    • Added a new test function for querying the status of the node in the system tests.
    • Introduced a utility function for obtaining a free TCP address for testing.
  • Bug Fixes

    • Enhanced test setups and logic for account retrieval, ensuring correct interactions with the gRPC server.
  • Documentation

    • Removed outdated documentation related to the test network setup.
  • Refactor

    • Restructured testnet command functionality for improved robustness and usability.
    • Streamlined integration tests by removing unnecessary dependencies and focusing on direct interactions.
  • Chores

    • Deleted several unused test files and functions to improve codebase cleanliness.
    • Removed the testutil/network package, recommending the use of the integration framework or system tests framework instead.

Copy link
Contributor

coderabbitai bot commented Oct 29, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request involves the complete removal of the testutil/network package and associated test files across multiple modules. The changes include the deletion of various test files that utilized the network package, as well as modifications to existing test setups to eliminate dependencies on the now-removed network functionalities. The restructuring aims to streamline the testing framework within the Cosmos SDK application, ensuring that tests are more maintainable and focused on direct interactions without relying on the deprecated network layer.

Changes

File Path Change Summary
client/grpc/cmtservice/status_test.go Deleted file containing a test for the status command, marked to be skipped.
simapp/simd/cmd/testnet.go Modified to enhance testnet initialization; removed startArgs, added parseURL, and improved signal handling.
simapp/test_helpers.go Removed unused imports and deleted the NewTestNetworkFixture function.
simapp/testutil_network_test.go Deleted file containing an integration test suite for network functionalities.
tests/integration/auth/keeper/account_retriever_test.go Updated test to initialize gRPC server and simplified setup without network dependencies.
tests/integration/auth/keeper/fixture_test.go Enhanced fixture struct with new fields for context and encoding configuration.
tests/integration/distribution/cli_tx_test.go Removed minting module configurations from the setup.
tests/integration/genutil/init_test.go Added a new function freeTCPAddr() for obtaining free TCP addresses for testing.
tests/integration/server/grpc/out_of_gas_test.go Deleted file containing tests for gRPC server out-of-gas scenarios.
tests/integration/server/grpc/server_test.go Deleted file with various tests for gRPC server functionalities.
tests/integration/server/grpc_test.go New file introducing an integration test suite for gRPC functionalities.
tests/integration/tx/benchmark/benchmarks_test.go Deleted file containing a benchmark test suite for transaction simulations.
tests/systemtests/cometbft_client_test.go Added a new test function TestQueryStatus for querying node status.
testutil/cli/tx.go Deleted functions CheckTxCode and GetTxResponse related to transaction handling.
testutil/network/doc.go Deleted documentation and implementation details for the test network.
testutil/network/interface.go Deleted interfaces NetworkI and ValidatorI.
testutil/network/network.go Deleted implementation for managing an in-process testing network.
testutil/network/util.go Deleted utility functions for managing CometBFT node in testing.
testutil/network/validator.go Deleted Validator struct and its associated methods.

Assessment against linked issues

Objective Addressed Explanation
Remove testutil/network package
Modify tests that used the network package

Possibly related PRs

  • test: migrate e2e/distribution to system tests #21908: The changes in this PR involve migrating end-to-end tests related to the distribution module to a system test format, which may include similar testing structures and functionalities as the deleted status_test.go file that was intended for testing the status command in the cmtservice package.
  • test: migrate e2e/auth to system tests and fix sign-batch #22149: This PR also focuses on migrating end-to-end tests to system tests, specifically for authentication-related transaction commands, which may share testing methodologies with the status_test.go file that was designed to verify command functionalities.
  • test: migrate e2e/tx tests to systemtest #22152: Similar to the previous PRs, this one involves migrating end-to-end tests for transaction services to a system test format, which could relate to the testing framework and command verification aspects found in the deleted status_test.go.
  • test: migrate e2e/group to system tests #22278: This PR addresses the migration of end-to-end tests for the group package to system tests, which may involve similar testing strategies and command functionalities as those outlined in the status_test.go.
  • test: migrate e2e/mint to system tests #22294: This PR focuses on migrating end-to-end tests for the minting functionality to system tests, which may also share testing principles and command verification approaches relevant to the changes made in the status_test.go.

Suggested labels

backport/v0.52.x

Suggested reviewers

  • akhilkumarpilli
  • tac0turtle
  • alpe

📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ed372c4 and a675a87.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

🔇 Additional comments (4)
CHANGELOG.md (4)

Line range hint 1-1: Documentation follows standard changelog format

The CHANGELOG.md follows the standard format with clear sections for Features, Improvements, Bug Fixes etc. The organization makes it easy for users to understand changes between versions.


Line range hint 2-4: Proper version documentation

The changelog properly documents version changes following semantic versioning, with clear breaking changes sections that help users understand upgrade impacts.


Line range hint 1-2000: Consistent markdown formatting

The markdown formatting is consistent throughout the document, with proper heading levels, bullet points, and code blocks. This makes the document easy to read and parse.


Line range hint 1-2000: Comprehensive module documentation

Changes are well documented per module with clear explanations of the changes and their impacts. Breaking changes and deprecations are clearly marked.


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. (Experiment)
  • @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 added the C:CLI label Oct 29, 2024
simapp/simd/cmd/testnet.go Fixed Show fixed Hide fixed
simapp/simd/cmd/testnet.go Fixed Show fixed Hide fixed
simapp/simd/cmd/testnet.go Fixed Show fixed Hide fixed
simapp/simd/cmd/testnet.go Fixed Show fixed Hide fixed
Comment on lines +714 to +719
go func() {
fmt.Println("Press the Enter Key to terminate all validator processes")
if _, err := fmt.Scanln(); err == nil {
close(shutdownCh) // Signal shutdown
}
}()

Check notice

Code scanning / CodeQL

Spawning a Go routine Note test

Spawning a Go routine may be a possible source of non-determinism
Comment on lines +724 to +728
go func() {
<-sigCh // Wait for Ctrl+C
fmt.Println("\nCtrl+C detected, terminating validator processes...")
close(shutdownCh) // Signal shutdown
}()

Check notice

Code scanning / CodeQL

Spawning a Go routine Note test

Spawning a Go routine may be a possible source of non-determinism
@julienrbrt
Copy link
Member

If you attempt to migrate them to the integration v2 framework, does it work?

@julienrbrt julienrbrt mentioned this pull request Dec 6, 2024
12 tasks
@julienrbrt julienrbrt changed the title test: remove testutil/network refactor!: remove testutil/network Dec 11, 2024
@julienrbrt julienrbrt marked this pull request as ready for review December 11, 2024 09:01
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: 5

🧹 Outside diff range and nitpick comments (3)
tests/integration/auth/keeper/account_retriever_test.go (1)

7-21: Import Statements Not Ordered According to gci Tool.

The import statements are not properly grouped and ordered according to the gci tool guidelines. This can affect code readability and maintainability.

Consider running the gci formatting tool to automatically sort and group the imports as per the project standards.

🧰 Tools
🪛 golangci-lint (1.62.2)

7-7: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


12-12: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


20-20: ST1019: package "github.com/cosmos/cosmos-sdk/x/auth/types" is being imported more than once

(stylecheck)


21-21: ST1019(related information): other import of "github.com/cosmos/cosmos-sdk/x/auth/types"

(stylecheck)

tests/integration/auth/keeper/fixture_test.go (1)

Line range hint 21-34: Import Statements Not Ordered According to gci Tool.

The import statements are not properly grouped and ordered according to the gci tool guidelines. This can affect code readability and maintainability.

Please run the gci tool to sort and group the imports correctly as per the project coding standards.

🧰 Tools
🪛 golangci-lint (1.62.2)

21-21: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

tests/integration/genutil/init_test.go (1)

396-412: Improve function documentation and implementation

While the function correctly implements the required functionality, here are some suggested improvements:

  1. The function comment should follow Go standards with a complete description
  2. The port conversion could be simplified

Consider these improvements:

-// Get a free address for a test CometBFT server
-// protocol is either tcp, http, etc
+// freeTCPAddr returns a free TCP address and port for testing purposes.
+// It returns the full address string, port string, a function to close the listener,
+// and any error encountered.
 func freeTCPAddr() (addr, port string, closeFn func() error, err error) {
     l, err := net.Listen("tcp", "127.0.0.1:0")
     if err != nil {
         return "", "", nil, err
     }
 
     closeFn = func() error {
         return l.Close()
     }
 
     portI := l.Addr().(*net.TCPAddr).Port
-    port = fmt.Sprintf("%d", portI)
+    port = strconv.Itoa(portI)
     addr = fmt.Sprintf("tcp://127.0.0.1:%s", port)
     return
 }
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between aa8266e and 4ee756f.

📒 Files selected for processing (19)
  • client/grpc/cmtservice/status_test.go (0 hunks)
  • simapp/simd/cmd/testnet.go (14 hunks)
  • simapp/test_helpers.go (0 hunks)
  • simapp/testutil_network_test.go (0 hunks)
  • tests/integration/auth/keeper/account_retriever_test.go (1 hunks)
  • tests/integration/auth/keeper/fixture_test.go (3 hunks)
  • tests/integration/distribution/cli_tx_test.go (0 hunks)
  • tests/integration/genutil/init_test.go (3 hunks)
  • tests/integration/server/grpc/out_of_gas_test.go (0 hunks)
  • tests/integration/server/grpc/server_test.go (0 hunks)
  • tests/integration/server/grpc_test.go (1 hunks)
  • tests/integration/tx/benchmark/benchmarks_test.go (0 hunks)
  • tests/systemtests/cometbft_client_test.go (1 hunks)
  • testutil/cli/tx.go (0 hunks)
  • testutil/network/doc.go (0 hunks)
  • testutil/network/interface.go (0 hunks)
  • testutil/network/network.go (0 hunks)
  • testutil/network/util.go (0 hunks)
  • testutil/network/validator.go (0 hunks)
💤 Files with no reviewable changes (13)
  • tests/integration/distribution/cli_tx_test.go
  • simapp/test_helpers.go
  • testutil/network/doc.go
  • testutil/network/interface.go
  • testutil/network/validator.go
  • client/grpc/cmtservice/status_test.go
  • simapp/testutil_network_test.go
  • tests/integration/tx/benchmark/benchmarks_test.go
  • testutil/network/util.go
  • testutil/cli/tx.go
  • tests/integration/server/grpc/out_of_gas_test.go
  • testutil/network/network.go
  • tests/integration/server/grpc/server_test.go
🧰 Additional context used
📓 Path-based instructions (6)
tests/systemtests/cometbft_client_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/auth/keeper/fixture_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/auth/keeper/account_retriever_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/server/grpc_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/genutil/init_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"

simapp/simd/cmd/testnet.go (1)

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

🪛 golangci-lint (1.62.2)
tests/integration/auth/keeper/fixture_test.go

21-21: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


34-34: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

tests/integration/auth/keeper/account_retriever_test.go

7-7: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


12-12: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


20-20: ST1019: package "github.com/cosmos/cosmos-sdk/x/auth/types" is being imported more than once

(stylecheck)


21-21: ST1019(related information): other import of "github.com/cosmos/cosmos-sdk/x/auth/types"

(stylecheck)

tests/integration/server/grpc_test.go

18-18: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


21-21: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


24-24: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

simapp/simd/cmd/testnet.go

[medium] 702-702: G204: Subprocess launched with a potential tainted input or cmd arguments

(gosec)

🔇 Additional comments (3)
tests/systemtests/cometbft_client_test.go (1)

25-34: Test TestQueryStatus Added Successfully.

The new test TestQueryStatus enhances the test coverage by verifying the node status. The implementation aligns with testing best practices.

tests/integration/genutil/init_test.go (2)

8-8: LGTM: Import addition is correct

The addition of the "net" package import is properly placed and necessary for the new TCP address functionality.


Line range hint 223-233: LGTM: Successfully migrated from network package

The test has been properly updated to use the local freeTCPAddr function while maintaining the same functionality and error handling. This change successfully removes the dependency on the testutil/network package as intended.


// run start command
cmdArgs := []string{"start", fmt.Sprintf("--%s=%s", flags.FlagHome, nodeDir)}
runCmd := exec.Command(os.Args[0], cmdArgs...) // spawn new process
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security Concern: Potential Command Injection in exec.Command.

Using exec.Command(os.Args[0], cmdArgs...) where cmdArgs may include untrusted input can lead to command injection vulnerabilities. It's crucial to ensure that all inputs used in cmdArgs are properly sanitized and validated.

Consider validating or sanitizing cmdArgs to prevent potential security risks. Alternatively, use exec.CommandContext with a controlled set of arguments.

🧰 Tools
🪛 golangci-lint (1.62.2)

[medium] 702-702: G204: Subprocess launched with a potential tainted input or cmd arguments

(gosec)

Comment on lines 15 to 21
srvconfig "github.com/cosmos/cosmos-sdk/server/config"
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
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

Duplicate Import of github.com/cosmos/cosmos-sdk/x/auth/types.

The package github.com/cosmos/cosmos-sdk/x/auth/types is imported twice with different aliases (types and authtypes), which can cause confusion.

Consolidate the imports by removing one of the duplicates and using a single alias throughout the code to improve clarity.

🧰 Tools
🪛 golangci-lint (1.62.2)

20-20: ST1019: package "github.com/cosmos/cosmos-sdk/x/auth/types" is being imported more than once

(stylecheck)


21-21: ST1019(related information): other import of "github.com/cosmos/cosmos-sdk/x/auth/types"

(stylecheck)

tests/integration/server/grpc_test.go Outdated Show resolved Hide resolved
tests/integration/server/grpc_test.go Outdated Show resolved Hide resolved
tests/integration/server/grpc_test.go 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.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (5)
server/grpc/server.go (1)

23-23: Excellent interface design change

The modification from concrete types.Application to interface type follows the Interface Segregation Principle perfectly. This change:

  • Reduces coupling by requiring only the necessary RegisterGRPCServer method
  • Increases flexibility for testing and implementation
  • Aligns with the goal of removing testutil/network dependencies

This is a good example of API design in Go - requiring only the minimal interface needed rather than a larger concrete type. Consider applying similar patterns in other packages where concrete types are currently required.

CHANGELOG.md (2)

Line range hint 1-1: Consider adding a title header to the changelog

The file would benefit from having a clear title header like "# Cosmos SDK Changelog" at the top.

+ # Cosmos SDK Changelog

64-65: Fix inconsistent newline after bullet point

There is an inconsistent newline after the bullet point. For consistency, remove the extra newline.

- * (testutil) [#22392](https://github.com/cosmos/cosmos-sdk/pull/22392) Remove `testutil/network` package. Use the integration framework or systemtests framework instead.
-
tests/integration/server/grpc_test.go (2)

202-211: Verify error handling in TestGRPCServer_BankBalance_OutOfGas

The test correctly checks for an out-of-gas error. However, consider verifying that the response res is nil to prevent potential nil pointer dereferences.

Apply this diff to enhance the test:

 _, err := bankClient.Balance(
     context.Background(),
     &banktypes.QueryBalanceRequest{Address: s.address.String(), Denom: "stake"},
 )
+s.Require().Nil(res)
 s.Require().ErrorContains(err, sdkerrors.ErrOutOfGas.Error())

265-265: Address the skipped test and associated TODO

The test TestGRPCServer_InterfaceReflection is currently skipped with a TODO to fix the test (#22825). Consider addressing this issue to ensure the test suite is comprehensive.

Would you like assistance in generating a solution or opening a GitHub issue to track this task?

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4ee756f and ed372c4.

📒 Files selected for processing (6)
  • CHANGELOG.md (1 hunks)
  • server/grpc/server.go (2 hunks)
  • tests/integration/auth/keeper/account_retriever_test.go (1 hunks)
  • tests/integration/auth/keeper/fixture_test.go (3 hunks)
  • tests/integration/server/grpc_test.go (1 hunks)
  • tests/systemtests/cometbft_client_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/systemtests/cometbft_client_test.go
  • tests/integration/auth/keeper/account_retriever_test.go
🧰 Additional context used
📓 Path-based instructions (4)
tests/integration/auth/keeper/fixture_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"

server/grpc/server.go (1)

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

tests/integration/server/grpc_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"

CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

🔇 Additional comments (10)
server/grpc/server.go (1)

8-8: LGTM: Clean import addition

The new import for gogoproto's gRPC package is properly aliased and necessary for the interface type change.

CHANGELOG.md (1)

Line range hint 1-2000: Overall documentation structure looks good

The changelog follows good practices with:

  • Clear version headers and release dates
  • Categorized sections (Features, Improvements, Bug Fixes etc.)
  • Consistent formatting for PR references
  • Detailed descriptions of changes
tests/integration/auth/keeper/fixture_test.go (4)

6-7: LGTM: Import additions are appropriate

The new imports are necessary for block finalization functionality and test assertions.


40-42: LGTM: Fixture struct additions are well-structured

The new fields provide necessary context and encoding configuration for integration tests, aligning with the migration away from testutil/network.


147-147: LGTM: Fixture initialization is complete and consistent

The initialization of new fields is properly handled, with appropriate context unwrapping and encoding configuration assignment.

Also applies to: 151-151


Line range hint 1-153: Verify test coverage after testutil/network removal

Let's ensure that the migration from testutil/network hasn't left any gaps in test coverage.

✅ Verification successful

Let me gather more specific information about test coverage.


Based on the analysis of the test files and patterns, I can now provide a final response.

Test coverage is properly maintained after testutil/network removal

The migration from testutil/network to the new integration test framework is well-covered:

  • The new fixture pattern is consistently used across multiple integration test packages (auth, accounts, distribution, gov, etc.)
  • The test file implements comprehensive test cases including:
    • Account retrieval and management
    • Module account initialization
    • Account migration scenarios
    • Async execution tests
    • Benchmarking tests
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining testutil/network usage and verify test coverage

# Check for any remaining testutil/network imports
echo "Checking for remaining testutil/network imports..."
rg -l "testutil/network" --type go

# Check for test files that might need migration
echo "Checking for potential test files that might need migration..."
fd -e go -e _test.go . | xargs rg -l "network"

# Look for potentially similar test patterns that might need updating
echo "Checking for similar test patterns..."
ast-grep --pattern 'func Test$_($_ *testing.T) {
  $$$
  network.$_
  $$$
}'

Length of output: 1531


Script:

#!/bin/bash
# Check for test coverage in auth/keeper tests
echo "Checking auth/keeper test coverage..."
fd -e go -e _test.go . tests/integration/auth/keeper/ | xargs cat

# Check for any other integration tests that might be using the new pattern
echo "Checking for similar integration test patterns..."
ast-grep --pattern 'type fixture struct {
  $$$
}'

# Look for other test files that might need similar updates
echo "Checking for potential similar test files..."
fd -e go -e _test.go . tests/integration/

Length of output: 37359

tests/integration/server/grpc_test.go (4)

3-49: Group and order imports according to 'gci' formatting rules

The imports are not properly grouped and ordered according to the project's import style guidelines enforced by the gci tool. Please run gci with the specified arguments to format the imports correctly.


179-184: Correct the function call to establish a gRPC client connection

The function grpc.NewClient does not exist in the google.golang.org/grpc package. The standard function to establish a client connection is grpc.Dial.

Apply this diff to correct the function call:

-s.conn, err = grpc.NewClient(
+s.conn, err = grpc.Dial(
     grpcCfg.Address,
     grpc.WithTransportCredentials(insecure.NewCredentials()),
     grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(encodingCfg.InterfaceRegistry).GRPCCodec())),
 )

192-200: LGTM!

The test TestGRPCServer_TestService is well-implemented and follows best practices.


291-317: LGTM!

The test TestGRPCUnpacker effectively verifies the unpacking of interfaces for validators and handles cases where interfaces are not yet unpacked.

Comment on lines +133 to +142
// commit and finalize block
defer func() {
_, err := integrationApp.Commit()
if err != nil {
panic(err)
}
}()
height := integrationApp.LastBlockHeight() + 1
_, err = integrationApp.FinalizeBlock(&cmtabcitypes.FinalizeBlockRequest{Height: height, DecidedLastCommit: cmtabcitypes.CommitInfo{Votes: []cmtabcitypes.VoteInfo{{}}}})
require.NoError(t, err)
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 improving error handling and cleanup in block finalization

The current implementation has several areas for improvement:

  1. Replace panic with test failure
  2. Make cleanup more explicit
  3. Use test assertions consistently

Consider this alternative implementation:

 // commit and finalize block
 defer func() {
-    _, err := integrationApp.Commit()
-    if err != nil {
-        panic(err)
-    }
+    _, err := integrationApp.Commit()
+    require.NoError(t, err, "failed to commit block")
 }()
 height := integrationApp.LastBlockHeight() + 1
 _, err = integrationApp.FinalizeBlock(&cmtabcitypes.FinalizeBlockRequest{
     Height: height,
     DecidedLastCommit: cmtabcitypes.CommitInfo{Votes: []cmtabcitypes.VoteInfo{{}}},
 })
 require.NoError(t, err)
📝 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
// commit and finalize block
defer func() {
_, err := integrationApp.Commit()
if err != nil {
panic(err)
}
}()
height := integrationApp.LastBlockHeight() + 1
_, err = integrationApp.FinalizeBlock(&cmtabcitypes.FinalizeBlockRequest{Height: height, DecidedLastCommit: cmtabcitypes.CommitInfo{Votes: []cmtabcitypes.VoteInfo{{}}}})
require.NoError(t, err)
// commit and finalize block
defer func() {
_, err := integrationApp.Commit()
require.NoError(t, err, "failed to commit block")
}()
height := integrationApp.LastBlockHeight() + 1
_, err = integrationApp.FinalizeBlock(&cmtabcitypes.FinalizeBlockRequest{
Height: height,
DecidedLastCommit: cmtabcitypes.CommitInfo{Votes: []cmtabcitypes.VoteInfo{{}}},
})
require.NoError(t, err)

@julienrbrt julienrbrt added this pull request to the merge queue Dec 11, 2024
Merged via the queue into main with commit cef0f84 Dec 11, 2024
72 of 74 checks passed
@julienrbrt julienrbrt deleted the akhil/remove-network branch December 11, 2024 12:03
@coderabbitai coderabbitai bot mentioned this pull request Dec 20, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove testutil/network package
4 participants