Skip to content

Commit

Permalink
add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer-zq committed Jun 25, 2024
1 parent c2cda47 commit 6ee24f2
Show file tree
Hide file tree
Showing 11 changed files with 3,200 additions and 684 deletions.
364 changes: 364 additions & 0 deletions e2e/app_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,364 @@
package e2e

import (
"time"

runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
capabilitymodulev1 "cosmossdk.io/api/cosmos/capability/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
crisismodulev1 "cosmossdk.io/api/cosmos/crisis/module/v1"
distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
evidencemodulev1 "cosmossdk.io/api/cosmos/evidence/module/v1"
feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
govmodulev1 "cosmossdk.io/api/cosmos/gov/module/v1"
groupmodulev1 "cosmossdk.io/api/cosmos/group/module/v1"
mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
slashingmodulev1 "cosmossdk.io/api/cosmos/slashing/module/v1"
stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1"
txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1"
upgrademodulev1 "cosmossdk.io/api/cosmos/upgrade/module/v1"
vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1"
"cosmossdk.io/core/appconfig"
_ "github.com/cosmos/cosmos-sdk/x/upgrade" // import for side-effects
"google.golang.org/protobuf/types/known/durationpb"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/group"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

coinswapmodule "mods.irisnet.org/api/irismod/coinswap/module/v1"
farmmodule "mods.irisnet.org/api/irismod/farm/module/v1"
htlcmodule "mods.irisnet.org/api/irismod/htlc/module/v1"
mtmodule "mods.irisnet.org/api/irismod/mt/module/v1"
nftmodule "mods.irisnet.org/api/irismod/nft/module/v1"
oraclemodule "mods.irisnet.org/api/irismod/oracle/module/v1"
randommodule "mods.irisnet.org/api/irismod/random/module/v1"
recordmodule "mods.irisnet.org/api/irismod/record/module/v1"
servicemodule "mods.irisnet.org/api/irismod/service/module/v1"
tokenmodule "mods.irisnet.org/api/irismod/token/module/v1"
_ "mods.irisnet.org/modules/coinswap" // import for side-effects
coinswaptypes "mods.irisnet.org/modules/coinswap/types"
_ "mods.irisnet.org/modules/farm" // import for side-effects
farmtypes "mods.irisnet.org/modules/farm/types"
_ "mods.irisnet.org/modules/htlc" // import for side-effects
htlctypes "mods.irisnet.org/modules/htlc/types"
_ "mods.irisnet.org/modules/mt" // import for side-effects
mttypes "mods.irisnet.org/modules/mt/types"
_ "mods.irisnet.org/modules/nft" // import for side-effects
nfttypes "mods.irisnet.org/modules/nft/types"
_ "mods.irisnet.org/modules/oracle" // import for side-effects
oracletypes "mods.irisnet.org/modules/oracle/types"
_ "mods.irisnet.org/modules/random" // import for side-effects
randomtypes "mods.irisnet.org/modules/random/types"
_ "mods.irisnet.org/modules/record" // import for side-effects
recordtypes "mods.irisnet.org/modules/record/types"
_ "mods.irisnet.org/modules/service" // import for side-effects
servicetypes "mods.irisnet.org/modules/service/types"
_ "mods.irisnet.org/modules/token" // import for side-effects
tokentypes "mods.irisnet.org/modules/token/types"
)

var (

// NOTE: The genutils module must occur after staking so that pools are
// properly initialized with tokens from genesis accounts.
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
// NOTE: Capability module must occur first so that it can initialize any capabilities
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
genesisModuleOrder = []string{
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName,
distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName,
minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
feegrant.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,
vestingtypes.ModuleName, consensustypes.ModuleName,
coinswaptypes.ModuleName,
farmtypes.ModuleName,
htlctypes.ModuleName,
mttypes.ModuleName,
nfttypes.ModuleName,
servicetypes.ModuleName, oracletypes.ModuleName,
randomtypes.ModuleName,
recordtypes.ModuleName,
tokentypes.ModuleName,
}

// module account permissions
moduleAccPerms = []*authmodulev1.ModuleAccountPermission{
{Account: authtypes.FeeCollectorName},
{Account: distrtypes.ModuleName},
{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: govtypes.ModuleName, Permissions: []string{authtypes.Burner}},
{Account: coinswaptypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}},
{Account: farmtypes.ModuleName, Permissions: []string{authtypes.Burner}},
{Account: farmtypes.RewardCollector},
{Account: htlctypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}},
{Account: nfttypes.ModuleName},
{Account: mttypes.ModuleName},
{Account: servicetypes.DepositAccName, Permissions: []string{authtypes.Burner}},
{Account: servicetypes.RequestAccName},
{Account: servicetypes.FeeCollectorName, Permissions: []string{authtypes.Burner}},
{Account: tokentypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}},
}

// blocked account addresses
blockAccAddrs = []string{
authtypes.FeeCollectorName,
distrtypes.ModuleName,
minttypes.ModuleName,
stakingtypes.BondedPoolName,
stakingtypes.NotBondedPoolName,
// We allow the following module accounts to receive funds:
// govtypes.ModuleName
}

