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

test: add simulation tests #2947

Merged
merged 23 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
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
99 changes: 40 additions & 59 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"encoding/json"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -177,64 +178,33 @@ func getGovProposalHandlers() []govclient.ProposalHandler {
return govProposalHandlers
}

var (
ModuleBasics = module.NewBasicManager(
auth.AppModuleBasic{},
genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
bank.AppModuleBasic{},
//capability.AppModuleBasic{},
staking.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
//ibc.AppModuleBasic{},
//ibctm.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
//transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
consensus.AppModuleBasic{},
evm.AppModuleBasic{},
feemarket.AppModuleBasic{},
authoritymodule.AppModuleBasic{},
lightclientmodule.AppModuleBasic{},
crosschainmodule.AppModuleBasic{},
//ibccrosschain.AppModuleBasic{},
observermodule.AppModuleBasic{},
fungiblemodule.AppModuleBasic{},
emissionsmodule.AppModuleBasic{},
groupmodule.AppModuleBasic{},
authzmodule.AppModuleBasic{},
)

// module account permissions
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
//ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
crosschaintypes.ModuleName: {authtypes.Minter, authtypes.Burner},
//ibccrosschaintypes.ModuleName: nil,
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
fungibletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
emissionstypes.ModuleName: nil,
emissionstypes.UndistributedObserverRewardsPool: nil,
emissionstypes.UndistributedTssRewardsPool: nil,
}
type GenesisState map[string]json.RawMessage

// module account permissions
var maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
//ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
crosschaintypes.ModuleName: {authtypes.Minter, authtypes.Burner},
//ibccrosschaintypes.ModuleName: nil,
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
fungibletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
emissionstypes.ModuleName: nil,
emissionstypes.UndistributedObserverRewardsPool: nil,
emissionstypes.UndistributedTssRewardsPool: nil,
}

// module accounts that are NOT allowed to receive tokens
blockedReceivingModAcc = map[string]bool{
distrtypes.ModuleName: true,
authtypes.FeeCollectorName: true,
stakingtypes.BondedPoolName: true,
stakingtypes.NotBondedPoolName: true,
govtypes.ModuleName: true,
}
)
// module accounts that are NOT allowed to receive tokens
var blockedReceivingModAcc = map[string]bool{
distrtypes.ModuleName: true,
authtypes.FeeCollectorName: true,
stakingtypes.BondedPoolName: true,
stakingtypes.NotBondedPoolName: true,
govtypes.ModuleName: true,
}

var (
_ runtime.AppI = (*App)(nil)
Expand All @@ -259,6 +229,7 @@ type App struct {

mm *module.Manager
sm *module.SimulationManager
ModuleBasics module.BasicManager
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved
configurator module.Configurator

// sdk keepers
Expand Down Expand Up @@ -636,6 +607,7 @@ func New(
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))

govConfig := govtypes.DefaultConfig()
govKeeper := govkeeper.NewKeeper(
appCodec,
Expand All @@ -647,11 +619,14 @@ func New(
govConfig,
authAddr,
)

app.GovKeeper = *govKeeper.SetHooks(
govtypes.NewMultiGovHooks(
// register governance hooks
),
)
// Set legacy router for backwards compatibility with gov v1beta1
app.GovKeeper.SetLegacyRouter(govRouter)
lumtis marked this conversation as resolved.
Show resolved Hide resolved

// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
evidenceKeeper := evidencekeeper.NewKeeper(
Expand Down Expand Up @@ -737,6 +712,8 @@ func New(
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
)

app.ModuleBasics = ModuleBasics
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved

// 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.
Expand Down Expand Up @@ -812,6 +789,10 @@ func New(
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)

app.sm = module.NewSimulationManager(simulationModules(app, appCodec, skipGenesisInvariants)...)
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved

app.sm.RegisterStoreDecoders()

// initialize stores
app.MountKVStores(keys)
app.MountTransientStores(tKeys)
Expand Down Expand Up @@ -899,7 +880,7 @@ func (app *App) ModuleAccountAddrs() map[string]bool {
return modAccAddrs
}

// LegacyAmino returns SimApp's amino codec.
// LegacyAmino returns app's amino codec.
//
// NOTE: This is solely to be used for testing purposes as it may be desirable
// for modules to register their own custom testing types.
Expand Down Expand Up @@ -962,7 +943,7 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig
nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register legacy and grpc-gateway routes for all modules.
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
app.ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved

// register app's OpenAPI routes.
if apiConfig.Swagger {
Expand Down
1 change: 1 addition & 0 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func MakeEncodingConfig() ethermint.EncodingConfig {
encodingConfig := evmenc.MakeConfig(ModuleBasics)
registry := encodingConfig.InterfaceRegistry

// TODO test if we need to register these interfaces again as MakeConfig already registers them
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved
cryptocodec.RegisterInterfaces(registry)
authtypes.RegisterInterfaces(registry)
authz.RegisterInterfaces(registry)
Expand Down
21 changes: 0 additions & 21 deletions app/genesis.go

This file was deleted.

66 changes: 0 additions & 66 deletions app/init_genesis.go

This file was deleted.

Loading
Loading