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

Merged
merged 8 commits into from
Oct 29, 2024
Merged

feat: ibc e2e tests for fiattokenfactory #374

merged 8 commits into from
Oct 29, 2024

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

Suggested reviewers

  • kaliweh-circle
  • johnletey

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

@johnletey johnletey mentioned this pull request May 30, 2024
7 tasks
e2e/fiat_tf_test.go Outdated Show resolved Hide resolved
e2e/fiat_tf_test.go Show resolved Hide resolved
e2e/fiat_tf_test.go Show resolved Hide resolved
@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
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.

e2e/fiat_tf_test.go Show resolved Hide resolved
e2e/fiat_tf_test.go Show resolved Hide resolved
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: 5

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

1852-2122: Ensure proper cleanup of test environments

The test functions do not explicitly clean up or teardown the test environments after execution. While the testing framework might handle some of this, it's good practice to ensure that all resources are properly released, especially when dealing with network or file system resources.

Consider adding defer statements to clean up resources, such as:

defer func() {
	if err := nw.Cleanup(); err != nil {
		t.Logf("Error during cleanup: %v", err)
	}
}()

This helps prevent resource leaks and makes the tests more robust.


1852-2122: Add comments to improve readability

The complex logic within the test functions can benefit from additional inline comments to explain the purpose of various steps, especially around error handling and IBC transfer processes.

For example, before the block handling the paused chain:

// Attempt IBC transfer while the token factory is paused. Expect failure.

Adding such comments enhances maintainability and helps other developers understand the test flow.


13-17: Remove unused imports

The import "github.com/strangelove-ventures/interchaintest/v8/testutil" is not used in the file. Unused imports can clutter the code and should be removed.

Remove the unused import:

-	"github.com/strangelove-ventures/interchaintest/v8/testutil"

14-14: Reorder imports for better organization

It's a good practice to group imports into standard library packages, third-party packages, and local packages, separated by blank lines.

Reorder the imports as follows:

import (
	"context"
	"encoding/json"
	"fmt"
	"testing"

	"cosmossdk.io/math"
	sdk "github.com/cosmos/cosmos-sdk/types"

	fiattokenfactorytypes "github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory/types"
	"github.com/cosmos/cosmos-sdk/crypto/keyring"
	transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"

	"github.com/noble-assets/noble/e2e"
	"github.com/strangelove-ventures/interchaintest/v8"
	"github.com/strangelove-ventures/interchaintest/v8/ibc"
	"github.com/stretchr/testify/require"
)

This improves readability and follows Go's import conventions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

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

⛔ Files ignored due to path filters (2)
  • .github/workflows/e2e-tests.yaml is excluded by !**/*.yaml
  • e2e/go.mod is excluded by !**/*.mod
📒 Files selected for processing (1)
  • e2e/fiat_tf_test.go (2 hunks)
🔇 Additional comments (2)
e2e/fiat_tf_test.go (2)

1996-1999: Check for correct denomination in IBC transfer

In the transfer object:

transfer := ibc.WalletAmount{
	Address: nobleWallet.FormattedAddress(),
	Denom:   dstIbcDenom,
	Amount:  amountToSend,
}

Ensure that dstIbcDenom is the correct denomination for the return IBC transfer from Gaia to Noble.

Confirm that dstIbcDenom matches the expected IBC denomination on Gaia for the token being transferred back to Noble.


1913-1925: Possible race condition when blacklisting accounts

In the test case where the noble wallet is blacklisted and then used in an IBC transfer, there might be a race condition if the unblacklisting happens before the transfer is attempted. Ensure that the blacklisted state is maintained throughout the test case.

Verify that the account remains blacklisted during the transfer attempt. You might want to add a check to confirm the blacklisted status:

e2e/fiat_tf_test.go Show resolved Hide resolved
e2e/fiat_tf_test.go Show resolved Hide resolved
e2e/fiat_tf_test.go Show resolved Hide resolved
e2e/fiat_tf_test.go Show resolved Hide resolved
e2e/fiat_tf_test.go Show resolved Hide resolved
@boojamya boojamya enabled auto-merge (squash) October 28, 2024 14:33
Copy link
Member

@johnletey johnletey left a comment

Choose a reason for hiding this comment

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

LGTM! Passing on Cosmos SDK v0.50 ⚡

  • ✅ Green CI for TestFiatTFIBCOut (link)
  • ✅ Green CI for TestFiatTFIBCIn (link)

@boojamya boojamya merged commit 7d282f5 into main Oct 29, 2024
35 checks passed
@boojamya boojamya deleted the dan/fiat-tf-ibc branch October 29, 2024 08:14
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