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

refactor: remove dependency on simapp from baseapp tests #12543

Merged
merged 9 commits into from
Jul 12, 2022

Conversation

kocubinski
Copy link
Member

@kocubinski kocubinski commented Jul 12, 2022

Description

Ref: #12535

  • Refactors usages of simapp.MakeTestEncodingConfig() to depinject.
  • Refactors usage of simapp.NewSimApp to depinject with clear dependencies and explicit modules under test.
  • Does not address dependency on testutil (yet) which introduces a transitive dependency on simapp.

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

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

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.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@kocubinski kocubinski requested a review from a team as a code owner July 12, 2022 17:50
)

appConfig := depinject.Configs(makeTestConfig(),
depinject.ProvideInModule("bank",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
depinject.ProvideInModule("bank",
depinject.ProvideInModule(banktypes.ModuleName,

@@ -53,11 +54,13 @@ func TestGRPCQueryRouter(t *testing.T) {

func TestRegisterQueryServiceTwice(t *testing.T) {
// Setup baseapp.
var (
Copy link
Member

Choose a reason for hiding this comment

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

One line declaration is better.

}
// GenesisStateWithSingleValidator initializes GenesisState with a single validator and genesis accounts
// that also act as delegators.
func GenesisStateWithSingleValidator(t *testing.T, codec codec.Codec, builder *runtime.AppBuilder) map[string]json.RawMessage {
Copy link
Member

@julienrbrt julienrbrt Jul 12, 2022

Choose a reason for hiding this comment

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

Maybe this is what you meant in your comment, but shouldn't this be in /testutil/sims instead? simapp.GenesisStateWithSingleValidator was used in other tests, so this will most likely too after complete decoupling.

Copy link
Member Author

Choose a reason for hiding this comment

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

More or less; that function's signature looks like

func GenesisStateWithSingleValidator(t *testing.T, app *SimApp) GenesisState

so I can't use it here. Maybe we can live with a bit of code duplication until it's more clear?

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

lgtm! Just a few comments.

@kocubinski kocubinski added the A:automerge Automatically merge PR once all prerequisites pass. label Jul 12, 2022
@julienrbrt julienrbrt merged commit 9f95534 into main Jul 12, 2022
@julienrbrt julienrbrt deleted the kocubinski/refactor-baseapp-simapp branch July 12, 2022 22:17
@julienrbrt julienrbrt linked an issue Jul 12, 2022 that may be closed by this pull request
Comment on lines +31 to +37
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
Copy link
Member

Choose a reason for hiding this comment

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

im hesitant introducing these dependencies into baseapp. I think this should be rethought.

Copy link
Member Author

Choose a reason for hiding this comment

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

baseapp already depended on these packages transitively through simapp. Now they are specified explicitly instead of implicitly. There is an overall reduction in the size of the dependency graph.

Copy link
Member

Choose a reason for hiding this comment

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

yes, it was fine before. Im thinking more in the future when things become their own go mods. It could be a pre-optimization though. we can ignore for now

Comment on lines +11 to +36
runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1"
txmodulev1 "cosmossdk.io/api/cosmos/tx/module/v1"
"cosmossdk.io/core/appconfig"
"cosmossdk.io/depinject"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil/mock"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
_ "github.com/cosmos/cosmos-sdk/x/auth"
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
_ "github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/mint"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Member Author

Choose a reason for hiding this comment

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

@tac0turtle
Copy link
Member

in the future lets wait for two approvals, this was merged too fast. It didnt have enough eyes

@kocubinski
Copy link
Member Author

@marbar3778 responded to your concerns above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove dependency from baseapp -> simapp
3 participants