// AppConfig application configuration (used by depinject)
AppConfig = appconfig.Compose(&appv1alpha1.Config{
Modules: []*appv1alpha1.ModuleConfig{
{
Name: "runtime",
Config: appconfig.WrapAny(&runtimev1alpha1.Module{
AppName: "SimApp",
// During begin block slashing happens after distr.BeginBlocker so that
// there is nothing left over in the validator fee pool, so as to keep the
// CanWithdrawInvariant invariant.
// NOTE: staking module is required if HistoricalEntries param > 0
// NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC)
BeginBlockers: []string{
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
minttypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
evidencetypes.ModuleName,
stakingtypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
govtypes.ModuleName,
crisistypes.ModuleName,
genutiltypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
group.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
coinswaptypes.ModuleName,
farmtypes.ModuleName,
htlctypes.ModuleName,
mttypes.ModuleName,
nfttypes.ModuleName,
servicetypes.ModuleName,
oracletypes.ModuleName,
randomtypes.ModuleName,
recordtypes.ModuleName,
tokentypes.ModuleName,
consensustypes.ModuleName,
},
EndBlockers: []string{
crisistypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
minttypes.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
group.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
consensustypes.ModuleName,
coinswaptypes.ModuleName,
farmtypes.ModuleName,
htlctypes.ModuleName,
mttypes.ModuleName,
nfttypes.ModuleName,
servicetypes.ModuleName,
oracletypes.ModuleName,
randomtypes.ModuleName,
recordtypes.ModuleName,
tokentypes.ModuleName,
vestingtypes.ModuleName,
},
OverrideStoreKeys: []*runtimev1alpha1.StoreKeyConfig{
{
ModuleName: authtypes.ModuleName,
KvStoreKey: "acc",
},
},
InitGenesis: genesisModuleOrder,
// When ExportGenesis is not specified, the export genesis module order
// is equal to the init genesis order
// ExportGenesis: genesisModuleOrder,
// Uncomment if you want to set a custom migration order here.
// OrderMigrations: nil,
}),
},
{
Name: authtypes.ModuleName,
Config: appconfig.WrapAny(&authmodulev1.Module{
Bech32Prefix: "cosmos",
ModuleAccountPermissions: moduleAccPerms,
// By default modules authority is the governance module. This is configurable with the following:
// Authority: "group", // A custom module authority can be set using a module name
// Authority: "cosmos1cwwv22j5ca08ggdv9c2uky355k908694z577tv", // or a specific address
}),
},
{
Name: vestingtypes.ModuleName,
Config: appconfig.WrapAny(&vestingmodulev1.Module{}),
},
{
Name: banktypes.ModuleName,
Config: appconfig.WrapAny(&bankmodulev1.Module{
BlockedModuleAccountsOverride: blockAccAddrs,
}),
},
{
Name: stakingtypes.ModuleName,
Config: appconfig.WrapAny(&stakingmodulev1.Module{}),
},
{
Name: slashingtypes.ModuleName,
Config: appconfig.WrapAny(&slashingmodulev1.Module{}),
},
{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txconfigv1.Config{}),
},
{
Name: genutiltypes.ModuleName,
Config: appconfig.WrapAny(&genutilmodulev1.Module{}),
},
{
Name: authz.ModuleName,
Config: appconfig.WrapAny(&authzmodulev1.Module{}),
},
{
Name: upgradetypes.ModuleName,
Config: appconfig.WrapAny(&upgrademodulev1.Module{}),
},
{
Name: distrtypes.ModuleName,
Config: appconfig.WrapAny(&distrmodulev1.Module{}),
},
{
Name: capabilitytypes.ModuleName,
Config: appconfig.WrapAny(&capabilitymodulev1.Module{
SealKeeper: true,
}),
},
{
Name: evidencetypes.ModuleName,
Config: appconfig.WrapAny(&evidencemodulev1.Module{}),
},
{
Name: minttypes.ModuleName,
Config: appconfig.WrapAny(&mintmodulev1.Module{}),
},
{
Name: group.ModuleName,
Config: appconfig.WrapAny(&groupmodulev1.Module{
MaxExecutionPeriod: durationpb.New(time.Second * 1209600),
MaxMetadataLen: 255,
}),
},
{
Name: feegrant.ModuleName,
Config: appconfig.WrapAny(&feegrantmodulev1.Module{}),
},
{
Name: govtypes.ModuleName,
Config: appconfig.WrapAny(&govmodulev1.Module{}),
},
{
Name: crisistypes.ModuleName,
Config: appconfig.WrapAny(&crisismodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: coinswaptypes.ModuleName,
Config: appconfig.WrapAny(&coinswapmodule.Module{
FeeCollectorName: authtypes.FeeCollectorName,
}),
},
{
Name: farmtypes.ModuleName,
Config: appconfig.WrapAny(&farmmodule.Module{
FeeCollectorName: authtypes.FeeCollectorName,
CommunityPoolName: distrtypes.ModuleName,
}),
},
{
Name: htlctypes.ModuleName,
Config: appconfig.WrapAny(&htlcmodule.Module{}),
},
{
Name: mttypes.ModuleName,
Config: appconfig.WrapAny(&mtmodule.Module{}),
},
{
Name: nfttypes.ModuleName,
Config: appconfig.WrapAny(&nftmodule.Module{}),
},
{
Name: oracletypes.ModuleName,
Config: appconfig.WrapAny(&oraclemodule.Module{}),
},
{
Name: servicetypes.ModuleName,
Config: appconfig.WrapAny(&servicemodule.Module{
FeeCollectorName: servicetypes.FeeCollectorName,
}),
},
{
Name: randomtypes.ModuleName,
Config: appconfig.WrapAny(&randommodule.Module{}),
},
{
Name: recordtypes.ModuleName,
Config: appconfig.WrapAny(&recordmodule.Module{}),
},
{
Name: tokentypes.ModuleName,
Config: appconfig.WrapAny(&tokenmodule.Module{
FeeCollectorName: authtypes.FeeCollectorName,
}),
},
},
})
)
Loading

0 comments on commit 6ee24f2

Please sign in to comment.