From 6c8c83c4b3a8242abfdd86d0d2ad71bd73b9910e Mon Sep 17 00:00:00 2001 From: dongsam Date: Thu, 19 Aug 2021 19:13:44 +0900 Subject: [PATCH] fix: solve module, sdk issues --- app/app.go | 3 +-- app/app_test.go | 36 ++++++++++++++++++++++++++++++++++++ x/farming/module.go | 2 +- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 app/app_test.go diff --git a/app/app.go b/app/app.go index 037a0cce..e9d8dedc 100644 --- a/app/app.go +++ b/app/app.go @@ -217,8 +217,7 @@ func NewFarmingApp( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, - evidencetypes.StoreKey, capabilitytypes.StoreKey, farmingtypes.StoreKey, - // todo: farming ordering + evidencetypes.StoreKey, capabilitytypes.StoreKey, authzkeeper.StoreKey, farmingtypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) diff --git a/app/app_test.go b/app/app_test.go new file mode 100644 index 00000000..4e486bd1 --- /dev/null +++ b/app/app_test.go @@ -0,0 +1,36 @@ +package app + +import ( + "encoding/json" + "os" + "testing" + + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" + dbm "github.com/tendermint/tm-db" +) + +func TestSimAppExportAndBlockedAddrs(t *testing.T) { + encCfg := MakeTestEncodingConfig() + db := dbm.NewMemDB() + app := NewFarmingApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encCfg, EmptyAppOptions{}) + + genesisState := NewDefaultGenesisState(encCfg.Marshaler) + stateBytes, err := json.MarshalIndent(genesisState, "", " ") + require.NoError(t, err) + + // Initialize the chain + app.InitChain( + abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + AppStateBytes: stateBytes, + }, + ) + app.Commit() + + res, err := app.ExportAppStateAndValidators(false, []string{}) + require.NoError(t, err, "ExportAppStateAndValidators should not have an error") + _, err = res.AppState.MarshalJSON() + require.NoError(t, err) +} diff --git a/x/farming/module.go b/x/farming/module.go index 9b4d5b7f..7119f492 100644 --- a/x/farming/module.go +++ b/x/farming/module.go @@ -167,7 +167,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock returns the begin blocker for the farming module. func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {