Skip to content

Commit

Permalink
fix(simapp): manually add x/vesting Cosmos-SDK module types to the co…
Browse files Browse the repository at this point in the history
…dec in simulation tests since they are expected by default (#2147)
  • Loading branch information
Unique-Divine authored Jan 8, 2025
1 parent df8c394 commit 8c6e021
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#2142](https://github.com/NibiruChain/nibiru/pull/2142) - fix(bank): add additional missing methods to the NibiruBankKeeper
- [#2144](https://github.com/NibiruChain/nibiru/pull/2144) - feat(token-registry): Implement strongly typed Nibiru Token Registry and generation command
- [#2145](https://github.com/NibiruChain/nibiru/pull/2145) - chore(token-registry): add xNIBI Astrovault LST to registry
- [#2147](https://github.com/NibiruChain/nibiru/pull/2147) - fix(simapp): manually add x/vesting Cosmos-SDK module types to the codec in simulation tests since they are expected by default

#### Nibiru EVM | Before Audit 2 - 2024-12-06

Expand Down
21 changes: 17 additions & 4 deletions simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
Expand All @@ -36,6 +37,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/NibiruChain/nibiru/v2/app"
"github.com/NibiruChain/nibiru/v2/app/codec"
devgastypes "github.com/NibiruChain/nibiru/v2/x/devgas/v1/types"
epochstypes "github.com/NibiruChain/nibiru/v2/x/epochs/types"
inflationtypes "github.com/NibiruChain/nibiru/v2/x/inflation/types"
Expand All @@ -59,6 +61,17 @@ type StoreKeysPrefixes struct {
Prefixes [][]byte
}

// makeEncodingConfig, similar to [app.MakeEncodingConfig], creates an
// EncodingConfig for an amino based test configuration. However, this function
// registers interfaces and types that are expected by default in the Cosmos-SDK
// even if they are disabled on Nibiru. This is the case for x/vesting Cosmos-SDK
// module.
func makeEncodingConfig() codec.EncodingConfig {
encCfg := app.MakeEncodingConfig()
vesting.RegisterInterfaces(encCfg.InterfaceRegistry)
return encCfg
}

func TestFullAppSimulation(t *testing.T) {
config := simcli.NewConfigFromFlags()
config.ChainID = SimAppChainID
Expand All @@ -78,7 +91,7 @@ func TestFullAppSimulation(t *testing.T) {
appOptions[flags.FlagHome] = app.DefaultNodeHome
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue

encoding := app.MakeEncodingConfig()
encoding := makeEncodingConfig()
app := app.NewNibiruApp(logger, db, nil, true, encoding, appOptions, baseapp.SetChainID(SimAppChainID))
require.Equal(t, "Nibiru", app.Name())
appCodec := app.AppCodec()
Expand Down Expand Up @@ -132,7 +145,7 @@ func TestAppStateDeterminism(t *testing.T) {
for j := 0; j < numTimesToRunPerSeed; j++ {
db := dbm.NewMemDB()
logger := log.NewNopLogger()
encoding := app.MakeEncodingConfig()
encoding := makeEncodingConfig()

app := app.NewNibiruApp(logger, db, nil, true, encoding, appOptions, baseapp.SetChainID(SimAppChainID))
appCodec := app.AppCodec()
Expand Down Expand Up @@ -191,7 +204,7 @@ func TestAppImportExport(t *testing.T) {
appOptions[flags.FlagHome] = app.DefaultNodeHome
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue

encoding := app.MakeEncodingConfig()
encoding := makeEncodingConfig()
oldApp := app.NewNibiruApp(logger, db, nil, true, encoding, appOptions, baseapp.SetChainID(SimAppChainID))
require.Equal(t, "Nibiru", oldApp.Name())
appCodec := oldApp.AppCodec()
Expand Down Expand Up @@ -315,7 +328,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
appOptions[flags.FlagHome] = app.DefaultNodeHome
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue

encoding := app.MakeEncodingConfig()
encoding := makeEncodingConfig()
oldApp := app.NewNibiruApp(logger, db, nil, true, encoding, appOptions, baseapp.SetChainID(SimAppChainID))
require.Equal(t, "Nibiru", oldApp.Name())
appCodec := oldApp.AppCodec()
Expand Down

0 comments on commit 8c6e021

Please sign in to comment.