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

imp(e2e): added generic grpc querier #5979

Merged
merged 30 commits into from
Apr 16, 2024
Merged

Conversation

srdtrk
Copy link
Member

@srdtrk srdtrk commented Mar 13, 2024

Description

closes: #5714


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

  • Refactor
    • Enhanced query handling across various test suites by centralizing query operations through the query package, improving code maintainability and consistency.
    • Streamlined inter-blockchain communication (IBC) operations with updated query functions, enhancing efficiency in retrieving essential IBC data.
  • Tests
    • Updated end-to-end test suites to utilize the new query structure, ensuring compatibility and robustness of the testing framework.

Copy link
Contributor

coderabbitai bot commented Mar 13, 2024

Walkthrough

The changes consolidate the handling of gRPC queries across the end-to-end test suite into a unified approach, utilizing a generic GRPCQuery function. This significant refactor reduces boilerplate code by replacing module-specific gRPC clients and their associated query functions with a single, versatile querying function. The update streamlines the process of making gRPC queries within tests, improving maintainability and scalability of the test suite.

Changes

Files Change Summary
.../base_test.go Replaced direct query calls with query package functions.
.../gov_test.go, .../groups_test.go, .../localhost_test.go, .../upgrades_test.go, .../incentivized_test.go Added query package import; updated method and function calls to use query package.
.../grpc_query.go, .../queries.go, .../client_test.go, .../upgrade_test.go, .../wasm/upgrade_test.go, .../localhost_test.go, .../params_test.go, .../query_test.go, .../genesis_test.go, .../tx.go Added query package import; introduced and refactored to use GRPCQuery function; removed grpcClients map; updated query-related functions to utilize the query package.

Assessment against linked issues

