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

tests: add E2E tests for IBC-OnRecvPacket Memo Handler #2446

Merged
merged 13 commits into from
Mar 19, 2024

Conversation

gsk967
Copy link
Collaborator

@gsk967 gsk967 commented Mar 5, 2024

Description


Author Checklist

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

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • added appropriate labels to the PR
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

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

I have...

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

Summary by CodeRabbit

  • New Features
    • Enhanced testing for IBC token transfer with memo functionality to ensure secure and accurate cross-blockchain transactions.
    • Expanded IBC module testing to validate packet handling of fungible token data and memo messages.
  • Tests
    • Added tests for balance verification, leverage account balance queries, and updated token transfer functionalities.
  • Chores
    • Updated setup configurations to enable ics20 hooks for improved memo management during token transfers.

@gsk967 gsk967 requested a review from a team as a code owner March 5, 2024 07:41
Copy link
Contributor

coderabbitai bot commented Mar 5, 2024

Walkthrough

The recent updates introduce enhanced testing for the Inter-Blockchain Communication (IBC) protocol, specifically focusing on token transfers with memo functionality and the handling of IBC packets. These changes aim to ensure the robustness of token transfers across blockchains, including various memo scenarios and packet data types. Additionally, the updates bring new utility functions and modifications to existing ones to support these tests, alongside enabling ics20 hooks for memo handling.

Changes

Files Change Summary
tests/e2e/e2e_ibc_memo_test.go Introduced tests for IBC token transfer with memo functionality.
x/uibc/.../ibc_module_test.go New tests for IBC modules handling token transfers and packet data.
tests/e2e/e2e_ibc_test.go
tests/e2e/setup/utils.go
tests/e2e/setup/setup.go
Enhanced IBC token transfer tests, added utility functions for balance queries and memo handling, and enabled ics20 hooks.

"In the realm of code, where rabbits dwell
Across the blockchains, tokens swell
🚀✨ With memos sent, and packets fly
We test, we check, under digital sky
Through IBC's weave, our tales we tell
Ensuring transfers always fare well."

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

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

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

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

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

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

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 416e5a3 and d56b807.
Files selected for processing (3)
  • x/uibc/gmp/gmp_middleware_test.go (1 hunks)
  • x/uibc/uics20/ibc_module_mocks_test.go (1 hunks)
  • x/uibc/uics20/ibc_module_test.go (1 hunks)

x/uibc/gmp/gmp_middleware_test.go Outdated Show resolved Hide resolved
x/uibc/uics20/ibc_module_mocks_test.go Outdated Show resolved Hide resolved
x/uibc/uics20/ibc_module_test.go Outdated Show resolved Hide resolved
x/uibc/uics20/ibc_module_test.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.38%. Comparing base (7f05ad4) to head (e9637f0).
Report is 409 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2446      +/-   ##
==========================================
- Coverage   75.38%   69.38%   -6.01%     
==========================================
  Files         100      185      +85     
  Lines        8025    10909    +2884     
==========================================
+ Hits         6050     7569    +1519     
- Misses       1589     2712    +1123     
- Partials      386      628     +242     

see 176 files with indirect coverage changes

@gsk967 gsk967 enabled auto-merge March 5, 2024 10:02
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d56b807 and 016438e.
Files selected for processing (3)
  • x/uibc/gmp/gmp_middleware_test.go (1 hunks)
  • x/uibc/uics20/ibc_module_mocks_test.go (1 hunks)
  • x/uibc/uics20/ibc_module_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • x/uibc/gmp/gmp_middleware_test.go
  • x/uibc/uics20/ibc_module_mocks_test.go
  • x/uibc/uics20/ibc_module_test.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 UI

Commits Files that changed from the base of the PR and between 016438e and b9b89ce.
Files selected for processing (1)
  • x/uibc/uics20/ibc_module_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/uibc/uics20/ibc_module_test.go

Copy link
Member

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

for integration tests I suggest to:

  1. use gomock for bank keeper
  2. use real ibc keeper
  3. use real or gomock for x/leverage (note: we already have gomock of x/leverage keeper defined)

And the integration test should verify:

  1. The bank balances are updated
  2. The leverage LP are set correctly.

x/uibc/uics20/ibc_module_test.go Outdated Show resolved Hide resolved
x/uibc/uics20/ibc_module_test.go Outdated Show resolved Hide resolved
x/uibc/uics20/ibc_module_test.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 UI

Commits Files that changed from the base of the PR and between b9b89ce and bbb352b.
Files selected for processing (3)
  • tests/e2e/e2e_ibc_memo_test.go (1 hunks)
  • tests/e2e/e2e_ibc_test.go (6 hunks)
  • tests/e2e/setup/utils.go (3 hunks)
