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: minter e2e tests for fiattokenfactory #368

Merged
merged 1 commit into from
Oct 17, 2024
Merged

Conversation

boojamya
Copy link
Member

@boojamya boojamya commented May 27, 2024

Includes:

  • TestFiatTFUpdateMasterMinter
  • TestFiatTFConfigureMinterController
  • TestFiatTFRemoveMinterController
  • TestFiatTFConfigureMinter
  • TestFiatTFRemoveMinter

Copy link

coderabbitai bot commented May 27, 2024

Walkthrough

The changes in this pull request enhance the testing suite for the fiat token factory by adding several new test functions in the e2e/fiat_tf_test.go file. These tests cover various scenarios related to minting operations, including handling paused states and unauthorized access. Additionally, the e2e/utils.go file has been updated to rename several functions for consistency, ensuring that all exported function names start with an uppercase letter.

Changes

File Change Summary
e2e/fiat_tf_test.go Added new test functions: TestFiatTFUpdateMasterMinter, TestFiatTFConfigureMinterController, TestFiatTFRemoveMinterController, TestFiatTFConfigureMinter, and TestFiatTFRemoveMinter.
e2e/utils.go Renamed several functions for consistent naming convention: unblacklistAccount to UnblacklistAccount, setupMinterAndController to SetupMinterAndController, configureMinter to ConfigureMinter, showMinterController to ShowMinterController, showMinters to ShowMinters, showMasterMinter to ShowMasterMinter, showBlacklister to ShowBlacklister, showBlacklisted to ShowBlacklisted, and showPaused to ShowPaused. Updated comments accordingly.

Possibly related PRs

Suggested reviewers

  • kaliweh-circle

Poem

In the code where bunnies hop,
New tests bloom, they never stop!
With names so bright, they lead the way,
For fiat tokens, come what may!
Hopping high, we celebrate,
Consistent names, oh, what a fate! 🐇✨


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.

e2e/fiat_tf_test.go Show resolved Hide resolved
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
e2e/fiat_tf_test.go Outdated Show resolved Hide resolved
e2e/fiat_tf_test.go Show resolved Hide resolved
e2e/fiat_tf_test.go Outdated Show resolved Hide resolved
e2e/fiat_tf_test.go Show resolved Hide resolved
e2e/fiat_tf_test.go Outdated Show resolved Hide resolved
Copy link

@circle-smartin circle-smartin left a comment

Choose a reason for hiding this comment

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

One small comment. Thanks for working on these Dan!

e2e/fiat_tf_test.go Show resolved Hide resolved
e2e/fiat_tf_test.go Outdated Show resolved Hide resolved
// minterController1 -> minter4
// minterController2 -> minter2
// minterController3 -> minter3
// minter1 dissociated from minter but has allowance

Choose a reason for hiding this comment

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

nit: incorrect comment.

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 in: 70e992c

Comment on lines 279 to 282
// minterController1 -> minter4
// minterController2 -> minter2
// minterController3 -> minter3
// minter1 dissociated from minter but has allowance

Choose a reason for hiding this comment

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

nit: reusing existing states in the same test makes the test more brittle. i.e. it would be better to create dedicated accounts for each test-case instead of reusing them.

e2e/fiat_tf_test.go Outdated Show resolved Hide resolved
// ACTION: Happy path: Configure minter
// EXPECTED: Success; Minter is configured with allowance

configureMinter(t, ctx, val, nw.fiatTfRoles.MinterController, nw.fiatTfRoles.Minter, 20)

Choose a reason for hiding this comment

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

missing: verifying the minter allowance was set properly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Verification is done inside the configureMinter function. See:

noble/e2e/utils.go

Lines 483 to 499 in 9143e5c

func configureMinter(t *testing.T, ctx context.Context, val *cosmos.ChainNode, minterController, minter ibc.Wallet, allowance int64) {
_, err := val.ExecTx(ctx, minterController.KeyName(), "fiat-tokenfactory", "configure-minter", minter.FormattedAddress(), fmt.Sprintf("%duusdc", allowance))
require.NoError(t, err, "error configuring minter")
showMinter, err := showMinters(ctx, val, minter)
require.NoError(t, err, "failed to query show-minter")
expectedShowMinters := fiattokenfactorytypes.QueryGetMintersResponse{
Minters: fiattokenfactorytypes.Minters{
Address: minter.FormattedAddress(),
Allowance: sdktypes.Coin{
Denom: "uusdc",
Amount: math.NewInt(allowance),
},
},
}
require.Equal(t, expectedShowMinters.Minters, showMinter.Minters)


blacklistAccount(t, ctx, val, nw.fiatTfRoles.Blacklister, minter1)

configureMinter(t, ctx, val, minterController1, minter1, 11)

Choose a reason for hiding this comment

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

missing, verify the minter was configured and the allowance is set properly.

Copy link
Member Author

Choose a reason for hiding this comment

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

@johnletey johnletey changed the base branch from feat/sdk-eden to main October 17, 2024 08:28
@johnletey johnletey requested a review from a team as a code owner October 17, 2024 08:28
Co-authored-by: Dan Kanefsky <dan@noble.xyz>
@johnletey johnletey changed the title chore: minter E2E tests for fiat token factory feat: minter e2e tests for fiattokenfactory Oct 17, 2024
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 TestFiatTFUpdateMasterMinter (link)
  • ✅ Green CI for TestFiatTFConfigureMinterController (link)
  • ✅ Green CI for TestFiatTFRemoveMinterController (link)
  • ✅ Green CI for TestFiatTFConfigureMinter (link)
  • ✅ Green CI for TestFiatTFRemoveMinter (link)

@johnletey johnletey merged commit 7c0fce0 into main Oct 17, 2024
20 checks passed
@johnletey johnletey deleted the dan/fiat-tf-minter branch October 17, 2024 08:50
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: 0

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

Line range hint 683-683: Consider renaming showBlacklister to ShowBlacklister

For consistency with the other exported functions in this file, consider renaming showBlacklister to ShowBlacklister. This would make it an exported function and follow the same naming convention as the other utility functions in this file.


Line range hint 700-700: Consider renaming showBlacklisted to ShowBlacklisted

For consistency with the other exported functions in this file, consider renaming showBlacklisted to ShowBlacklisted. This would make it an exported function and follow the same naming convention as the other utility functions in this file.


Line range hint 718-718: Consider renaming showPaused to ShowPaused

For consistency with the other exported functions in this file, consider renaming showPaused to ShowPaused. This would make it an exported function and follow the same naming convention as the other utility functions in this file.


Line range hint 1-734: Overall improvements in naming conventions with a few remaining inconsistencies

The changes in this file primarily focus on renaming functions to follow Go's naming conventions for exported functions. This improves the overall consistency and adherence to Go best practices. Most functions have been correctly renamed, such as UnblacklistAccount, SetupMinterAndController, ConfigureMinter, etc.

However, there are still three functions that haven't been renamed:

  1. showBlacklister
  2. showBlacklisted
  3. showPaused

For complete consistency, consider renaming these functions to ShowBlacklister, ShowBlacklisted, and ShowPaused respectively.

No logic changes were made to any of the functions, which is appropriate for this type of refactoring.

e2e/fiat_tf_test.go (2)

593-594: Typo in comment: "Remove a a non existent Minter Controller"

There's a duplication of the word "a" in the comment. It should be:

-// ACTION: Remove a a non existent Minter Controller
+// ACTION: Remove a non-existent Minter Controller

681-682: Clarify the action comment for better understanding

The action comment is grammatically incorrect:

-// ACTION: Configure a minter is blacklisted from a blacklisted minter controller
+// ACTION: Configure a blacklisted minter from a blacklisted minter controller

This rephrasing improves clarity for future maintainers.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8361d3f and d8344e3.

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

501-503: LGTM: Function renamed to follow Go conventions

The function has been correctly renamed from unblacklistAccount to UnblacklistAccount, following Go's naming convention for exported functions. The implementation remains unchanged and correct.


553-554: LGTM: Function renamed to follow Go conventions

The function has been correctly renamed from setupMinterAndController to SetupMinterAndController, adhering to Go's naming convention for exported functions. The implementation remains unchanged and correct.


577-579: LGTM: Function renamed to follow Go conventions

The function has been appropriately renamed from configureMinter to ConfigureMinter, following Go's naming convention for exported functions. The implementation remains unchanged and correct.


598-600: LGTM: Function renamed to follow Go conventions

The function has been correctly renamed from showMinterController to ShowMinterController, adhering to Go's naming convention for exported functions. The implementation remains unchanged and correct.


615-617: LGTM: Function renamed to follow Go conventions

The function has been appropriately renamed from showMinters to ShowMinters, following Go's naming convention for exported functions. The implementation remains unchanged and correct.


648-649: LGTM: Function renamed to follow Go conventions

The function has been correctly renamed from showMasterMinter to ShowMasterMinter, adhering to Go's naming convention for exported functions. The implementation remains unchanged and correct.

e2e/fiat_tf_test.go (5)

178-291: TestFiatTFUpdateMasterMinter test cases are comprehensive and well-structured

The test cases thoroughly cover scenarios for updating the Master Minter, including:

  • Happy path updates.
  • Updates while the token factory is paused.
  • Unauthorized update attempts.
  • Updates involving blacklisted accounts.

Assertions are appropriately used to verify expected outcomes, ensuring the functionality behaves as intended.


293-506: TestFiatTFConfigureMinterController tests effectively validate minter controller configurations

This test function comprehensively covers:

  • Configuring minter controllers in normal conditions.
  • Configurations while the token factory is paused.
  • Unauthorized configuration attempts.
  • Configurations involving blacklisted minter controllers and minters.
  • Reassigning minter controllers to new minters.
  • Assigning multiple controllers to a single minter.

The tests are well-implemented, and assertions confirm that the system state aligns with expectations after each action.


507-602: TestFiatTFRemoveMinterController tests cover essential removal scenarios

The test cases include:

  • Happy path removal of a minter controller.
  • Removal while the token factory is paused.
  • Unauthorized removal attempts.
  • Removal involving blacklisted master minter and minter controller.
  • Attempting to remove a non-existent minter controller.

Assertions are correctly used to validate that the minter controllers are removed or maintained as expected.


603-692: TestFiatTFConfigureMinter tests are thorough and correctly implemented

The test function covers:

  • Configuring a minter in normal conditions.
  • Attempting to configure a minter while the token factory is paused (expecting failure).
  • Unauthorized configuration attempts from incorrect minter controllers.
  • Configuring a blacklisted minter from a blacklisted minter controller.

The tests effectively validate the expected behaviors, and the assertions confirm the system responds appropriately in each scenario.


694-775: TestFiatTFRemoveMinter tests effectively cover minter removal scenarios

The test cases include:

  • Happy path removal of a minter.
  • Removal while the token factory is paused.
  • Unauthorized removal attempts by a minter controller not associated with the minter.
  • Removal involving blacklisted minter controller and minter.

Assertions are appropriately used to verify that minters are removed or retained as expected in each scenario.

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