Objective Addressed Explanation
Replace gRPC query clients in E2E with a single gRPC query function (#5714)
Reduce the necessity of adding a querier for every new module tested (#5714)
Eliminate the need to create different functions for each query request type (#5714)
Implement a single query function that can handle any query request and return the appropriate response (#5714)
Link service paths to request types to avoid manual provision (#5714) The implementation of getProtoPath effectively addresses the challenge of linking service paths to request types without manual intervention.

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

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

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: 9

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between 1ebede6 and 537dc24.
Files selected for processing (22)
  • e2e/tests/core/02-client/client_test.go (14 hunks)
  • e2e/tests/core/03-connection/connection_test.go (4 hunks)
  • e2e/tests/interchain_accounts/base_test.go (11 hunks)
  • e2e/tests/interchain_accounts/gov_test.go (4 hunks)
  • e2e/tests/interchain_accounts/groups_test.go (4 hunks)
  • e2e/tests/interchain_accounts/incentivized_test.go (9 hunks)
  • e2e/tests/interchain_accounts/localhost_test.go (9 hunks)
  • e2e/tests/interchain_accounts/params_test.go (4 hunks)
  • e2e/tests/interchain_accounts/upgrades_test.go (11 hunks)
  • e2e/tests/transfer/authz_test.go (5 hunks)
  • e2e/tests/transfer/base_test.go (11 hunks)
  • e2e/tests/transfer/incentivized_test.go (23 hunks)
  • e2e/tests/transfer/localhost_test.go (4 hunks)
  • e2e/tests/transfer/upgrades_test.go (15 hunks)
  • e2e/tests/upgrades/genesis_test.go (4 hunks)
  • e2e/tests/upgrades/upgrade_test.go (31 hunks)
  • e2e/tests/wasm/grandpa_test.go (10 hunks)
  • e2e/tests/wasm/upgrade_test.go (4 hunks)
  • e2e/testsuite/query/grpc_query.go (1 hunks)
  • e2e/testsuite/query/queries.go (1 hunks)
  • e2e/testsuite/testsuite.go (7 hunks)
  • e2e/testsuite/tx.go (4 hunks)
Check Runs (6)
e2e / e2e-tests (TestMsgTransfer_WithMemo, TestTransferTestSuite) completed (1)
e2e / e2e-tests (TestMsgTransfer_Succeeds_Nonincentivized, TestTransferTestSuite) completed (1)
e2e / e2e-tests (TestMsgTransfer_Localhost, TestTransferLocalhostTestSuite) completed (1)
e2e / e2e-tests (TestMsgTransfer_Fails_InvalidAddress, TestTransferTestSuite) completed (1)
e2e / e2e-tests (TestMsgSendTx_SuccessfulTransfer_AfterUpgradingOrdertoUnordered, TestInterchainAccount... completed (1)
e2e / e2e-tests (TestMaxExpectedTimePerBlockParam, TestConnectionTestSuite) completed (1)
Additional comments: 152
e2e/testsuite/query/grpc_query.go (2)
  • 14-39: Creating a new gRPC connection for each query might lead to performance issues. Consider reusing connections or implementing a connection pool for efficiency.
  • 41-59: The getProtoPath function relies on specific naming conventions in type URLs, which could lead to maintenance challenges. Consider a more robust method for deriving gRPC paths.
e2e/testsuite/query/queries.go (9)
  • 72-81: The ClientStatus function is concise and correctly queries the client status. No issues found.
  • 84-98: The GetValidatorSetByHeight function correctly queries and sorts the validator set by address. This is a good use of the sort.SliceStable function for deterministic ordering.
  • 114-124: The Channel function implementation is straightforward and correctly queries channel information. No issues found.
  • 127-137: The CounterPartyPayee function is implemented correctly. It's a good practice to ensure error messages are informative for easier debugging.
  • 140-154: The IncentivizedPacketsForChannel function is correctly implemented to query incentivized packets for a channel. Good use of the generic GRPCQuery function.
  • 157-166: The FeeEnabledChannel function correctly queries the fee-enabled status of a channel. This is a straightforward and clean implementation.
  • 169-178: In the TotalEscrowForDenom function, the implementation is correct. It's important to ensure that error handling is consistent across all query functions.
  • 181-192: The PacketAcknowledgements function is implemented correctly. It queries packet acknowledgements efficiently using the generic GRPCQuery function.
  • 195-204: The UpgradeError function correctly queries for upgrade errors. This function is a good example of how to leverage the generic GRPCQuery for specific query types.
e2e/tests/interchain_accounts/groups_test.go (4)
  • 23-23: The import of the query package is correctly added to utilize the new generic gRPC querier functionality. This change aligns with the PR's objective to streamline querying processes.
  • 71-71: The change from queryClient.GroupPoliciesByGroup to query.GRPCQuery[grouptypes.QueryGroupPoliciesByGroupResponse] is a good example of utilizing the new generic gRPC querier. This simplifies the querying process and reduces boilerplate code.
  • 144-144: The method call change from s.QueryInterchainAccount to QueryInterchainAccount seems to be missing context. Ensure that QueryInterchainAccount is correctly defined and accessible within this context.
  • 202-202: The changes from s.QueryBalance to query.Balance correctly utilize the new query package for balance queries. This is in line with the PR's goal to centralize and simplify querying processes.

Also applies to: 209-209

e2e/tests/upgrades/genesis_test.go (3)
  • 24-24: The addition of the query package import aligns with the PR's objective to centralize and simplify the querying process in the IBC e2e testing suite.
  • 104-110: > 📝 NOTE

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

Replacing s.QueryBalance with query.Balance is a good practice as it utilizes the newly introduced generic gRPC querier, reducing boilerplate code and enhancing maintainability.

  • 116-123: Utilizing query.GRPCQuery for querying interchain account information is a significant improvement. It simplifies the querying process by using a single function capable of handling any query request.
e2e/tests/transfer/authz_test.go (4)
  • 9-9: Adding the import for github.com/strangelove-ventures/interchaintest/v8/ibc is necessary for the new functionality introduced in this file.
  • 21-21: The addition of the query package import is crucial for utilizing the new generic gRPC querier functionality within the e2e testing suite.
  • 35-45: Introducing the QueryGranterGrants function to retrieve GrantAuthorizations using the query.GRPCQuery method is a significant enhancement. It simplifies the process of querying grant authorizations by leveraging the generic gRPC querier.
  • 154-157: Replacing suite.QueryBalance calls with query.Balance for balance verification is a good practice. It leverages the newly introduced generic gRPC querier, enhancing code maintainability and reducing complexity.
e2e/testsuite/tx.go (4)
  • 26-26: The addition of the query package import supports the use of the new generic gRPC querier functionality within the e2e testing suite, aligning with the PR's objectives.
  • 183-194: Changing the type of govProposal to a pointer and updating the query call to use query.GRPCQuery with the govtypesv1.QueryProposalResponse type is a significant improvement. It simplifies the querying process for governance proposals by leveraging the generic gRPC querier.
  • 224-241: Adjusting the assignment of proposalResp and proposal variables in the ExecuteAndPassGovV1Beta1Proposal function to use query.GRPCQuery with the govtypesv1beta1.QueryProposalResponse type is a good practice. It enhances the querying process for governance proposals by utilizing the generic gRPC querier.
  • 250-260: Updating the waitForGovV1Beta1ProposalToPass function to use query.GRPCQuery with the govtypesv1beta1.QueryProposalResponse type for querying governance proposals is a significant improvement. It simplifies and standardizes the querying process across different governance proposal types.
e2e/tests/interchain_accounts/upgrades_test.go (17)
  • 23-23: The introduction of the query package is a significant improvement in terms of code maintainability and extensibility. By centralizing query logic, it simplifies the process of querying blockchain states across different modules.
  • 82-82: The replacement of direct query calls with query.GRPCQuery or specific query functions from the query package is a notable change. However, it's important to ensure that the QueryInterchainAccount function correctly handles errors and edge cases, as it directly impacts the reliability of the test suite.
  • 86-86: Utilizing the query.Channel function here streamlines the process of fetching channel information. It's crucial to verify that the function is used consistently across all test cases to maintain code uniformity.
  • 133-133: The use of query.Balance to verify token transfers is a good practice. It abstracts away the complexity of querying balances, making the test code cleaner and more readable.
  • 140-140: The call to query.Channel for channel information before upgrading the channel showcases the utility of the query package in simplifying test setup procedures. Ensure that the channel information is accurately retrieved and used in the context of the test.
  • 147-147: Querying the module account address using query.ModuleAccountAddress is a clean way to fetch necessary data for governance proposals. This approach enhances the readability and maintainability of the test code.
  • 158-158: Re-querying the channel after an upgrade operation using query.Channel is essential for verifying the upgrade's success. It's important to ensure that the query accurately reflects the channel's new state.
  • 170-170: Similar to the previous comment, verifying the channel upgrade on the counterparty chain is crucial. The use of query.Channel here should be carefully checked to ensure it accurately captures the channel's state post-upgrade.
  • 212-212: Re-using query.Balance to verify the token transfer after the channel upgrade is a good practice. It demonstrates the utility of the query package in reducing code duplication and simplifying test assertions.
  • 268-268: The use of a direct query call to fetch the interchain account before the channel upgrade test is a critical step. It's important to ensure that this query accurately retrieves the interchain account information.
  • 272-272: Utilizing query.Channel to fetch channel information before initiating a channel upgrade is a streamlined approach. Consistency in using the query package across different test scenarios is key to maintaining code quality.
  • 283-283: Querying the channel post-upgrade to verify the inclusion of the fee version is an important validation step. The use of query.Channel here should be carefully reviewed to ensure it accurately reflects the channel's upgraded state.
  • 292-292: The call to query.FeeEnabledChannel to verify if a channel is fee-enabled post-upgrade is a clear example of the query package's utility in simplifying test assertions. Ensure that this function accurately determines the fee status of the channel.
  • 298-298: Repeating the verification of the fee-enabled status on the counterparty chain is crucial for ensuring the upgrade's consistency across both chains. The accuracy of the query.FeeEnabledChannel function in this context should be verified.
  • 307-307: Similar to the previous comment, verifying the fee-enabled status on the counterparty chain is essential. The use of query.FeeEnabledChannel here should be carefully reviewed to ensure it accurately reflects the channel's state.
  • 369-369: Querying the channel state post-timeout using query.Channel is a critical step in verifying the channel closure. It's important to ensure that this query accurately captures the channel's closed state.
  • 376-376: Similar to the previous comment, verifying the channel closure on the counterparty chain is crucial. The accuracy of the query.Channel function in this context should be verified to ensure it accurately reflects the channel's state.
e2e/tests/interchain_accounts/incentivized_test.go (13)
  • 22-22: The introduction of the query package is a significant improvement in terms of code maintainability and extensibility. By centralizing query logic, it simplifies the process of querying blockchain states across different modules.
  • 89-89: The replacement of direct query calls with query.GRPCQuery or specific query functions from the query package is a notable change. However, it's important to ensure that the QueryInterchainAccount function correctly handles errors and edge cases, as it directly impacts the reliability of the test suite.
  • 120-120: Utilizing the query.CounterPartyPayee function here streamlines the process of fetching counterparty payee information. It's crucial to verify that the function is used consistently across all test cases to maintain code uniformity.
  • 126-126: The use of query.IncentivizedPacketsForChannel to verify the absence of incentivized packets before a transaction is a good practice. It abstracts away the complexity of querying packet information, making the test code cleaner and more readable.
  • 168-168: Re-using query.IncentivizedPacketsForChannel to verify the presence of incentivized packets after a transaction showcases the utility of the query package in reducing code duplication and simplifying test assertions.
  • 183-183: The call to query.IncentivizedPacketsForChannel for verifying that packets have been relayed is essential for ensuring the success of incentivized transactions. It's important to ensure that the query accurately reflects the absence of pending packets.
  • 189-189: Querying the balance of the recipient account using query.Balance to verify token transfers is a good practice. It simplifies the validation process by abstracting away direct query calls.
  • 267-267: The use of a direct query call to fetch the interchain account before the incentivized transaction test is a critical step. It's important to ensure that this query accurately retrieves the interchain account information.
  • 288-288: Utilizing query.CounterPartyPayee to fetch counterparty payee information before executing an incentivized transaction is a streamlined approach. Consistency in using the query package across different test scenarios is key to maintaining code quality.
  • 294-294: The call to query.IncentivizedPacketsForChannel to verify the absence of incentivized packets before a failed transaction is a clear example of the query package's utility in simplifying test assertions. Ensure that this function accurately determines the packet status.
  • 337-337: Repeating the verification of incentivized packets after a failed transaction is crucial for ensuring the test's integrity. The accuracy of the query.IncentivizedPacketsForChannel function in this context should be verified.
  • 352-352: Similar to the previous comment, verifying that packets have been relayed after a failed transaction is essential. The use of query.IncentivizedPacketsForChannel here should be carefully reviewed to ensure it accurately reflects the packet status.
  • 358-358: Querying the balance of the recipient account using query.Balance to verify the absence of token transfers in a failed transaction is a good practice. It demonstrates the utility of the query package in reducing code duplication and simplifying test assertions.
e2e/tests/transfer/upgrades_test.go (14)
  • 17-17: The import of the query package aligns with the PR's objective to centralize and simplify querying processes across the e2e testing suite. This change is consistent with the described enhancements.
  • 84-84: Utilizing the query.Channel function from the query package for channel information retrieval is a significant improvement in terms of code maintainability and simplicity. This change effectively replaces direct gRPC client calls with a more abstracted and reusable approach.
  • 99-99: The replacement of direct balance queries with the query.Balance function from the query package is a clear example of the PR's objective to streamline querying processes. This enhances code readability and maintainability.
  • 106-106: Repeating the use of query.Balance for balance queries further demonstrates the PR's commitment to reducing redundancy and simplifying the querying logic across different blockchain modules.
  • 113-113: The use of query.Channel for retrieving channel information post-upgrade is consistent and ensures that the querying process remains streamlined and maintainable. This is a good practice in keeping the codebase clean and efficient.
  • 122-122: Querying for fee-enabled channels using the query.FeeEnabledChannel function is a direct application of the newly introduced querying mechanisms. This specific query function adds to the extensibility of the testing suite by allowing easy addition of similar queries in the future.
  • 128-128: Repeating the pattern of using query package functions for channel information retrieval on the counterparty chain demonstrates a consistent approach to simplifying the querying process across the board. This consistency is key to maintainable and readable code.
  • 137-137: The application of query.FeeEnabledChannel for the counterparty chain further emphasizes the PR's objective to centralize and simplify querying processes. This consistent use of the query package across different test scenarios is commendable.
  • 144-144: Utilizing query.PacketAcknowledgements for retrieving packet acknowledgements is a good example of how the new querying mechanism can be extended to various types of queries, enhancing the test suite's flexibility and maintainability.
  • 153-153: The repeated use of query.PacketAcknowledgements to verify the state post-pruning demonstrates the utility of the query package in making the code more concise and focused on the testing logic rather than the specifics of query execution.
  • 181-181: Replacing direct calls with query.CounterPartyPayee for querying counterparty payee information aligns with the PR's goal of simplifying and centralizing the querying process. This change contributes to a more maintainable and scalable codebase.
  • 192-192: The use of query.IncentivizedPacketsForChannel before sending incentivized transfer packets is a strategic application of the new querying mechanism, showcasing its versatility and the ease with which it can be integrated into existing tests.
  • 205-205: Verifying the absence of incentivized packets after relaying using query.IncentivizedPacketsForChannel is a clear demonstration of the benefits brought by the centralized querying mechanism, particularly in terms of code readability and maintainability.
  • 211-211: The consistent use of query.Balance for balance queries across different test scenarios, as seen here for verifying token receipt by walletB, underscores the PR's objective to streamline and centralize the querying process.
e2e/tests/interchain_accounts/base_test.go (15)
  • 22-22: The import of the query package is in line with the PR's objective to centralize and simplify the querying process within the e2e testing suite. This change is consistent with the described enhancements and improves code maintainability.
  • 46-56: The addition of the QueryInterchainAccount function is a significant enhancement, providing a centralized and simplified way to query interchain account information. This function encapsulates the querying logic, making the tests more readable and maintainable.
  • 103-103: Replacing direct querying calls with the QueryInterchainAccount function for verifying interchain accounts is a clear demonstration of the PR's objective to streamline the querying process. This enhances code readability and maintainability.
  • 159-159: The use of query.Balance for balance queries is consistent with the PR's goal of simplifying and centralizing the querying process. This change contributes to a more maintainable and scalable codebase.
  • 162-162: Repeating the use of query.Balance for balance queries further demonstrates the PR's commitment to reducing redundancy and simplifying the querying logic across different blockchain modules.
  • 202-202: Utilizing the QueryInterchainAccount function for interchain account verification in a different test scenario shows the function's versatility and the ease with which it can be integrated into existing tests.
  • 213-213: The use of query.Balance to verify the host wallet's balance before attempting a transfer is a good practice, ensuring that the test's preconditions are met. This is another example of the centralized querying mechanism's utility.
  • 252-252: Repeating the pattern of using query.Balance for balance verification after a failed transfer attempt is consistent with the PR's objective to centralize and simplify querying processes. This consistency is key to maintainable and readable code.
  • 300-300: The repeated use of QueryInterchainAccount for interchain account verification in yet another test scenario underscores the utility of the newly introduced querying mechanism in making the code more concise and focused on the testing logic.
  • 304-304: Utilizing query.Channel to verify channel information post-interchain account registration is consistent with the PR's goal of simplifying and centralizing the querying process. This enhances code readability and maintainability.
  • 364-364: The use of query.Channel to verify the channel's state after a timeout event is a strategic application of the new querying mechanism, showcasing its versatility and the ease with which it can be integrated into existing tests.
  • 371-371: The consistent use of query.Balance for balance queries across different test scenarios, as seen here for verifying token transfer failure, underscores the PR's objective to streamline and centralize the querying process.
  • 374-374: Repeating the use of query.Balance to verify the host account's balance after a failed transfer attempt further demonstrates the PR's commitment to reducing redundancy and simplifying the querying logic across different blockchain modules.
  • 393-393: Utilizing query.Channel to verify the state of a newly opened channel post-interchain account re-registration is consistent with the PR's goal of simplifying and centralizing the querying process. This enhances code readability and maintainability.
  • 434-434: The use of query.Balance for balance queries in the context of verifying token transfers after reopening an interchain account is a clear demonstration of the benefits brought by the centralized querying mechanism, particularly in terms of code readability and maintainability.
e2e/tests/interchain_accounts/localhost_test.go (6)
  • 22-22: The import of the query package aligns with the PR objectives to centralize and simplify querying operations across the test suite. This change should enhance maintainability and reduce boilerplate code.
  • 112-116: The replacement of direct channel query calls with query.Channel from the query package is a significant improvement. It centralizes the querying logic, which is in line with the PR's objectives. However, ensure that the query.Channel function is thoroughly tested to handle various query scenarios and error conditions.
  • 187-187: The use of query.Balance for querying balances demonstrates the PR's objective of simplifying and centralizing query operations. This should make the test suite more maintainable and reduce redundancy. Ensure that query.Balance is well-tested, especially for edge cases and error handling.
  • 267-271: Reusing the query.Channel function in another test case further demonstrates the utility of the query package in simplifying query operations across different test scenarios. This is a positive change towards achieving the PR's goal of centralizing query logic.
  • 339-344: The checks for channel states being CLOSED using the query.Channel function in the test case for verifying channel closure is a good use of the centralized querying logic provided by the query package. This showcases the package's utility in handling various query needs within the test suite.
  • 472-472: The usage of query.Balance in this test case further demonstrates the utility of the query package in centralizing and simplifying query operations across the test suite. This aligns with the PR's objectives and should be beneficial for maintainability.
e2e/tests/transfer/base_test.go (10)
  • 22-22: The addition of the query package import is appropriate and necessary for the changes made in this file. This aligns with the PR's objective to utilize the new generic gRPC querier for simplifying the querying process.
  • 38-38: The refactoring of QueryTransferParams to use query.GRPCQuery is a significant improvement. It simplifies the querying process by eliminating the need for direct gRPC client calls and specific query functions. This change enhances code maintainability and readability.
  • 85-85: The use of query.TotalEscrowForDenom for querying the total escrow amount is a clear example of how the new query package can simplify and centralize querying logic. This eliminates redundant code and contributes to the overall goal of improving code maintainability.
  • 102-102: Replacing direct balance queries with query.Balance is another step towards centralizing and simplifying the querying process. This change is consistent with the PR's objectives and improves the code's extensibility for future enhancements.
  • 121-121: Continuing the pattern, the use of query.Balance for querying balances in different scenarios demonstrates the flexibility and utility of the new query package. This approach reduces complexity and enhances the code's readability.
  • 127-127: The conditional use of query.TotalEscrowForDenom based on feature support is a good practice. It ensures that the code remains compatible with different versions of the underlying systems, thereby enhancing the code's robustness.
  • 147-147: The use of query.TotalEscrowForDenom for querying un-escrowed tokens aligns with the PR's goal of simplifying the querying process. This change makes the code more maintainable and easier to understand.
  • 266-266: Querying the module account address using query.ModuleAccountAddress is a clear demonstration of the benefits of the new query package. It centralizes and simplifies the process of obtaining module account addresses, which is crucial for governance-related operations.
  • 329-329: Similarly, the addition of query.ModuleAccountAddress in the TestReceiveEnabledParam function showcases the utility of the query package in streamlining the querying process across different test scenarios.
  • 465-465: The consistent use of query.ModuleAccountAddress for querying module account addresses in various test functions further emphasizes the advantages of the new query package. This approach enhances code maintainability and simplifies the querying process.
e2e/testsuite/testsuite.go (7)
  • 20-25: The addition of the query package import is necessary for the changes made in this file, enabling the use of the new generic gRPC querier. This change is consistent with the PR's objectives and enhances the code's maintainability.
  • 313-321: Refactoring the GetChainANativeBalance function to use query.GRPCQuery for balance queries is a significant improvement. It centralizes the querying logic, making the code more maintainable and readable. This change aligns with the PR's goal of simplifying the querying process.
  • 327-336: Similarly, the GetChainBNativeBalance function's refactoring to use query.GRPCQuery demonstrates the utility of the new query package in centralizing balance queries. This approach reduces complexity and enhances code readability.
  • 342-349: The use of query.GRPCQuery in the AssertPacketRelayed function for querying packet commitments is another example of how the new query package simplifies the querying process. This change contributes to the code's maintainability and aligns with the PR's objectives.
  • 357-363: Utilizing query.GRPCQuery for querying denom metadata in the AssertHumanReadableDenom function showcases the benefits of centralizing querying logic. This modification simplifies the code and aligns with the PR's goal of enhancing maintainability.
  • 454-454: Querying the module account address using query.ModuleAccountAddress in the SetUpgradeTimeoutParam function is a clear demonstration of the advantages of the new query package. It centralizes and simplifies the querying process, enhancing code maintainability.
  • 465-465: The consistent use of query.ModuleAccountAddress for querying module account addresses in the InitiateChannelUpgrade function further emphasizes the utility of the query package. This approach streamlines the querying process and improves code maintainability.
e2e/tests/core/02-client/client_test.go (5)
  • 34-34: The import of the query package aligns with the PR's objective to centralize and simplify the querying process in the e2e testing suite. This change is expected to enhance maintainability and reduce boilerplate code.
  • 57-57: Replacing direct queryClient.ClientParams calls with query.GRPCQuery[clienttypes.QueryClientParamsResponse] is a significant improvement. It abstracts the underlying gRPC call mechanism, making the test code cleaner and more maintainable.
  • 77-77: The consistent replacement of various specific query and status check calls with their counterparts in the query package across the test suite is a commendable effort towards achieving the PR's objectives. This change not only reduces the complexity and amount of code but also improves the maintainability and scalability of the test suite.

Also applies to: 81-81, 108-108, 110-110, 120-120, 130-130, 134-134, 208-208, 214-214, 227-227, 233-233, 291-291, 297-297, 304-304, 313-313, 319-319, 350-350, 366-366, 382-382, 391-391, 426-426, 461-461, 485-485

  • 57-57: The use of generics with query.GRPCQuery[clienttypes.QueryClientParamsResponse] demonstrates a modern approach to handling gRPC queries, leveraging Go's type parameters feature. This approach enhances type safety and reduces the risk of runtime errors related to type assertions.
  • 57-57: While the changes made are in line with the PR's objectives, it's important to verify that the new query.GRPCQuery function and the specific query functions within the query package have been thoroughly tested. This verification ensures that the refactoring does not introduce any regressions or unexpected behaviors in the test suite.
e2e/tests/transfer/incentivized_test.go (24)
  • 19-19: The import of the query package aligns with the PR's objective to centralize and simplify querying processes in e2e tests. This change should enhance maintainability and reduce boilerplate code.
  • 76-76: Utilizing query.CounterPartyPayee to verify counterparty payee addresses is a good practice. It abstracts the querying logic, making the test code cleaner and more maintainable.
  • 103-103: Replacing direct query calls with query.IncentivizedPacketsForChannel is a significant improvement. It encapsulates the querying logic, contributing to code modularity and readability.
  • 117-117: The use of query.IncentivizedPacketsForChannel here demonstrates the flexibility and reusability of the query package for different test scenarios. This is a positive change towards reducing code duplication.
  • 142-142: Again, the use of query.IncentivizedPacketsForChannel for querying post-relay packet state showcases the utility of the query package in simplifying the test setup. This consistency in querying approach is commendable.
  • 193-193: Reusing query.CounterPartyPayee in different test cases without direct gRPC calls simplifies the test logic and adheres to DRY principles. This is a good practice.
  • 217-217: The consistent use of query.IncentivizedPacketsForChannel across different test scenarios enhances the test suite's maintainability and readability.
  • 231-231: The validation of incentivized packets through the query package in this scenario further demonstrates the package's utility in simplifying and centralizing query operations.
  • 256-256: The application of query.IncentivizedPacketsForChannel for verifying the state after packet relay in this test case is consistent with the PR's objectives. This enhances the test suite's clarity and maintainability.
  • 314-314: The repeated use of query.CounterPartyPayee across various test cases without direct gRPC calls is a testament to the query package's effectiveness in centralizing query logic.
  • 320-320: Employing query.IncentivizedPacketsForChannel for initial state verification before operations is a good practice, ensuring test reliability and readability.
  • 331-331: The validation of incentivized packets through the query package in this multi-message scenario underscores the package's versatility and utility in the test suite.
  • 355-355: Using query.IncentivizedPacketsForChannel to check the state after relaying packets in a multi-message scenario is consistent with the PR's goal of simplifying querying processes. This is a positive change.
  • 412-412: The consistent application of query.CounterPartyPayee across different test scenarios without direct gRPC calls simplifies the test logic and adheres to DRY principles.
  • 443-443: Utilizing query.IncentivizedPacketsForChannel for initial state verification in this timeout scenario demonstrates the query package's utility in simplifying and centralizing query operations.
  • 454-454: The validation of incentivized packets through the query package in the timeout scenario further demonstrates the package's utility in simplifying and centralizing query operations.
  • 479-479: Employing query.IncentivizedPacketsForChannel to check the state after relaying packets in a timeout scenario aligns with the PR's objectives. This enhances the test suite's clarity and maintainability.
  • 538-538: The use of query.IncentivizedPacketsForChannel for initial state verification before operations in a scenario without a counterparty address is a good practice, ensuring test reliability and readability.
  • 552-552: Validating incentivized packets through the query package in a scenario without a counterparty address underscores the package's versatility and utility in the test suite.
  • 578-578: Using query.IncentivizedPacketsForChannel to check the state after relaying packets in a scenario without a counterparty address is consistent with the PR's goal of simplifying querying processes. This is a positive change.
  • 629-629: The repeated use of query.CounterPartyPayee across various test cases without direct gRPC calls is a testament to the query package's effectiveness in centralizing query logic.
  • 656-656: Employing query.IncentivizedPacketsForChannel for initial state verification in a multiple senders scenario is a good practice, ensuring test reliability and readability.
  • 675-675: The validation of incentivized packets through the query package in a multiple senders scenario further demonstrates the package's utility in simplifying and centralizing query operations.
  • 723-723: Utilizing query.IncentivizedPacketsForChannel to check the state after relaying packets in a multiple senders scenario aligns with the PR's objectives. This enhances the test suite's clarity and maintainability.
e2e/tests/wasm/grandpa_test.go (8)
  • 28-28: The introduction of the query package and its usage here is a positive change, aligning with the PR's objective to streamline and simplify the querying process in the e2e testing suite. This approach enhances code maintainability by centralizing query logic.
  • 406-406: The use of query.ClientState here correctly replaces the previous direct gRPC client call, streamlining the querying process for the client state. This change is consistent with the PR's goal of simplifying and centralizing query operations.
  • 577-577: The replacement of the removed clientStatus function with query.ClientStatus is a good example of how the new querying approach simplifies the code. By using a centralized query function, the test suite becomes more maintainable and easier to extend.
  • 582-582: Similarly, the use of query.ClientStatus for checking the substitute client's status demonstrates the benefits of the new querying mechanism. This change contributes to reducing boilerplate code and improving code readability.
  • 589-589: Utilizing query.ModuleAccountAddress to fetch the module account address for the governance module is another example of the streamlined querying process. This centralized approach to querying enhances the test suite's consistency and maintainability.
  • 601-601: The repeated use of query.ClientStatus to verify the status of the subject client after a governance proposal execution further illustrates the benefits of the centralized querying mechanism introduced in this PR.
  • 606-606: The use of query.ClientStatus to check the status of both the subject and substitute clients post-governance proposal execution is consistent with the PR's objectives. This approach simplifies the querying process and enhances code maintainability.
  • 635-638: The implementation of query.GRPCQuery in PushNewWasmClientProposal to fetch the code response based on the checksum is a significant improvement. It demonstrates the flexibility and utility of the new generic gRPC querier by allowing for a wide range of query types to be handled in a unified manner.
e2e/tests/upgrades/upgrade_test.go (7)
  • 28-28: The import of the query package aligns with the PR's objective to centralize and simplify gRPC queries across the e2e testing suite. This change should enhance maintainability and reduce boilerplate code.
  • 166-166: Replacing direct balance queries with query.Balance calls is a significant improvement in terms of code maintainability and consistency. Ensure that the query.Balance function is thoroughly tested to handle various edge cases and error scenarios.
  • 310-314: The replacement of direct client status queries with query.ClientStatus calls is a positive change, promoting code reuse and simplifying the test logic. However, it's crucial to verify that the query.ClientStatus function accurately handles different client states and returns the expected status.
  • 587-596: > 📝 NOTE

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

The use of query.ModuleAccountAddress and query.GRPCQuery for updating and querying client parameters post-upgrade demonstrates a good application of the new query package. It's important to ensure these functions are resilient to changes in the underlying modules and maintain compatibility with future IBC versions.

  • 649-655: > 📝 NOTE

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

The transition from direct queries to using query.IncentivizedPacketsForChannel for handling incentivized packets is a notable improvement. This change should make the code more readable and easier to maintain. However, ensure that the query package's functions are adequately tested, especially for edge cases like empty packet lists or query failures.

  • 828-840: The use of query.GRPCQuery for querying channel parameters post-upgrade is a good practice, ensuring consistency and reducing direct gRPC calls. It's essential to validate that the channel parameters are correctly fetched and that the upgrade timeout values meet the expected criteria.
  • 999-1000: The ClientState function is a utility method for querying the current client state by client ID. Ensure that error handling is robust and that the function gracefully handles scenarios where the client ID does not exist or the query fails for other reasons.

e2e/testsuite/query/queries.go Show resolved Hide resolved
e2e/testsuite/query/queries.go Outdated Show resolved Hide resolved
Comment on lines 101 to 111
// Balance returns the balance of a specific denomination for a given account by address.
func Balance(ctx context.Context, chain ibc.Chain, address string, denom string) (math.Int, error) {
res, err := GRPCQuery[banktypes.QueryBalanceResponse](ctx, chain, &banktypes.QueryBalanceRequest{
Address: address,
Denom: denom,
})
if err != nil {
return math.Int{}, err
}

return res.Balance.Amount, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

In the Balance function, consider handling the case where the res.Balance is nil to avoid potential nil pointer dereferences.

+	if res.Balance == nil {
+		return math.Int{}, fmt.Errorf("balance response is nil for address %s and denom %s", address, denom)
+	}

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.

Suggested change
// Balance returns the balance of a specific denomination for a given account by address.
func Balance(ctx context.Context, chain ibc.Chain, address string, denom string) (math.Int, error) {
res, err := GRPCQuery[banktypes.QueryBalanceResponse](ctx, chain, &banktypes.QueryBalanceRequest{
Address: address,
Denom: denom,
})
if err != nil {
return math.Int{}, err
}
return res.Balance.Amount, nil
// Balance returns the balance of a specific denomination for a given account by address.
func Balance(ctx context.Context, chain ibc.Chain, address string, denom string) (math.Int, error) {
res, err := GRPCQuery[banktypes.QueryBalanceResponse](ctx, chain, &banktypes.QueryBalanceRequest{
Address: address,
Denom: denom,
})
if err != nil {
return math.Int{}, err
}
if res.Balance == nil {
return math.Int{}, fmt.Errorf("balance response is nil for address %s and denom %s", address, denom)
}
return res.Balance.Amount, nil

e2e/tests/interchain_accounts/localhost_test.go Outdated Show resolved Hide resolved
s.Require().NoError(err)
s.Require().NotNil(channelEndB)

s.Require().Equal(channelEndA.ConnectionHops, channelEndB.ConnectionHops)
})

t.Run("verify interchain account registration and deposit funds", func(t *testing.T) {
interchainAccAddress, err := s.QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID)
interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID)
Copy link
Contributor

Choose a reason for hiding this comment

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

The direct call to QueryInterchainAccount here, as previously noted, indicates an inconsistency in the abstraction of query operations. Consistency in using the query package for all querying operations is essential for maintainability and aligning with the PR's objectives.

Ensure that QueryInterchainAccount is either refactored into the query package or consistently use the query package for all querying operations.

Comment on lines 409 to 413
interchainAccAddress, err := QueryInterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID)
s.Require().NoError(err)
s.Require().NotZero(len(interchainAccAddress))

balance, err := s.QueryBalance(ctx, chainA, interchainAccAddress, chainADenom)
balance, err := query.Balance(ctx, chainA, interchainAccAddress, chainADenom)
Copy link
Contributor

Choose a reason for hiding this comment

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

The inconsistency in using the query package for querying interchain account addresses and balances, as seen with the direct call to QueryInterchainAccount and the use of query.Balance, needs to be addressed. Consistent use of the query package is crucial for the maintainability and clarity of the test suite.

Refactor QueryInterchainAccount into the query package or ensure consistent usage of the query package for all querying operations.

e2e/tests/core/02-client/client_test.go Show resolved Hide resolved
e2e/testsuite/query/grpc_query.go 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.yml

Commits Files that changed from the base of the PR and between 537dc24 and 31af2a1.
Files selected for processing (1)
  • e2e/testsuite/query/queries.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • e2e/testsuite/query/queries.go

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 31af2a1 and ea357db.
Files selected for processing (8)
  • e2e/tests/interchain_accounts/base_test.go (10 hunks)
  • e2e/tests/interchain_accounts/gov_test.go (4 hunks)
  • e2e/tests/interchain_accounts/groups_test.go (4 hunks)
  • e2e/tests/interchain_accounts/incentivized_test.go (9 hunks)
  • e2e/tests/interchain_accounts/localhost_test.go (9 hunks)
  • e2e/tests/interchain_accounts/upgrades_test.go (11 hunks)
  • e2e/testsuite/query/grpc_query.go (1 hunks)
  • e2e/testsuite/query/queries.go (1 hunks)
Files skipped from review as they are similar to previous changes (8)
  • e2e/tests/interchain_accounts/base_test.go
  • e2e/tests/interchain_accounts/gov_test.go
  • e2e/tests/interchain_accounts/groups_test.go
  • e2e/tests/interchain_accounts/incentivized_test.go
  • e2e/tests/interchain_accounts/localhost_test.go
  • e2e/tests/interchain_accounts/upgrades_test.go
  • e2e/testsuite/query/grpc_query.go
  • e2e/testsuite/query/queries.go

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 ea357db and d88dd4a.
Files selected for processing (1)
  • e2e/testsuite/query/grpc_query.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • e2e/testsuite/query/grpc_query.go

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: 5

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between d88dd4a and 3e943fc.
Files selected for processing (1)
  • e2e/testsuite/testsuite.go (7 hunks)
Additional comments: 1
e2e/testsuite/testsuite.go (1)
  • 20-25: The addition of the query package import and removal of direct gRPC client initialization and query calls align with the PR's objectives to centralize querying mechanisms. This change should enhance maintainability and scalability by reducing redundancy and simplifying the querying process.

Comment on lines 342 to 348
commitmentResp, err := query.GRPCQuery[channeltypes.QueryPacketCommitmentResponse](ctx, chain, &channeltypes.QueryPacketCommitmentRequest{
PortId: portID,
ChannelId: channelID,
Sequence: sequence,
})
s.Require().ErrorContains(err, "packet commitment hash not found")

Copy link
Contributor

Choose a reason for hiding this comment

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

Using query.GRPCQuery for asserting packet relayed is a good use of the new centralized querying mechanism. It simplifies the code and makes it more consistent. However, the error message check s.Require().ErrorContains(err, "packet commitment hash not found") assumes a specific error message format.

Ensure that the error message format is standardized and documented, or consider using error types or codes for more reliable error handling.

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: 6

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between 3e943fc and ef4e8bc.
Files selected for processing (1)
  • e2e/testsuite/testsuite.go (7 hunks)
Additional comments: 1
e2e/testsuite/testsuite.go (1)
  • 25-25: The addition of the query package import is a crucial part of this refactoring effort, enabling the use of the new generic query.GRPCQuery function across the e2e testing suite. This change supports the PR's objective of streamlining gRPC queries by reducing boilerplate and improving maintainability.

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 ef4e8bc and d4dad0b.
Files selected for processing (1)
  • e2e/tests/core/02-client/client_test.go (14 hunks)
Files skipped from review as they are similar to previous changes (1)
  • e2e/tests/core/02-client/client_test.go

@srdtrk srdtrk changed the title [Do not review] imp(e2e): added generic grpc querier imp(e2e): added generic grpc querier Mar 13, 2024
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: 7

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between d4dad0b and 143de08.
Files selected for processing (4)
  • e2e/tests/interchain_accounts/base_test.go (10 hunks)
  • e2e/tests/upgrades/upgrade_test.go (31 hunks)
  • e2e/tests/wasm/upgrade_test.go (4 hunks)
  • e2e/testsuite/testsuite.go (7 hunks)
Files skipped from review as they are similar to previous changes (2)
  • e2e/tests/interchain_accounts/base_test.go
  • e2e/tests/wasm/upgrade_test.go
Additional comments: 39
e2e/testsuite/testsuite.go (1)
  • 20-25: The addition of the query package import and removal of the grpcClients map align with the PR's objective to streamline the querying process by introducing a centralized querying mechanism. This change should enhance maintainability and reduce redundancy in the codebase.
e2e/tests/upgrades/upgrade_test.go (38)
  • 28-28: The import of the query package aligns with the PR's objective to consolidate gRPC query clients into a single, generic function. This change should streamline the testing codebase and reduce redundancy.
  • 166-166: Replacing direct calls to s.QueryBalance with query.Balance is a significant improvement. It demonstrates the practical application of the new generic GRPCQuery function, enhancing code modularity and maintainability.
  • 194-194: The repeated use of query.Balance for querying balances post-upgrade validates the effectiveness of the new querying mechanism across different test scenarios. This consistency is crucial for maintainability.
  • 213-213: Utilizing query.Balance for balance checks in various test scenarios, including after chain upgrades and token transfers, showcases the versatility of the new generic querying function.
  • 244-244: The use of query.Balance to verify token balances before and after chain upgrades further emphasizes the utility of the new generic querying mechanism in simplifying the test suite.
  • 268-268: Continued use of query.Balance for balance verification post-upgrade demonstrates the adaptability of the new querying mechanism to different testing scenarios, enhancing code reuse and simplification.
  • 310-310: Replacing s.QueryClientStatus with query.ClientStatus for client status checks aligns with the PR's goal of streamlining gRPC queries. This change contributes to reducing code duplication and improving test suite maintainability.
  • 314-314: The consistent application of query.ClientStatus across different test cases for client status verification further demonstrates the effectiveness of the new generic querying mechanism in simplifying the test suite.
  • 349-349: Utilizing query.ClientStatus for checking the status of clients, including solomachine clients, showcases the versatility of the new querying mechanism in handling various query types efficiently.
  • 380-380: The application of query.Balance for balance verification in tests involving solomachine clients further illustrates the adaptability and utility of the new generic querying function across diverse testing scenarios.
  • 404-404: The use of query.ClientStatus for verifying client statuses post-upgrade demonstrates the new querying mechanism's capability to streamline and simplify the test suite, even in complex upgrade scenarios.
  • 408-408: Continued application of query.ClientStatus for client status checks post-upgrade reinforces the utility of the new generic querying mechanism in enhancing code modularity and maintainability across various test cases.
  • 421-421: Employing query.Balance for balance checks post-upgrade in tests involving solomachine clients validates the effectiveness of the new querying mechanism in simplifying balance verification across different scenarios.
  • 475-475: The repeated use of query.Balance for balance verification in tests post-upgrade highlights the new querying mechanism's role in streamlining the test suite and reducing code duplication.
  • 490-490: Utilizing query.ClientStatus and query.GRPCQuery for querying client statuses and connection responses post-upgrade demonstrates the adaptability of the new querying mechanism to various query types, enhancing test suite maintainability.
  • 503-503: The application of query.TotalEscrowForDenom for querying total escrow amounts post-upgrade showcases the utility of the new generic querying function in handling diverse query requests efficiently.
  • 566-566: Continued use of query.Balance for balance verification in tests post-upgrade emphasizes the new querying mechanism's effectiveness in simplifying the test suite across different testing scenarios.
  • 581-581: Replacing s.QueryModuleAccountAddress with query.ModuleAccountAddress for querying module account addresses aligns with the PR's objective of consolidating gRPC queries, enhancing code modularity and maintainability.
  • 590-590: The use of query.GRPCQuery for querying client parameters post-upgrade demonstrates the new querying mechanism's capability to streamline and simplify the test suite, even in complex scenarios involving parameter updates.
  • 652-652: Replacing s.QueryIncentivizedPacketsForChannel with query.IncentivizedPacketsForChannel for querying incentivized packets aligns with the PR's goal of streamlining gRPC queries, reducing code duplication and improving test suite maintainability.
  • 667-667: The consistent application of query.IncentivizedPacketsForChannel across different test cases for querying incentivized packets further demonstrates the effectiveness of the new generic querying mechanism in simplifying the test suite.
  • 705-705: Utilizing query.Balance for querying module account balances showcases the versatility of the new querying mechanism in handling various query types efficiently, enhancing code reuse and simplification.
  • 721-721: The repeated use of query.Balance for balance verification in tests involving fee payments validates the effectiveness of the new querying mechanism in simplifying balance checks across different scenarios.
  • 828-828: Employing query.GRPCQuery for querying channel parameters post-upgrade demonstrates the new querying mechanism's capability to streamline and simplify the test suite, even in complex scenarios involving channel upgrades.
  • 837-837: The consistent application of query.GRPCQuery for querying channel parameters on both chains post-upgrade reinforces the utility of the new generic querying mechanism in enhancing code modularity and maintainability across various test cases.
  • 861-861: The use of query.Balance for balance verification in tests post-channel upgrade highlights the new querying mechanism's role in streamlining the test suite and reducing code duplication, even in complex scenarios involving packet relays.
  • 867-867: Continued application of query.Balance for balance checks post-channel upgrade in tests involving packet relays further demonstrates the effectiveness of the new generic querying mechanism in simplifying the test suite across diverse testing scenarios.
  • 874-874: Verifying channel upgrades and fee enablement using query.Channel and feetypes.MetadataFromVersion showcases the adaptability of the new querying mechanism to various query types, enhancing test suite maintainability and modularity.
  • 883-883: The use of query.FeeEnabledChannel for verifying fee enablement on channels post-upgrade aligns with the PR's objective of streamlining gRPC queries, reducing code duplication and improving test suite maintainability.
  • 889-889: Employing query.Channel and feetypes.MetadataFromVersion for verifying channel upgrades and fee enablement on both chains post-upgrade demonstrates the new querying mechanism's capability to handle diverse query requests efficiently.
  • 898-898: The consistent application of query.FeeEnabledChannel for fee enablement checks on channels across both chains post-upgrade reinforces the utility of the new generic querying mechanism in enhancing code modularity and maintainability.
  • 905-905: Utilizing query.PacketAcknowledgements for querying packet acknowledgements pre and post-pruning showcases the versatility of the new querying mechanism in handling various query types efficiently, enhancing code reuse and simplification.
  • 914-914: The repeated use of query.PacketAcknowledgements for querying packet acknowledgements post-pruning validates the effectiveness of the new querying mechanism in simplifying the test suite across different scenarios involving packet acknowledgements.
  • 942-942: Replacing s.QueryCounterPartyPayee with query.CounterPartyPayee for querying counterparty payee addresses aligns with the PR's goal of streamlining gRPC queries, reducing code duplication and improving test suite maintainability.
  • 953-953: The use of query.IncentivizedPacketsForChannel for querying incentivized packets pre and post fee payment demonstrates the new querying mechanism's capability to streamline and simplify the test suite, even in complex scenarios involving fee payments.
  • 975-975: Continued application of query.IncentivizedPacketsForChannel for querying incentivized packets post fee payment reinforces the utility of the new generic querying mechanism in enhancing code modularity and maintainability across various test cases.
  • 981-981: Employing query.Balance for balance verification in tests involving incentivized transfer packets further illustrates the adaptability and utility of the new generic querying function across diverse testing scenarios.
  • 999-1000: The ClientState function demonstrates a direct application of the query.GRPCQuery generic function for querying client states. This usage exemplifies the PR's objective to streamline gRPC queries across the test suite, enhancing code modularity and maintainability.

Comment on lines +313 to +316
balanceResp, err := query.GRPCQuery[banktypes.QueryBalanceResponse](ctx, chainA, &banktypes.QueryBalanceRequest{
Address: user.FormattedAddress(),
Denom: chainA.Config().Denom,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactoring the balance querying function to use query.GRPCQuery simplifies the querying process and makes the code more maintainable. However, ensure that error handling is robust and that the context passed to GRPCQuery includes any necessary metadata or deadlines.

Consider adding more detailed error handling or logging to provide clearer insights into failures during the querying process.

Comment on lines +327 to +331

balanceResp, err := query.GRPCQuery[banktypes.QueryBalanceResponse](ctx, chainB, &banktypes.QueryBalanceRequest{
Address: user.FormattedAddress(),
Denom: chainB.Config().Denom,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the previous comment, using query.GRPCQuery for querying balance on chain B is a significant improvement. Ensure that error handling and context management are adequately addressed to prevent potential issues during the querying process.

e2e/testsuite/testsuite.go Show resolved Hide resolved
Comment on lines +354 to +360
denomMetadataResp, err := query.GRPCQuery[banktypes.QueryDenomMetadataResponse](ctx, chain, &banktypes.QueryDenomMetadataRequest{
Denom: chainIBCDenom.IBCDenom(),
})
s.Require().NoError(err)

denomMetadata := denomMetadataResp.Metadata

Copy link
Contributor

Choose a reason for hiding this comment

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

The use of query.GRPCQuery for asserting human-readable denom metadata is another excellent application of the centralized querying mechanism. It makes the code cleaner and more maintainable. However, the assertions on the metadata fields (base, name, display, symbol) rely on specific formatting and naming conventions.

Ensure that these conventions are well-documented and consistently applied across the codebase to avoid potential mismatches or confusion.

@@ -442,7 +448,7 @@
// SetUpgradeTimeoutParam creates and submits a governance proposal to execute the message to update 04-channel params with a timeout of 1s
func (s *E2ETestSuite) SetUpgradeTimeoutParam(ctx context.Context, chain ibc.Chain, wallet ibc.Wallet) {
const timeoutDelta = 1000000000 // use 1 second as relative timeout to force upgrade timeout on the counterparty
govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chain)
govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chain)
Copy link
Contributor

Choose a reason for hiding this comment

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

The call to query.ModuleAccountAddress for setting upgrade timeout parameters is a good example of leveraging the new querying package to simplify the retrieval of module account addresses. However, it's crucial to handle potential errors gracefully and provide informative error messages to aid in debugging.

Consider adding more detailed error handling around the query.ModuleAccountAddress call to ensure that any issues encountered are clearly communicated to the developer.

@@ -453,7 +459,7 @@

// InitiateChannelUpgrade creates and submits a governance proposal to execute the message to initiate a channel upgrade
func (s *E2ETestSuite) InitiateChannelUpgrade(ctx context.Context, chain ibc.Chain, wallet ibc.Wallet, portID, channelID string, upgradeFields channeltypes.UpgradeFields) {
govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chain)
govModuleAddress, err := query.ModuleAccountAddress(ctx, govtypes.ModuleName, chain)
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly, using query.ModuleAccountAddress for initiating channel upgrades demonstrates the benefits of the centralized querying mechanism. As with the previous comment, ensure that error handling is robust and that any issues encountered during the querying process are clearly communicated.

Enhance error handling around the query.ModuleAccountAddress call to provide clearer insights into failures and facilitate troubleshooting.

s.Require().Equal(clienttypes.ZeroHeight(), upgradeTimeout.Height)
s.Require().Equal(uint64(time.Minute*10), upgradeTimeout.Timestamp)
})
})

t.Run("execute gov proposal to initiate channel upgrade", func(t *testing.T) {
chA, err := s.QueryChannel(ctx, chainA, channelA.PortID, channelA.ChannelID)
chA, err := query.Channel(ctx, chainA, channelA.PortID, channelA.ChannelID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Initiating a channel upgrade through a governance proposal is a critical operation. It's important to ensure that the upgrade fields are correctly set and that the channel upgrade does not adversely affect ongoing IBC operations. Consider adding more detailed tests around the channel upgrade process to cover various scenarios and edge cases.

Would you like assistance in generating additional test cases to cover various scenarios and edge cases for channel upgrades?

Copy link
Contributor

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

only looked real quick at the generic func, will try and give a more thorough review later, looks sweet so far!

}

// Create a connection to the gRPC server.
grpcConn, err := grpc.Dial(
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess instead of doing a Dial for each query we could init the grpc conn, store a ref to it in the e2esuite, and have a generic Query function that takes the e2esuite as an arg?

I doubt this re-dialing costs much considering we're using local endpoints though so I'd be perfectly fine with this too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, if there is a convincing argument showing that dialing costs matter, then I'd be happy to create this global

Copy link
Contributor

Choose a reason for hiding this comment

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

nice consideration! But TBH, creating it every time means we never need to worry about re-initializing connections (e.g. after chain restarts) and just generally simplifies things. I think we should wait until this is a problem.

)

// Queries the chain with a query request and deserializes the response to T
func GRPCQuery[T any](ctx context.Context, chain ibc.Chain, req proto.Message, opts ...grpc.CallOption) (*T, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should be able to not return an error here, since I doubt we'd ever want to ever test grpc query err cases in e2es. Looking at invocations does reinforce that thought (hoping I didn't miss anything!), we always require no error after a call. Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are cases we want to test the error. In fact, we do this to check whether a packet commitment is missing here: https://github.com/cosmos/ibc-go/pull/5979/files#diff-a36fcd03b468866255ec8560b99276d8897eccd88d3876b1534e6c9e9b48c800R347

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's reasonable enough to leave it up to caller to handle the error, especially since this fn isn't associated with a testing.T in any way.

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 143de08 and 66674b3.
Files selected for processing (3)
  • e2e/tests/core/02-client/client_test.go (14 hunks)
  • e2e/tests/interchain_accounts/base_test.go (13 hunks)
  • e2e/tests/transfer/localhost_test.go (4 hunks)
Files skipped from review as they are similar to previous changes (3)
  • e2e/tests/core/02-client/client_test.go
  • e2e/tests/interchain_accounts/base_test.go
  • e2e/tests/transfer/localhost_test.go

Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

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

LGTM! Looks great @srdtrk, nice improvement! Just a few small comments but overall looks great!

)

// Queries the chain with a query request and deserializes the response to T
func GRPCQuery[T any](ctx context.Context, chain ibc.Chain, req proto.Message, opts ...grpc.CallOption) (*T, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's reasonable enough to leave it up to caller to handle the error, especially since this fn isn't associated with a testing.T in any way.

e2e/testsuite/query/grpc_query.go Outdated Show resolved Hide resolved
)

// Queries the chain with a query request and deserializes the response to T
func GRPCQuery[T any](ctx context.Context, chain ibc.Chain, req proto.Message, opts ...grpc.CallOption) (*T, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a further constract we can put on T here? Maybe enforce it its a proto message?

Not an expert with generics by any means but something like

type QueryResponse interface {
   proto.Message
}

func GRPCQuery[T QueryResponse] (){}

not foolproof but a little better than any WDYT?

Copy link
Member Author

@srdtrk srdtrk Apr 2, 2024

Choose a reason for hiding this comment

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

linter complaining when I do this + I think keeping it simple is good imo

}

// Create a connection to the gRPC server.
grpcConn, err := grpc.Dial(
Copy link
Contributor

Choose a reason for hiding this comment

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

nice consideration! But TBH, creating it every time means we never need to worry about re-initializing connections (e.g. after chain restarts) and just generally simplifies things. I think we should wait until this is a problem.

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: 2

Review Status

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between 66674b3 and cb78e06.
Files selected for processing (8)
  • e2e/tests/interchain_accounts/base_test.go (13 hunks)
  • e2e/tests/interchain_accounts/localhost_test.go (9 hunks)
  • e2e/tests/interchain_accounts/params_test.go (6 hunks)
  • e2e/tests/interchain_accounts/query_test.go (2 hunks)
  • e2e/tests/interchain_accounts/upgrades_test.go (11 hunks)
  • e2e/tests/upgrades/genesis_test.go (4 hunks)
  • e2e/testsuite/query/grpc_query.go (1 hunks)
  • e2e/testsuite/tx.go (4 hunks)
Additional Context Used
Path-based Instructions (8)
e2e/testsuite/query/grpc_query.go (2)

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


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

e2e/tests/interchain_accounts/query_test.go (3)

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


Pattern e2e/**/*: "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"

e2e/tests/upgrades/genesis_test.go (3)

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


Pattern e2e/**/*: "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"

e2e/tests/interchain_accounts/params_test.go (3)

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


Pattern e2e/**/*: "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"

e2e/tests/interchain_accounts/upgrades_test.go (3)

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


Pattern e2e/**/*: "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"

e2e/testsuite/tx.go (2)

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


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

e2e/tests/interchain_accounts/localhost_test.go (3)

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


Pattern e2e/**/*: "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"

e2e/tests/interchain_accounts/base_test.go (3)

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


Pattern e2e/**/*: "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"

Additional comments not posted (36)
e2e/testsuite/query/grpc_query.go (1)

14-14: The function documentation is clear and concise, providing a good overview of its purpose and usage.

e2e/tests/interchain_accounts/query_test.go (2)

20-20: The import of the query package is correctly added to utilize the new generic query function within the tests. This change aligns with the PR's objective to streamline gRPC querying in the e2e testing suite.


68-68: The replacement of s.QueryInterchainAccount with query.InterchainAccount is a good application of the new generic query function, enhancing the test's maintainability by reducing direct dependencies on specific query clients.

e2e/tests/upgrades/genesis_test.go (3)

24-24: The import of the query package is correctly added to utilize the new generic query function within the tests. This change aligns with the PR's objective to streamline gRPC querying in the e2e testing suite.


107-107: The replacement of s.QueryBalance with query.Balance is a good application of the new generic query function, enhancing the test's maintainability by reducing direct dependencies on specific query clients.


116-119: The use of query.GRPCQuery with controllertypes.QueryInterchainAccountResponse as the generic type parameter is a clear example of how the new generic query function can be utilized to streamline querying across different modules. This change improves code readability and maintainability.

e2e/tests/interchain_accounts/params_test.go (3)

24-24: The import of the query package is correctly added to utilize the new generic query function within the tests. This change aligns with the PR's objective to streamline gRPC querying in the e2e testing suite.


44-44: The replacement of direct query calls with query.GRPCQuery for controller params is a good application of the new generic query function, enhancing the test's maintainability by reducing direct dependencies on specific query clients.


52-52: Similarly, the replacement of direct query calls with query.GRPCQuery for host params demonstrates the versatility and utility of the new generic query function in streamlining the querying process across different modules.

e2e/tests/interchain_accounts/upgrades_test.go (3)

23-23: The import of the query package is correctly added to utilize the new generic query function within the tests. This change aligns with the PR's objective to streamline gRPC querying in the e2e testing suite.


82-82: The replacement of s.QueryInterchainAccount with query.InterchainAccount is a good application of the new generic query function, enhancing the test's maintainability by reducing direct dependencies on specific query clients.


86-86: The use of query.Channel to replace direct query calls for channel information is another example of how the new generic query function can streamline querying processes across different modules, improving code readability and maintainability.

e2e/testsuite/tx.go (4)

29-29: The import of the query package is correctly added to facilitate the use of the new GRPCQuery function. This aligns with the PR's objective to streamline gRPC querying by consolidating multiple query clients into a single, generic function.


186-197: The modification to use query.GRPCQuery with govtypesv1.QueryProposalResponse in waitForGovV1ProposalToPass is a good example of the intended consolidation of gRPC queries. This change enhances maintainability by reducing redundancy and streamlining the querying process.


227-244: The use of query.GRPCQuery in ExecuteAndPassGovV1Beta1Proposal for querying proposal responses is consistent with the PR's goal. It's important to ensure that the query.GRPCQuery function is thoroughly tested, especially since it now handles diverse query types.


253-263: The refactoring to use query.GRPCQuery for querying proposal responses in waitForGovV1Beta1ProposalToPass is consistent with the changes made in other parts of the file. This demonstrates a uniform approach to querying, which is beneficial for code maintainability.

e2e/tests/interchain_accounts/localhost_test.go (5)

22-22: The import of the query package is correctly added, enabling the use of the new GRPCQuery function for querying operations related to interchain accounts. This change supports the PR's goal of reducing redundancy and enhancing maintainability.


112-116: The replacement of direct method calls with calls to query.Channel for querying channel ends is a good application of the new query package. This change simplifies the querying process and aligns with the PR's objectives.


124-124: Using query.InterchainAccount to query interchain account addresses demonstrates the intended use of the query package to streamline querying operations. Ensure that all query operations related to interchain accounts are consistently using this package.


138-138: Repeating the use of query.InterchainAccount for querying interchain account addresses before sending packets is consistent with the PR's goal. This consistency in using the query package enhances code readability and maintainability.


187-187: The use of query.Balance to query balances is another example of how the query package is being utilized to streamline querying operations. This change contributes to reducing code duplication and improving maintainability.

e2e/tests/interchain_accounts/base_test.go (15)

24-24: The addition of the query package import is consistent with the PR's objective to centralize gRPC queries. Ensure that the query package is thoroughly tested, especially since it now plays a critical role in the e2e testing suite.


92-92: The replacement of direct query calls with the query.InterchainAccount function is a good example of code centralization. However, ensure that the query package's InterchainAccount function handles all edge cases previously covered by the direct query method.


148-151: Using the query.Balance function to replace direct balance queries is in line with the PR's goals. It's important to verify that this function accurately handles different denominations and error scenarios, similar to the original implementation.


191-191: Repeating the use of query.InterchainAccount in another test case demonstrates consistency in applying the new querying approach. Ensure that this does not introduce any performance regressions due to potential overhead from the generic querying mechanism.


202-202: The use of query.Balance to check the host account's balance before attempting a transfer is a prudent check. Confirm that the query package's implementation provides real-time balance information to avoid stale data issues.


241-241: Again, the query.Balance function is used to verify the outcome of a transaction. It's crucial to ensure that this method accurately reflects changes in account balances post-transaction, considering eventual consistency models in distributed systems.


289-289: The consistent use of query.InterchainAccount across different test scenarios is noted. It's essential to validate that the underlying gRPC calls are optimized for performance, especially in test environments where speed is critical.


293-293: The introduction of the query.Channel function to check channel states is a significant change. Ensure that this function can accurately determine the state of channels, including nuanced states that might be relevant for specific tests.


353-353: The use of query.Channel to verify channel closure due to timeout is a critical test assertion. This highlights the importance of the query package's ability to accurately reflect channel states, which must be thoroughly tested.


360-363: Utilizing query.Balance to confirm that tokens were not transferred due to a channel timeout is a good practice. This reinforces the need for the query package to provide accurate and timely balance information.


382-382: The query.Channel function is used to verify the state of a newly opened channel. This is a crucial check, and it's important to ensure that the query package can handle scenarios where channels are reopened or have their state changed.


423-423: The use of query.Balance to verify successful token transfer after reopening an interchain account channel is consistent with previous test cases. It's essential to ensure that the query package's balance query accurately reflects such transactions.


469-469: The repeated use of query.InterchainAccount across various test scenarios demonstrates the PR's objective to centralize query functionality. It's important to ensure that this does not introduce any unintended side effects, especially in complex test scenarios.


493-493: Introducing the query.ModuleAccountAddress function to obtain a module account address is a significant change. Ensure that this function is capable of accurately retrieving addresses for various modules, considering the dynamic nature of blockchain state.


533-536: The use of a generic query.GRPCQuery function to retrieve a governance proposal demonstrates the flexibility of the new query package. It's crucial to verify that this generic querying mechanism does not compromise the specificity and accuracy needed for such queries.

e2e/testsuite/query/grpc_query.go Show resolved Hide resolved
Comment on lines +41 to +85
func getProtoPath(req proto.Message) (string, error) {
typeURL := "/" + proto.MessageName(req)

switch {
case strings.Contains(typeURL, "Query"):
return getQueryProtoPath(typeURL)
case strings.Contains(typeURL, "cosmos.base.tendermint"):
return getCmtProtoPath(typeURL)
default:
return "", fmt.Errorf("unsupported typeURL: %s", typeURL)
}
}

func getQueryProtoPath(queryTypeURL string) (string, error) {
queryIndex := strings.Index(queryTypeURL, "Query")
if queryIndex == -1 {
return "", fmt.Errorf("invalid typeURL: %s", queryTypeURL)
}

// Add to the index to account for the length of "Query"
queryIndex += len("Query")

// Add a slash before the query
urlWithSlash := queryTypeURL[:queryIndex] + "/" + queryTypeURL[queryIndex:]
if !strings.HasSuffix(urlWithSlash, "Request") {
return "", fmt.Errorf("invalid typeURL: %s", queryTypeURL)
}

return strings.TrimSuffix(urlWithSlash, "Request"), nil
}

func getCmtProtoPath(cmtTypeURL string) (string, error) {
cmtIndex := strings.Index(cmtTypeURL, "Get")
if cmtIndex == -1 {
return "", fmt.Errorf("invalid typeURL: %s", cmtTypeURL)
}

// Add a slash before the commitment
urlWithSlash := cmtTypeURL[:cmtIndex] + "Service/" + cmtTypeURL[cmtIndex:]
if !strings.HasSuffix(urlWithSlash, "Request") {
return "", fmt.Errorf("invalid typeURL: %s", cmtTypeURL)
}

return strings.TrimSuffix(urlWithSlash, "Request"), nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The verification process revealed that there are no tests specifically targeting the functions getProtoPath, getQueryProtoPath, and getCmtProtoPath within the e2e/testsuite/query directory. This finding contradicts the assumption made in the review comment about the importance of thorough testing for all supported typeURLs. Therefore, it's crucial to address this gap in test coverage to ensure the reliability and correctness of these functions.

Analysis chain

The getProtoPath function and its helpers getQueryProtoPath and getCmtProtoPath are well-structured and provide a clear mechanism for deriving the gRPC service path from the request type. This dynamic approach enhances the flexibility of the GRPCQuery function. Ensure that all supported typeURLs are thoroughly tested to prevent runtime errors due to unsupported or incorrectly formatted typeURLs.


Given the initial script did not produce any output, it's essential to take a more granular approach to verify the presence of the functions and their tests separately. Let's start by confirming the presence of the functions getProtoPath, getQueryProtoPath, and getCmtProtoPath in the Go files.


To further investigate the presence of tests for the functions getProtoPath, getQueryProtoPath, and getCmtProtoPath, let's search for any test functions in the e2e/testsuite/query directory or its subdirectories that might reference these methods.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that all supported typeURLs are covered by unit tests.
rg --type go "getProtoPath|getQueryProtoPath|getCmtProtoPath" --files-with-matches | xargs rg "Test"

Length of output: 100



Script:

#!/bin/bash
# Verify the presence of the functions in the Go files.
rg --type go "func (getProtoPath|getQueryProtoPath|getCmtProtoPath)\("

Length of output: 349



Script:

#!/bin/bash
# Search for test functions in the e2e/testsuite/query directory.
rg --type go "Test" e2e/testsuite/query/

Length of output: 40

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

Review Status

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between cb78e06 and 168bd97.
Files selected for processing (1)
  • e2e/testsuite/tx.go (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • e2e/testsuite/tx.go

Copy link

sonarcloud bot commented Apr 16, 2024

Quality Gate Passed Quality Gate passed for 'ibc-go'

Issues
7 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@srdtrk srdtrk merged commit bb4ce39 into main Apr 16, 2024
138 checks passed
@srdtrk srdtrk deleted the serdar/issue#5714-e2e-grpc-querier branch April 16, 2024 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Replace gRPC query clients in E2E with a single gRPC query function
4 participants