Skip to content

Commit

Permalink
fix the lint error
Browse files Browse the repository at this point in the history
use shared test utils to refine the test codes

fix the problem in tests caused by denom rename
  • Loading branch information
TimmyExogenous committed Mar 4, 2024
1 parent 0826b03 commit 3d1990e
Show file tree
Hide file tree
Showing 68 changed files with 678 additions and 1,857 deletions.
2 changes: 1 addition & 1 deletion app/ethtest_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func NewTestGenesisState(codec codec.Codec) simapp.GenesisState {
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))),
}

genesisState := NewDefaultGenesisState()
genesisState := NewDefaultGenesisState(codec)
return genesisStateWithValSet(codec, genesisState, valSet, []authtypes.GenesisAccount{acc}, balance)
}

Expand Down
60 changes: 55 additions & 5 deletions app/export.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,75 @@
package app

import (
"cosmossdk.io/simapp"
"encoding/json"
"fmt"

"github.com/ExocoreNetwork/exocore/utils"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

"cosmossdk.io/simapp"
"github.com/cosmos/cosmos-sdk/codec"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
claimstypes "github.com/evmos/evmos/v14/x/claims/types"
evmtypes "github.com/evmos/evmos/v14/x/evm/types"
inflationtypes "github.com/evmos/evmos/v14/x/inflation/types"

"github.com/evmos/evmos/v14/encoding"
)

// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState() simapp.GenesisState {
func NewDefaultGenesisState(cdc codec.Codec) simapp.GenesisState {
encCfg := encoding.MakeConfig(ModuleBasics)
return ModuleBasics.DefaultGenesis(encCfg.Codec)
defaultGenesis := ModuleBasics.DefaultGenesis(encCfg.Codec)

// staking module
stakingGenesis := stakingtypes.GenesisState{}
rawGenesis := defaultGenesis[stakingtypes.ModuleName]
cdc.MustUnmarshalJSON(rawGenesis, &stakingGenesis)
stakingGenesis.Params.BondDenom = utils.BaseDenom
defaultGenesis[stakingtypes.ModuleName] = cdc.MustMarshalJSON(&stakingGenesis)

// crisis module
crisisGenesis := crisistypes.GenesisState{}
rawGenesis = defaultGenesis[crisistypes.ModuleName]
cdc.MustUnmarshalJSON(rawGenesis, &crisisGenesis)
crisisGenesis.ConstantFee.Denom = utils.BaseDenom
defaultGenesis[crisistypes.ModuleName] = cdc.MustMarshalJSON(&crisisGenesis)

// gov module
govGenesis := govtypesv1.GenesisState{}
rawGenesis = defaultGenesis[govtypes.ModuleName]
cdc.MustUnmarshalJSON(rawGenesis, &govGenesis)
govGenesis.Params.MinDeposit[0].Denom = utils.BaseDenom
defaultGenesis[govtypes.ModuleName] = cdc.MustMarshalJSON(&govGenesis)

// evm module
evmGenesis := evmtypes.GenesisState{}
rawGenesis = defaultGenesis[evmtypes.ModuleName]
cdc.MustUnmarshalJSON(rawGenesis, &evmGenesis)
evmGenesis.Params.EvmDenom = utils.BaseDenom
defaultGenesis[evmtypes.ModuleName] = cdc.MustMarshalJSON(&evmGenesis)

// inflation module
inflationGenesis := inflationtypes.GenesisState{}
rawGenesis = defaultGenesis[inflationtypes.ModuleName]
cdc.MustUnmarshalJSON(rawGenesis, &inflationGenesis)
inflationGenesis.Params.MintDenom = utils.BaseDenom
defaultGenesis[inflationtypes.ModuleName] = cdc.MustMarshalJSON(&inflationGenesis)

// claims module
claimsGenesis := claimstypes.GenesisState{}
rawGenesis = defaultGenesis[claimstypes.ModuleName]
cdc.MustUnmarshalJSON(rawGenesis, &claimsGenesis)
claimsGenesis.Params.ClaimsDenom = utils.BaseDenom
defaultGenesis[claimstypes.ModuleName] = cdc.MustMarshalJSON(&claimsGenesis)

return defaultGenesis
}

// ExportAppStateAndValidators exports the state of the application for a genesis
Expand Down
8 changes: 4 additions & 4 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/evmos/evmos/v14/encoding"
feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types"

"github.com/evmos/evmos/v14/cmd/config"
"github.com/evmos/evmos/v14/utils"
"github.com/ExocoreNetwork/exocore/cmd/config"
"github.com/ExocoreNetwork/exocore/utils"
)

func init() {
Expand Down Expand Up @@ -106,7 +106,7 @@ func Setup(
)
if !isCheckTx {
// init chain must be called to stop deliverState from being nil
genesisState := NewDefaultGenesisState()
genesisState := NewDefaultGenesisState(app.appCodec)
genesisState = GenesisStateWithValSet(app, genesisState, valSet, []authtypes.GenesisAccount{acc}, balance)

// Verify feeMarket genesis
Expand Down Expand Up @@ -218,6 +218,6 @@ func SetupTestingApp(chainID string, isPrintLog bool) func() (ibctesting.Testing
simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome),
baseapp.SetChainID(chainID),
)
return app, NewDefaultGenesisState()
return app, NewDefaultGenesisState(app.appCodec)
}
}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,14 @@ replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
// use Cosmos-SDK fork to enable Ledger functionality
github.com/cosmos/cosmos-sdk => github.com/evmos/cosmos-sdk v0.47.4-evmos.2
//github.com/cosmos/cosmos-sdk => ../cosmos-sdk
//fix cosmos-sdk error
github.com/cosmos/gogoproto => github.com/cosmos/gogoproto v1.4.10
// use Evmos geth fork
github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2
// use exocore fork of evmos
github.com/evmos/evmos/v14 => github.com/ExocoreNetwork/evmos/v14 v14.1.1-0.20240205024453-5e8090e42ef4
//github.com/evmos/evmos/v14 => ../ExocoreNetwork/evmos
// Security Advisory https://github.com/advisories/GHSA-h395-qcrw-5vmq
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1
// replace broken goleveldb
Expand Down
Loading

0 comments on commit 3d1990e

Please sign in to comment.