-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
refactor(tests/integration): Port x/accounts integration tests to server v2 #22881
Conversation
📝 WalkthroughWalkthroughThis pull request involves a comprehensive refactoring of integration tests for the Cosmos SDK accounts module. The changes include deleting old test files in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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
🧹 Nitpick comments (2)
tests/integration/v2/accounts/fixture_test.go (1)
36-36
: Remove the Extraneous Backticks in CommentThere's an extra backtick at the end of the comment in line 36.
Apply the following diff:
- _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiring`` + _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import as blank for app wiringtests/integration/v2/accounts/base_account_test.go (1)
81-89
: Improve Error Message intoAnyPb
FunctionThe error message
"no"
int.Fatal("no")
is not descriptive. Consider providing a more informative message to aid in debugging.Apply this diff to enhance the error message:
if gogoproto.MessageName(pm) == gogoproto.MessageName(&gogoany.Any{}) { - t.Fatal("no") + t.Fatal("cannot convert a message of type Any to protobuf Any representation") }
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
tests/integration/accounts/base_account_test.go
(0 hunks)tests/integration/accounts/fixture_test.go
(0 hunks)tests/integration/v2/accounts/base_account_test.go
(1 hunks)tests/integration/v2/accounts/fixture_test.go
(1 hunks)tests/integration/v2/accounts/wiring_test.go
(3 hunks)tests/integration/v2/services.go
(3 hunks)
💤 Files with no reviewable changes (2)
- tests/integration/accounts/fixture_test.go
- tests/integration/accounts/base_account_test.go
🧰 Additional context used
📓 Path-based instructions (4)
tests/integration/v2/accounts/base_account_test.go (3)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern tests/**/*
: "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"
tests/integration/v2/accounts/fixture_test.go (3)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern tests/**/*
: "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"
tests/integration/v2/services.go (2)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern tests/**/*
: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"
tests/integration/v2/accounts/wiring_test.go (3)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern tests/**/*
: "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 (4)
tests/integration/v2/accounts/wiring_test.go (4)
9-9
: LGTM: Import changes align with server v2 migration
The updated imports correctly reflect the transition to server v2's gas metering system and integration test utilities.
Also applies to: 13-13
30-36
: LGTM: Account initialization properly uses fixture keepers
The account initialization and funding logic is correctly implemented using the fixture's keepers while maintaining proper error handling.
Line range hint 39-69
: LGTM: Comprehensive test coverage with proper assertions
The test thoroughly verifies all components:
- Transaction execution
- Gas consumption
- Header information
- Address codec functionality
- Fund transfers and balance checks
All verifications properly utilize the fixture's keepers and maintain strong assertions.
25-28
: LGTM: Clean test setup with fixture pattern
The test setup has been improved using a fixture-based approach, which enhances modularity and maintainability. The gas meter and header configurations are properly initialized using the new v2 utilities.
Let's verify the fixture initialization implementation:
✅ Verification successful
LGTM: Fixture initialization is properly implemented
The fixture implementation in tests/integration/v2/accounts/fixture_test.go
follows good testing practices:
- Uses test helper pattern with
t.Helper()
- Sets up proper module encoding configuration
- Initializes necessary module dependencies (accounts, auth)
- Provides a clean context with header and gas meter configuration
The usage in wiring_test.go
correctly leverages the fixture for test setup.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check the fixture implementation
ast-grep --pattern 'func initFixture($$$) *testing.($$$)'
Length of output: 59
Script:
#!/bin/bash
# Let's try a broader search for the fixture implementation
rg "func initFixture" -A 5
# Also search for any imports of fixture-related types
rg "import.*fixture" --type go
# Search for the integration package usage
rg "integration\." --type go -A 2
Length of output: 60759
Script:
#!/bin/bash
# Let's check the fixture implementation in the specific file
rg -A 10 "func initFixture" tests/integration/v2/accounts/fixture_test.go
# Also check for any test files that use this fixture
rg "initFixture.*\(" tests/integration/v2/accounts/wiring_test.go -A 5
Length of output: 815
type mockAccount struct { | ||
authenticate authentiacteFunc | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct the Typo in authentiacteFunc
Type Name
There's a typo in the type name authentiacteFunc
; it should be authenticateFunc
.
Apply the following diff to fix the typo:
- type authentiacteFunc = func(ctx context.Context, msg *account_abstractionv1.MsgAuthenticate) (*account_abstractionv1.MsgAuthenticateResponse, error)
+ type authenticateFunc = func(ctx context.Context, msg *account_abstractionv1.MsgAuthenticate) (*account_abstractionv1.MsgAuthenticateResponse, error)
Also, update its usage in the mockAccount
struct:
type mockAccount struct {
- authenticate authentiacteFunc
+ authenticate authenticateFunc
}
Also applies to: 69-70
_ = originalGasMeter.Consume(gasUsed, "execute-with-gas-limit") | ||
iCtx.gasMeter = stfgas.DefaultGasMeter(originalGasMeter.Remaining()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Handle Potential Errors from Gas Consumption
The error returned by originalGasMeter.Consume()
is ignored. It's important to check and handle this error to prevent unexpected behavior if gas consumption fails.
Apply this diff to handle the error:
- _ = originalGasMeter.Consume(gasUsed, "execute-with-gas-limit")
+ errConsume := originalGasMeter.Consume(gasUsed, "execute-with-gas-limit")
+ if errConsume != nil {
+ return gasUsed, errConsume
+ }
Committable suggestion skipped: line range outside the PR's diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Description
ref: #20799
part 1 of x/accounts integration tests, lockup and multisig tests will be in another PR
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...
!
in the type prefix if API or client breaking changeCHANGELOG.md
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.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
New Features
Bug Fixes
Chores