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: add x/group app wiring integration tests #12243

Merged
merged 37 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3d986bf
wip: migrate x/group to app wiring
likhita-809 Jun 1, 2022
a8e44d5
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk into likh…
likhita-809 Jun 7, 2022
21769ea
wip
likhita-809 Jun 7, 2022
223257d
wip
likhita-809 Jun 7, 2022
2d85b33
add inline doc for group module proto
likhita-809 Jun 7, 2022
2a6a54a
fix tests
likhita-809 Jun 7, 2022
4fb021b
address review comments
likhita-809 Jun 7, 2022
46464d4
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk into likh…
likhita-809 Jun 7, 2022
d7d1a21
minor code changes
likhita-809 Jun 8, 2022
4abad9c
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk into likh…
likhita-809 Jun 8, 2022
9a57e1e
improve goline doc
likhita-809 Jun 8, 2022
d250e28
address review comments
likhita-809 Jun 8, 2022
c1e64b7
nit
likhita-809 Jun 8, 2022
a64cc94
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk into likh…
likhita-809 Jun 8, 2022
020ac3b
add default value for group config's max_execution_period
likhita-809 Jun 9, 2022
13e7482
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk into likh…
likhita-809 Jun 9, 2022
bf33bbe
fix conflicts
likhita-809 Jun 9, 2022
7aef0d5
fix failing tests
likhita-809 Jun 9, 2022
c78d40e
refactor code
likhita-809 Jun 9, 2022
457eef8
fix tests
likhita-809 Jun 9, 2022
40e8808
fix yaml parsing for maxExecutionPeriod
likhita-809 Jun 10, 2022
425ef47
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk into likh…
likhita-809 Jun 10, 2022
4f90a96
fix protobuf lint
likhita-809 Jun 10, 2022
4856431
use duration type for max_execution_period
likhita-809 Jun 10, 2022
dadf2df
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk into likh…
likhita-809 Jun 13, 2022
d97cf43
refactor module.go in group's module
likhita-809 Jun 13, 2022
89f6d86
app yaml for integration tests in x/group
likhita-809 Jun 13, 2022
20417a4
Merge branch 'likhita/group-app-wiring-2' of https://github.com/cosmo…
likhita-809 Jun 13, 2022
bb2a9e4
wip
likhita-809 Jun 14, 2022
07b7f27
fix: testutil network app config setup
aaronc Jun 14, 2022
9470484
Update testutil/network/network.go
aaronc Jun 14, 2022
badb2cb
Update testutil/network/network.go
aaronc Jun 14, 2022
09c3658
fmt
aaronc Jun 14, 2022
bd93dcb
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk into likh…
likhita-809 Jun 15, 2022
9730588
Merge branch 'aaronc/fix-network-app-config' of https://github.com/co…
likhita-809 Jun 15, 2022
ebf91d0
fix test
likhita-809 Jun 15, 2022
8a2ab88
address review comments
likhita-809 Jun 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
665 changes: 665 additions & 0 deletions api/cosmos/group/v1/module/v1/module.pulsar.go

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions proto/cosmos/group/v1/module/v1/module.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";

package cosmos.group.v1.module.v1;

import "cosmos/app/v1alpha1/module.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";

// Module is the config object of the group module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/cosmos/cosmos-sdk/x/group"
};

// max_execution_period defines the max duration after a proposal's voting period ends that members can send a MsgExec to execute the proposal.
google.protobuf.Duration max_execution_period = 1 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];

// max_metadata_len defines the max length of the metadata bytes field for various entities within the group module. Defaults to 255 if not explicitly set.
uint64 max_metadata_len = 2;
}
10 changes: 1 addition & 9 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ func NewSimApp(
&app.AuthzKeeper,
&app.FeeGrantKeeper,
&app.StakingKeeper,
&app.GroupKeeper,
&app.NFTKeeper,
&app.SlashingKeeper,
&msgServiceRouter,
Expand All @@ -237,7 +238,6 @@ func NewSimApp(
minttypes.StoreKey, distrtypes.StoreKey,
govtypes.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey,
group.StoreKey,
)
// NOTE: The testingkey is just mounted for testing purposes. Actual applications should
// not include this key.
Expand Down Expand Up @@ -267,13 +267,6 @@ func NewSimApp(
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()),
)

groupConfig := group.DefaultConfig()
/*
Example of setting group params:
groupConfig.MaxMetadataLen = 1000
*/
app.GroupKeeper = groupkeeper.NewKeeper(app.keys[group.StoreKey], app.appCodec, app.MsgServiceRouter(), app.AccountKeeper, groupConfig)

// register the proposal types
govRouter := govv1beta1.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
Expand Down Expand Up @@ -321,7 +314,6 @@ func NewSimApp(
distr.NewAppModule(app.appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
upgrade.NewAppModule(app.UpgradeKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
groupmodule.NewAppModule(app.appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
); err != nil {
panic(err)
}
Expand Down
6 changes: 6 additions & 0 deletions simapp/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ modules:
config:
"@type": cosmos.staking.module.v1.Module

- name: group
config:
"@type": cosmos.group.v1.module.v1.Module
max_metadata_len: 255
max_execution_period: "1209600s"

- name: nft
config:
"@type": cosmos.nft.module.v1.Module
Expand Down
6 changes: 5 additions & 1 deletion x/group/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
package testutil

import (
_ "embed"
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
"testing"

"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/x/group/testutil"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)

func TestIntegrationTestSuite(t *testing.T) {
cfg := network.DefaultConfig()
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg.NumValidators = 2
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
suite.Run(t, NewIntegrationTestSuite(cfg))
}
55 changes: 53 additions & 2 deletions x/group/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ import (
"fmt"
"math/rand"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"cosmossdk.io/core/appmodule"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"

modulev1 "cosmossdk.io/api/cosmos/group/v1/module/v1"
"github.com/cosmos/cosmos-sdk/baseapp"
sdkclient "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/depinject"
"github.com/cosmos/cosmos-sdk/runtime"
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
Expand Down Expand Up @@ -82,7 +88,7 @@ func (a AppModuleBasic) GetTxCmd() *cobra.Command {
}

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the group module.
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) {
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *gwruntime.ServeMux) {
if err := group.RegisterQueryHandlerClient(context.Background(), mux, group.NewQueryClient(clientCtx)); err != nil {
panic(err)
}
Expand Down Expand Up @@ -155,6 +161,51 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val
return []abci.ValidatorUpdate{}
}

func init() {
appmodule.Register(
&modulev1.Module{},
appmodule.Provide(
provideModuleBasic,
provideModule,
),
)
}

func provideModuleBasic() runtime.AppModuleBasicWrapper {
return runtime.WrapAppModuleBasic(AppModuleBasic{})
}

type groupInputs struct {
depinject.In

Config *modulev1.Module
Key *store.KVStoreKey
Cdc codec.Codec
AccountKeeper group.AccountKeeper
BankKeeper group.BankKeeper
Registry cdctypes.InterfaceRegistry
MsgServiceRouter *baseapp.MsgServiceRouter
}

type groupOutputs struct {
depinject.Out

GroupKeeper keeper.Keeper
Module runtime.AppModuleWrapper
}

func provideModule(in groupInputs) groupOutputs {
/*
Example of setting group params:
in.Config.MaxMetadataLen = 1000
in.Config.MaxExecutionPeriod = "1209600s"
*/

k := keeper.NewKeeper(in.Key, in.Cdc, in.MsgServiceRouter, in.AccountKeeper, group.Config{MaxExecutionPeriod: in.Config.MaxExecutionPeriod.AsDuration(), MaxMetadataLen: in.Config.MaxMetadataLen})
m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry)
return groupOutputs{GroupKeeper: k, Module: runtime.WrapAppModule(m)}
}

// ____________________________________________________________________________

// AppModuleSimulation functions
Expand Down
49 changes: 49 additions & 0 deletions x/group/testutil/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
modules:
- name: runtime
config:
"@type": cosmos.app.runtime.v1alpha1.Module

app_name: GroupApp

begin_blockers: [staking, auth, bank, genutil, authz, group, params]
end_blockers: [staking, auth, bank, genutil, authz, group, params]
init_genesis: [auth, bank, staking, genutil, authz, group, params]

- name: auth
config:
"@type": cosmos.auth.module.v1.Module
bech32_prefix: cosmos
module_account_permissions:
- account: fee_collector
- account: bonded_tokens_pool
permissions: [burner, staking]
- account: not_bonded_tokens_pool
permissions: [burner, staking]

- name: bank
config:
"@type": cosmos.bank.module.v1.Module

- name: params
config:
"@type": cosmos.params.module.v1.Module

- name: tx
config:
"@type": cosmos.tx.module.v1.Module

- name: staking
config:
"@type": cosmos.staking.module.v1.Module

- name: authz
config:
"@type": cosmos.authz.module.v1.Module

- name: group
config:
"@type": cosmos.group.v1.module.v1.Module

- name: genutil
config:
"@type": cosmos.genutil.module.v1.Module
12 changes: 12 additions & 0 deletions x/group/testutil/app_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package testutil

import (
_ "embed"

likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
"cosmossdk.io/core/appconfig"
)

//go:embed app.yaml
var appConfig []byte

var AppConfig = appconfig.LoadYAML(appConfig)