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

feat: ibc e2e tests for fiattokenfactory #374

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

Conversation

boojamya
Copy link
Member

Includes:

  • TestFiatTFIBCOut
  • TestFiatTFIBCIn

Copy link

coderabbitai bot commented May 27, 2024

Walkthrough

The changes in this pull request introduce new test cases in the e2e/fiat_tf_test.go file, specifically targeting the Inter-Blockchain Communication (IBC) functionality of the fiat token factory. Two new test functions, TestFiatTFIBCOut and TestFiatTFIBCIn, are added to simulate various scenarios related to sending and receiving fiat tokens across different chains. The modifications also include necessary imports for handling IBC transfers and testing utilities.

Changes

File Change Summary
e2e/fiat_tf_test.go - Added new test function: TestFiatTFIBCOut for sending fiat tokens with various scenarios.
- Added new test function: TestFiatTFIBCIn for receiving fiat tokens with various scenarios.
- Imported transfertypes and testutil packages for IBC transfers and testing utilities.

Possibly related PRs

  • feat: owner e2e tests for fiattokenfactory #367: The main PR adds tests for IBC functionality in the fiat token factory, while this PR introduces tests for ownership features in the same file, indicating a related focus on the fiat token factory's functionality.
  • feat: pause e2e tests for fiattokenfactory #369: This PR enhances the testing of pausing functionality in the fiat token factory, which is relevant as the main PR also tests scenarios involving the paused state of the token factory during IBC transfers.
  • feat: mint & burn e2e tests for fiattokenfactory #371: The main PR's focus on IBC transfers relates to the overall functionality of the fiat token factory, which is also tested in this PR that covers minting and burning operations, ensuring comprehensive testing of the factory's capabilities.

Suggested reviewers

  • kaliweh-circle

🐇 In the realm of tokens, we leap and bound,
With tests for IBC, our joy is profound.
From Noble to Gaia, the tokens will flow,
Through pauses and blacklists, our knowledge will grow.
So hop along, friends, let’s celebrate this feat,
For in testing we trust, our success is sweet! 🌟


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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

Comment on lines 64 to 66
// uusdc IBC denom on gaia
srcDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", gaiaToNobleChannelID, denomMetadataUsdc.Base))
dstIbcDenom := srcDenomTrace.IBCDenom()

Choose a reason for hiding this comment

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

If possible, these lines might fit in better with the setup (around line 44) rather than as part of the first test case since they appear to be shared across all the cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated:
5df6693 (#374)

gaiaWalletBal, err = gaia.GetBalance(ctx, gaiaWallet.FormattedAddress(), dstIbcDenom)
require.NoError(t, err)
require.Equal(t, transfer.Amount, gaiaWalletBal)
}

Choose a reason for hiding this comment

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

Any value in checking the noble wallet balance in any of the above cases? Or it's sufficient to just check the gaia balance?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is unnecessary as this is more testing core IBC functionality. However, I am happy to add the checks if you prefer.

Choose a reason for hiding this comment

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

Ok, I think this is sufficient for me. Thanks!

nobleWalletBal, err = noble.GetBalance(ctx, nobleWallet.FormattedAddress(), denomMetadataUsdc.Base)
require.NoError(t, err)
require.Equal(t, transfer.Amount, nobleWalletBal)
}

Choose a reason for hiding this comment

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

same question about checking the gaia balances in addition to the noble ones

@johnletey johnletey changed the base branch from feat/sdk-eden to main October 17, 2024 10:08
@johnletey johnletey requested a review from a team as a code owner October 17, 2024 10:08
@johnletey johnletey changed the title chore: IBC E2E tests for fiat token factory feat: ibc e2e tests for fiattokenfactory Oct 17, 2024
require.NoError(t, err)

ack, err := testutil.PollForAck(ctx, gaia, height, heightAfterFlush+5, tx.Packet)
require.NoError(t, err, "error polling for ack")
Copy link
Member

Choose a reason for hiding this comment

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

@boojamya We are running into the encoding issue we were experiencing with conformance tests 🤔

Maybe we can simply wait 5 blocks after flush, and that will be sufficient?

Copy link

@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

🧹 Outside diff range and nitpick comments (2)
e2e/fiat_tf_test.go (2)

1994-2000: Avoid reassigning amountToSend with different values

In TestFiatTFIBCIn, the variable amountToSend is assigned with mintAmount and later reassigned with math.OneInt(). This can lead to confusion. Use separate variables or reset the value appropriately to maintain clarity.


2040-2041: Assert specific error details in IBC acknowledgement

When checking the IBC acknowledgement for errors, consider asserting specific error codes or messages to make the test more precise and informative. This can help in quickly identifying the cause of failures.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4d9b4f5 and f39d0ed.

📒 Files selected for processing (1)
  • e2e/fiat_tf_test.go (2 hunks)
🧰 Additional context used
🔇 Additional comments (1)
e2e/fiat_tf_test.go (1)

2080-2098: Verify error handling when recipient is blacklisted during IBC transfer

Ensure that the test verifies the correct handling of errors when the recipient (nobleWallet) is blacklisted during an IBC transfer. Confirm that the funds are not received and appropriate error acknowledgements are returned.

Comment on lines +1852 to +1863
func TestFiatTFIBCOut(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

ctx := context.Background()

nw, gaia, _, r, ibcPathName, _, eRep, _, _ := e2e.NobleSpinUpIBC(t, ctx, true)
noble := nw.Chain
val := noble.Validators[0]

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor common test setup code into a helper function

The test functions TestFiatTFIBCOut and TestFiatTFIBCIn share similar setup code, including initializing contexts, spinning up networks, and creating wallets. Extracting these steps into a helper function can reduce code duplication and improve maintainability.

Comment on lines +1873 to +1880
nobleToGaiaChannelInfo, err := r.GetChannels(ctx, eRep, noble.Config().ChainID)
require.NoError(t, err)
nobleToGaiaChannelID := nobleToGaiaChannelInfo[0].ChannelID
// gaia -> noble channel info
gaiaToNobleChannelInfo, err := r.GetChannels(ctx, eRep, gaia.Config().ChainID)
require.NoError(t, err)
gaiaToNobleChannelID := gaiaToNobleChannelInfo[0].ChannelID

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Encapsulate channel retrieval logic into a utility function

The code for retrieving channel information between Noble and Gaia is duplicated. Consider creating a utility function to encapsulate the channel retrieval logic, which will enhance readability and reduce redundancy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants