-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
chore: remove baseapp and sdk.Context
fully from x/upgrade
#23396
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThis pull request introduces significant changes to the Cosmos SDK testing infrastructure, focusing on creating a new Changes
Suggested labels
Suggested reviewers
Possibly related PRs
📜 Recent review detailsConfiguration used: .coderabbit.yml ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ Context from checks skipped due to timeout of 90000ms (1)
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: 0
🧹 Nitpick comments (4)
core/testing/branch.go (2)
18-25
: Consider implementing actual gas tracking in ExecuteWithGasLimit.The current implementation always returns the input gasLimit without tracking actual gas consumption, which might be misleading in tests that rely on accurate gas measurements.
func (bs TestBranchService) ExecuteWithGasLimit( ctx context.Context, gasLimit uint64, f func(ctx context.Context) error, ) (gasUsed uint64, err error) { unwrap(ctx) // check that this is a testing context - return gasLimit, f(ctx) + err = f(ctx) + // Return a portion of gasLimit to simulate actual consumption + gasUsed = gasLimit / 2 + return gasUsed, err }
9-11
: Add documentation for exported types and methods.The
TestBranchService
type and its methods are exported but lack documentation comments. This makes it harder for other developers to understand their purpose and usage.+// TestBranchService implements branch.Service for testing purposes. var _ branch.Service = &TestBranchService{} +// TestBranchService provides a minimal implementation of branch.Service for testing. type TestBranchService struct{}x/upgrade/keeper/keeper.go (1)
Line range hint
440-449
: Consider adding error handling for nil versionModifier.The code checks for nil
versionModifier
but doesn't handle potential errors fromAppVersion()
andSetAppVersion()
consistently.Consider this implementation:
if k.versionModifier != nil { currentAppVersion, err := k.versionModifier.AppVersion(ctx) if err != nil { return err } - - if err := k.versionModifier.SetAppVersion(ctx, currentAppVersion+1); err != nil { - return err - } + return k.versionModifier.SetAppVersion(ctx, currentAppVersion+1) }x/upgrade/keeper/abci_test.go (1)
71-85
: Consider adding validation in version modifier.The mocked version modifier implementation could benefit from basic validation.
Consider adding validation:
func (m *mockedVersionModifier) SetAppVersion(_ context.Context, u uint64) error { + if u < m.version { + return fmt.Errorf("cannot decrease version from %d to %d", m.version, u) + } m.version = u return nil }
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
go.sum
is excluded by!**/*.sum
x/circuit/go.sum
is excluded by!**/*.sum
x/upgrade/go.sum
is excluded by!**/*.sum
📒 Files selected for processing (16)
core/testing/branch.go
(1 hunks)core/testing/environment.go
(1 hunks)go.mod
(1 hunks)tests/integration/bank/app_test.go
(2 hunks)tests/integration/baseapp/block_gas_test.go
(1 hunks)x/auth/ante/testutil_test.go
(1 hunks)x/auth/keeper/deterministic_test.go
(3 hunks)x/auth/keeper/grpc_query_test.go
(2 hunks)x/auth/keeper/keeper_test.go
(5 hunks)x/auth/tx/config/depinject.go
(0 hunks)x/circuit/go.mod
(1 hunks)x/upgrade/go.mod
(2 hunks)x/upgrade/keeper/abci_test.go
(16 hunks)x/upgrade/keeper/grpc_query_test.go
(5 hunks)x/upgrade/keeper/keeper.go
(3 hunks)x/upgrade/keeper/keeper_test.go
(7 hunks)
💤 Files with no reviewable changes (1)
- x/auth/tx/config/depinject.go
✅ Files skipped from review due to trivial changes (2)
- x/auth/keeper/grpc_query_test.go
- x/circuit/go.mod
🧰 Additional context used
📓 Path-based instructions (11)
x/auth/ante/testutil_test.go (2)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern **/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
tests/integration/baseapp/block_gas_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"
core/testing/environment.go (1)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
x/upgrade/keeper/keeper.go (1)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
tests/integration/bank/app_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"
core/testing/branch.go (1)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
x/auth/keeper/keeper_test.go (2)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern **/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
x/upgrade/keeper/grpc_query_test.go (2)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern **/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
x/auth/keeper/deterministic_test.go (2)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern **/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
x/upgrade/keeper/keeper_test.go (2)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern **/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
x/upgrade/keeper/abci_test.go (2)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern **/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: test-system-v2
- GitHub Check: Analyze
- GitHub Check: Summary
🔇 Additional comments (27)
core/testing/environment.go (1)
36-36
: LGTM!Initializing
BranchService
withTestBranchService{}
aligns with the PR objective of removing baseapp dependencies.x/upgrade/keeper/grpc_query_test.go (3)
31-32
: LGTM!The type changes from
sdk.Context
tocoretesting.TestContext
align with the PR objective of removing SDK context dependencies.
41-47
: LGTM!The test environment setup is clean and properly initialized with the required configuration.
103-103
: Verify all context usage is updated consistently.Ensure that all query client calls use the test context consistently. Let's verify this:
Also applies to: 161-161, 211-211
tests/integration/baseapp/block_gas_test.go (1)
104-105
: LGTM!Setting the transaction encoder and decoder is necessary for proper transaction handling in the test environment.
x/auth/keeper/keeper_test.go (4)
13-14
: LGTM! Import changes align with the new query handling pattern.The addition of the
queryclient
package supports the transition away from baseapp dependencies.
54-58
: LGTM! Environment setup follows the new testing pattern.The use of
coretesting.NewTestEnvironment
provides a more modular and maintainable test setup.
Line range hint
81-89
: LGTM! Keeper initialization updated correctly.The environment parameter is properly passed to the keeper constructor.
91-93
: LGTM! Query helper setup follows the new pattern.The transition to
queryclient.NewQueryHelper
withcodec.NewProtoCodec
improves the query handling mechanism.x/auth/ante/testutil_test.go (1)
99-100
: LGTM! Environment setup simplified correctly.The environment initialization has been streamlined by removing baseapp dependencies.
x/upgrade/keeper/keeper_test.go (4)
13-14
: LGTM! Import changes support new functionality.The addition of server and queryclient packages aligns with the module's requirements.
33-35
: LGTM! Type declarations updated appropriately.The change to use
coretesting
types improves test environment management.
68-76
: LGTM! Keeper initialization updated correctly.The keeper parameters are properly configured with the new environment setup.
Line range hint
289-307
: LGTM! Version checks implemented correctly.The context usage in version checks is consistent with the new context management approach.
x/auth/keeper/deterministic_test.go (3)
17-17
: LGTM! Import changes align with new query handling.The addition of the queryclient package supports the new query helper pattern.
263-265
: LGTM! Query helper initialization follows new pattern.The use of
queryclient.NewQueryHelper
withcodec.NewProtoCodec
improves query handling.
269-269
: LGTM! Context type updated appropriately.The parameter type change to
context.Context
aligns with the new context management approach.x/upgrade/keeper/keeper.go (2)
37-37
: LGTM! Clear and accurate documentation.The updated comment for
versionModifier
field accurately describes its purpose without tying it to a specific implementation.
50-50
: LGTM! Improved parameter documentation.The updated comment for the
vs
parameter provides a clearer description of its functionality.tests/integration/bank/app_test.go (3)
93-93
: TODO comment needs clarification.The TODO comment about using a v2 application lacks context and actionable details.
Please clarify:
- What is a v2 application?
- What are the requirements or blockers?
- Is there a tracking issue?
Line range hint
94-115
: LGTM! Improved test setup readability.The expanded configuration parameters enhance code readability and maintainability.
118-119
: LGTM! Proper transaction handling setup.The addition of TxEncoder and TxDecoder setup ensures proper transaction handling in tests.
x/upgrade/keeper/abci_test.go (2)
36-38
: LGTM! Clear test suite structure.The updated TestSuite structure properly uses the new testing infrastructure.
40-69
: LGTM! Well-structured test setup.The setupTest function properly initializes the test environment with all necessary components.
go.mod (1)
173-173
: LGTM! Proper module replacement.The replace directive correctly points to the local core/testing implementation.
x/upgrade/go.mod (2)
73-73
: LGTM: Addition of cometbft/api as indirect dependencyThe addition of
github.com/cometbft/cometbft/api
as an indirect dependency aligns with the PR's objective of removing baseapp dependencies.
200-203
: LGTM: Well-organized replace directivesThe replace directives are properly organized, grouping related replacements together. The addition of
cosmossdk.io/core/testing
replacement is consistent with the module's testing requirements.
Description
Closes: #XXXX
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
Release Notes
New Features
coretesting
with enhanced test environment support.Refactoring
baseapp
in multiple modules.Chores
Testing