diff --git a/tests/e2e/common.go b/tests/e2e/common.go index 6246f6ddc..1354b1db0 100644 --- a/tests/e2e/common.go +++ b/tests/e2e/common.go @@ -1,11 +1,13 @@ package e2e import ( + "encoding/json" "fmt" "os" "cosmossdk.io/log" pruningtypes "cosmossdk.io/store/pruning/types" + "github.com/cosmos/cosmos-sdk/codec" dbm "github.com/cosmos/cosmos-db" bam "github.com/cosmos/cosmos-sdk/baseapp" @@ -16,12 +18,14 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/staking" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" laconicApp "git.vdb.to/cerc-io/laconicd/app" auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module" bondmodule "git.vdb.to/cerc-io/laconicd/x/bond/module" registrymodule "git.vdb.to/cerc-io/laconicd/x/registry/module" + "git.vdb.to/cerc-io/laconicd/app/params" _ "git.vdb.to/cerc-io/laconicd/app/params" // import for side-effects (see init) "git.vdb.to/cerc-io/laconicd/testutil/network" ) @@ -54,16 +58,40 @@ func NewTestNetworkFixture() network.TestFixture { return app } + encodingConfig := testutil.MakeTestEncodingConfig( + auth.AppModuleBasic{}, + bank.AppModuleBasic{}, + staking.AppModuleBasic{}, + auctionmodule.AppModule{}, + bondmodule.AppModule{}, + registrymodule.AppModule{}, + ) + + genesisState := app.DefaultGenesis() + genesisState, err = updateStakingGenesisBondDenom(genesisState, encodingConfig.Codec) + if err != nil { + panic(fmt.Sprintf("failed to update genesis state: %v", err)) + } + return network.TestFixture{ AppConstructor: appCtr, - GenesisState: app.DefaultGenesis(), - EncodingConfig: testutil.MakeTestEncodingConfig( - auth.AppModuleBasic{}, - bank.AppModuleBasic{}, - staking.AppModuleBasic{}, - auctionmodule.AppModule{}, - bondmodule.AppModule{}, - registrymodule.AppModule{}, - ), + GenesisState: genesisState, + EncodingConfig: encodingConfig, } } + +func updateStakingGenesisBondDenom(genesisState map[string]json.RawMessage, codec codec.Codec) (map[string]json.RawMessage, error) { + var stakingGenesis stakingtypes.GenesisState + if err := codec.UnmarshalJSON(genesisState[stakingtypes.ModuleName], &stakingGenesis); err != nil { + return nil, nil + } + stakingGenesis.Params.BondDenom = params.CoinUnit + + stakingGenesisBz, err := codec.MarshalJSON(&stakingGenesis) + if err != nil { + return nil, nil + } + genesisState[stakingtypes.ModuleName] = stakingGenesisBz + + return genesisState, nil +} diff --git a/tests/integration/auction/keeper/query_server_test.go b/tests/integration/auction/keeper/query_server_test.go index c5e73e8eb..d68219435 100644 --- a/tests/integration/auction/keeper/query_server_test.go +++ b/tests/integration/auction/keeper/query_server_test.go @@ -10,6 +10,7 @@ import ( simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "git.vdb.to/cerc-io/laconicd/app/params" integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration" types "git.vdb.to/cerc-io/laconicd/x/auction" ) @@ -337,9 +338,9 @@ func (kts *KeeperTestSuite) createAuctionAndCommitBid(commitBid bool) (*types.Au Signer: accounts[0].String(), CommitsDuration: 5 * time.Minute, RevealsDuration: 5 * time.Minute, - CommitFee: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000)), - RevealFee: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000)), - MinimumBid: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000000)), + CommitFee: sdk.NewCoin(params.CoinUnit, sdkmath.NewInt(1000)), + RevealFee: sdk.NewCoin(params.CoinUnit, sdkmath.NewInt(1000)), + MinimumBid: sdk.NewCoin(params.CoinUnit, sdkmath.NewInt(1000000)), }, ) if err != nil { diff --git a/tests/integration/bond/keeper/query_server_test.go b/tests/integration/bond/keeper/query_server_test.go index 20e517ed7..aed846ba5 100644 --- a/tests/integration/bond/keeper/query_server_test.go +++ b/tests/integration/bond/keeper/query_server_test.go @@ -8,6 +8,7 @@ import ( simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "git.vdb.to/cerc-io/laconicd/app/params" integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration" types "git.vdb.to/cerc-io/laconicd/x/bond" ) @@ -185,7 +186,7 @@ func (kts *KeeperTestSuite) TestGrpcGetModuleBalance() { if !test.errResponse { kts.Require().Nil(err) kts.Require().NotNil(resp.GetBalance()) - kts.Require().Equal(resp.GetBalance(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10)))) + kts.Require().Equal(resp.GetBalance(), sdk.NewCoins(sdk.NewCoin(params.CoinUnit, math.NewInt(10)))) } else { kts.Require().NotNil(err) kts.Require().Error(err) @@ -201,7 +202,7 @@ func (kts *KeeperTestSuite) createBond() (*types.Bond, error) { // Create funded account(s) accounts := simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, accCount, math.NewInt(1000)) - bond, err := k.CreateBond(ctx, accounts[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10)))) + bond, err := k.CreateBond(ctx, accounts[0], sdk.NewCoins(sdk.NewCoin(params.CoinUnit, math.NewInt(10)))) if err != nil { return nil, err } diff --git a/tests/integration/common.go b/tests/integration/common.go index cc3c58726..15aa3947f 100644 --- a/tests/integration/common.go +++ b/tests/integration/common.go @@ -23,6 +23,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "git.vdb.to/cerc-io/laconicd/app/params" auctionTypes "git.vdb.to/cerc-io/laconicd/x/auction" auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper" auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module" @@ -82,8 +83,8 @@ func (tf *TestFixture) Setup() error { runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, - addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), - sdk.Bech32MainPrefix, + addresscodec.NewBech32Codec(params.Bech32PrefixAccAddr), + params.Bech32PrefixAccAddr, authority.String(), ) @@ -161,5 +162,5 @@ func (tf *TestFixture) Setup() error { type BondDenomProvider struct{} func (bdp BondDenomProvider) BondDenom(ctx context.Context) (string, error) { - return sdk.DefaultBondDenom, nil + return params.CoinUnit, nil } diff --git a/tests/integration/registry/keeper/common_test.go b/tests/integration/registry/keeper/common_test.go index 095e0b495..1c171dc74 100644 --- a/tests/integration/registry/keeper/common_test.go +++ b/tests/integration/registry/keeper/common_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" + "git.vdb.to/cerc-io/laconicd/app/params" integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration" bondTypes "git.vdb.to/cerc-io/laconicd/x/bond" types "git.vdb.to/cerc-io/laconicd/x/registry" @@ -51,7 +52,7 @@ func (kts *KeeperTestSuite) createBond() (*bondTypes.Bond, error) { // Create a funded account kts.accounts = simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, 1, math.NewInt(1000000000000)) - bond, err := kts.BondKeeper.CreateBond(ctx, kts.accounts[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(1000000000)))) + bond, err := kts.BondKeeper.CreateBond(ctx, kts.accounts[0], sdk.NewCoins(sdk.NewCoin(params.CoinUnit, math.NewInt(1000000000)))) if err != nil { return nil, err } diff --git a/testutil/network/network.go b/testutil/network/network.go index ceed27e13..8711006db 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -60,6 +60,8 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "git.vdb.to/cerc-io/laconicd/app/params" ) // package-wide network lock to only allow one test network at a time @@ -148,8 +150,8 @@ func DefaultConfig(factory TestFixtureFactory) Config { TimeoutCommit: 2 * time.Second, ChainID: "chain-" + unsafe.Str(6), NumValidators: 4, - BondDenom: sdk.DefaultBondDenom, - MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), + BondDenom: params.CoinUnit, + MinGasPrices: fmt.Sprintf("0.000006%s", params.CoinUnit), AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction), StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction), BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction),