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: replace app wiring yaml config by go #12757

Merged
merged 10 commits into from
Jul 29, 2022
6 changes: 3 additions & 3 deletions simapp/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ import (
vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1"
)

// Alternatively the AppConfig can be defined as a YAML or a JSON file.
// e.g. https://github.com/cosmos/cosmos-sdk/blob/91b1d83f1339e235a1dfa929ecc00084101a19e3/simapp/app.yaml

var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Modules: []*appv1alpha1.ModuleConfig{
{
Expand Down Expand Up @@ -122,7 +125,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
},
}),
},

{
Name: vestingtypes.ModuleName,
Config: appconfig.WrapAny(&vestingmodulev1.Module{}),
Expand Down Expand Up @@ -202,5 +204,3 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{
},
},
})

// Alternatively this configuration can be set as yaml or json: https://github.com/cosmos/cosmos-sdk/blob/91b1d83f1339e235a1dfa929ecc00084101a19e3/simapp/app.yaml
10 changes: 4 additions & 6 deletions tests/e2e/auth/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ package testutil
import (
"testing"

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/network"
testutil2 "github.com/cosmos/cosmos-sdk/x/auth/client/testutil"
"github.com/cosmos/cosmos-sdk/x/auth/testutil"
clientestutil "github.com/cosmos/cosmos-sdk/x/auth/client/testutil"

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

func TestIntegrationTestSuite(t *testing.T) {
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 2
suite.Run(t, testutil2.NewIntegrationTestSuite(cfg))
suite.Run(t, clientestutil.NewIntegrationTestSuite(cfg))
}
6 changes: 2 additions & 4 deletions tests/e2e/auth/vesting/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ package testutil
import (
"testing"

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

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/network"
testutil2 "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/testutil"
"github.com/cosmos/cosmos-sdk/x/auth/vesting/testutil"
)

func TestIntegrationTestSuite(t *testing.T) {
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 1
suite.Run(t, testutil2.NewIntegrationTestSuite(cfg))
}
4 changes: 2 additions & 2 deletions tests/e2e/authz/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/x/authz/client/testutil"
clienttestutil "github.com/cosmos/cosmos-sdk/x/authz/client/testutil"
)

func TestIntegrationTestSuite(t *testing.T) {
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 1
suite.Run(t, testutil.NewIntegrationTestSuite(cfg))
suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg))
}
10 changes: 4 additions & 6 deletions tests/e2e/evidence/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ package testutil
import (
"testing"

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

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/network"
testutil2 "github.com/cosmos/cosmos-sdk/x/evidence/client/testutil"
"github.com/cosmos/cosmos-sdk/x/evidence/testutil"
clienttestutil "github.com/cosmos/cosmos-sdk/x/evidence/client/testutil"
)

func TestIntegrationTestSuite(t *testing.T) {
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 1
suite.Run(t, testutil2.NewIntegrationTestSuite(cfg))
suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg))
}
6 changes: 2 additions & 4 deletions tests/e2e/feegrant/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ package testutil
import (
"testing"

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/network"
clienttestutil "github.com/cosmos/cosmos-sdk/x/feegrant/client/testutil"
"github.com/cosmos/cosmos-sdk/x/feegrant/testutil"

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

func TestIntegrationTestSuite(t *testing.T) {
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 3
suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg))
}
6 changes: 2 additions & 4 deletions tests/e2e/group/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ package testutil
import (
"testing"

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

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

func TestIntegrationTestSuite(t *testing.T) {
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 2
suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg))
}
6 changes: 2 additions & 4 deletions tests/e2e/mint/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ package testutil
import (
"testing"

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

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/network"
clienttestutil "github.com/cosmos/cosmos-sdk/x/mint/client/testutil"
"github.com/cosmos/cosmos-sdk/x/mint/testutil"
)

func TestIntegrationTestSuite(t *testing.T) {
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 1
suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg))
}
6 changes: 2 additions & 4 deletions tests/e2e/nft/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ package testutil
import (
"testing"

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

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/network"
clienttestutil "github.com/cosmos/cosmos-sdk/x/nft/client/testutil"
"github.com/cosmos/cosmos-sdk/x/nft/testutil"
)

func TestIntegrationTestSuite(t *testing.T) {
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 1
suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg))
}
6 changes: 2 additions & 4 deletions tests/e2e/params/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ package testutil
import (
"testing"

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

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/network"
clienttestutil "github.com/cosmos/cosmos-sdk/x/params/client/testutil"
"github.com/cosmos/cosmos-sdk/x/params/testutil"
)

func TestIntegrationTestSuite(t *testing.T) {
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 1
suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg))
}
6 changes: 2 additions & 4 deletions tests/e2e/slashing/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ package testutil
import (
"testing"

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/network"
clienttestutil "github.com/cosmos/cosmos-sdk/x/slashing/client/testutil"
"github.com/cosmos/cosmos-sdk/x/slashing/testutil"

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

func TestIntegrationTestSuite(t *testing.T) {
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 1
suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg))
}
55 changes: 0 additions & 55 deletions x/auth/testutil/app.yaml

This file was deleted.

104 changes: 98 additions & 6 deletions x/auth/testutil/app_config.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,114 @@
package testutil

import (
_ "embed"

_ "github.com/cosmos/cosmos-sdk/x/auth"
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/auth/vesting"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/feegrant/module"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/gov"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"

"cosmossdk.io/core/appconfig"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

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"
feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/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"
vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1"
)

//go:embed app.yaml
var appConfig []byte
var AppConfig = appconfig.Compose(&appv1alpha1.Config{
Modules: []*appv1alpha1.ModuleConfig{
{
Name: "runtime",
Config: appconfig.WrapAny(&runtimev1alpha1.Module{
AppName: "AuthApp",
BeginBlockers: []string{
stakingtypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
genutiltypes.ModuleName,
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
},
EndBlockers: []string{
stakingtypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
genutiltypes.ModuleName,
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
},
InitGenesis: []string{
authtypes.ModuleName,
banktypes.ModuleName,
stakingtypes.ModuleName,
genutiltypes.ModuleName,
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
},
}),
},
{
Name: authtypes.ModuleName,
Config: appconfig.WrapAny(&authmodulev1.Module{
Bech32Prefix: "cosmos",
ModuleAccountPermissions: []*authmodulev1.ModuleAccountPermission{
{Account: authtypes.FeeCollectorName},
{Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}},
{Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}},
{Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}},
{Account: "multiple permissions account", Permissions: []string{authtypes.Minter, authtypes.Burner, stakingtypes.ModuleName}}, // dummy permissions
{Account: "random permission", Permissions: []string{"random"}},
},
}),
},
{
Name: vestingtypes.ModuleName,
Config: appconfig.WrapAny(&vestingmodulev1.Module{}),
},
{
Name: banktypes.ModuleName,
Config: appconfig.WrapAny(&bankmodulev1.Module{}),
},
{
Name: stakingtypes.ModuleName,
Config: appconfig.WrapAny(&stakingmodulev1.Module{}),
},
{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txmodulev1.Module{}),
},
{
Name: genutiltypes.ModuleName,
Config: appconfig.WrapAny(&genutilmodulev1.Module{}),
},

var AppConfig = appconfig.LoadYAML(appConfig)
{
Name: feegrant.ModuleName,
Config: appconfig.WrapAny(&feegrantmodulev1.Module{}),
},
},
})
Loading