Check Runs (12)
test-unit-cover completed (1)
liveness-test completed (1)
install-tparse completed (1)
umeed linux-arm64 completed (1)
umeed darwin-arm64 completed (1)
umeed linux-amd64 completed (1)
umeed darwin-amd64 completed (1)
test-app-non-determinism completed (1)
Run golangci-lint completed (12)
install-dependencies completed (1)
Run govulncheck completed (11)
buf-lint completed (1)
Additional comments: 8
tests/e2e/e2e_ibc_memo_test.go (1)
  • 16-83: The test function testIBCTokenTransferWithMemo is well-structured and covers various scenarios for IBC token transfers with different memo types (valid, invalid with fallback address, invalid without fallback address). It ensures that the system behaves as expected in each case, validating memo handling, packet processing, and data deserialization. The use of assertions to check conditions and the logging of important information are good practices that enhance the test's readability and debuggability.
tests/e2e/e2e_ibc_test.go (4)
  • 14-14: Adding the util/coin package import is appropriate for leveraging utility functions related to coin operations within the test suite. Ensuring that imported packages are utilized effectively is crucial for maintainability and avoiding unnecessary dependencies.
  • 85-102: The addition of the checkLeverageAccountBalance function is a valuable enhancement to the test suite, allowing for more granular verification of account balances in leverage scenarios. This function improves the test coverage by ensuring that collateral and supplied amounts are correctly accounted for in the leverage module. It's important to ensure that the function is called with the correct parameters in all relevant test cases to maximize its utility.
  • 72-80: Modifying the checkSupply function to include a more detailed logging message in case of a failure is a good practice. It enhances the debuggability of the tests by providing clearer insights into the nature of any issues encountered. Including the expected and actual supply amounts, along with the error message, can significantly aid in troubleshooting.
  • 69-149: > 📝 NOTE

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

The updates to the TestIBCTokenTransfer function, including the addition of new test scenarios and the refinement of existing ones, significantly enhance the test suite's coverage and robustness. The detailed scenarios test various aspects of IBC token transfers, including quota management and memo handling. It's important to ensure that all edge cases are considered and that the tests are comprehensive enough to catch potential issues in the IBC transfer logic.

tests/e2e/setup/utils.go (3)
  • 91-101: > 📝 NOTE

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

The modification to the SendIBC function to include a memo parameter is a necessary enhancement for testing IBC transfers with various memo scenarios. This change allows for more comprehensive testing of the IBC transfer functionality, including the handling of memos. It's important to ensure that the memo is correctly formatted and used in all relevant test cases to fully leverage this functionality.

  • 206-214: The addition of the QueryLeverageAccountBalances function is a valuable enhancement to the test suite's utility functions. It enables querying leverage account balances, which is crucial for verifying the state of accounts in tests involving the leverage module. This function improves the test suite's ability to validate the correctness of leverage operations and account states.
  • 98-98: Logging the execution command for Hermes in the SendIBC function is a good practice that enhances the debuggability of the tests. It provides visibility into the exact commands being executed, which can be invaluable for troubleshooting issues related to IBC transfers. Ensuring that logs are informative and relevant is important for maintaining the usefulness of test output.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between bbb352b and 07b46ff.
Files selected for processing (1)
  • tests/e2e/setup/setup.go (1 hunks)
Additional comments: 1
tests/e2e/setup/setup.go (1)
  • 291-292: The change to enable ics20 hooks for memo handling in the uibcGenState.Params is correctly implemented. This is crucial for testing the IBC-OnRecvPacket functionality, especially for scenarios involving memo handling.

Please ensure to verify if enabling these hooks has any unintended side effects on other integration tests within the suite.

Copy link
Member

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

old comments are not solved

tests/e2e/e2e_ibc_memo_test.go Outdated Show resolved Hide resolved
tests/e2e/e2e_ibc_memo_test.go Show resolved Hide resolved
x/uibc/uics20/ibc_module_test.go Outdated Show resolved Hide resolved
x/uibc/uics20/ibc_module_mocks_test.go Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 07b46ff and 0cda333.
Files selected for processing (2)
  • tests/e2e/e2e_ibc_memo_test.go (1 hunks)
  • x/uibc/uics20/ibc_module_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/e2e_ibc_memo_test.go

x/uibc/uics20/ibc_module_test.go Show resolved Hide resolved
x/uibc/uics20/ibc_module_test.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 UI

Commits Files that changed from the base of the PR and between 0cda333 and 8e22e9f.
Files selected for processing (1)
  • x/uibc/uics20/ibc_module_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/uibc/uics20/ibc_module_test.go

@gsk967 gsk967 changed the title tests: add integration tests for IBC-OnRecvPacket tests: add E2E tests for IBC-OnRecvPacket Memo Handler Mar 19, 2024
x/uibc/gmp/gmp_middleware_test.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: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8e22e9f and e9637f0.
Files selected for processing (1)
  • x/uibc/gmp/gmp_middleware_test.go (1 hunks)

x/uibc/gmp/gmp_middleware_test.go Show resolved Hide resolved
@robert-zaremba robert-zaremba disabled auto-merge March 19, 2024 09:37
@robert-zaremba robert-zaremba merged commit a050c18 into main Mar 19, 2024
25 of 27 checks passed
@robert-zaremba robert-zaremba deleted the sai/memo_tests branch March 19, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants