Update e2e and integration tests for new tokens setup (#73)

Part of https://www.notion.so/Multiple-tokens-support-1f2a6b22d47280269f87df3fe03e8d64

Reviewed-on: cerc-io/laconicd#73
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
Prathamesh Musale 2025-05-19 10:10:54 +00:00 committed by nabarun
parent 59236e5ce6
commit e02d221dea
6 changed files with 54 additions and 20 deletions

View File

@ -1,11 +1,13 @@
package e2e package e2e
import ( import (
"encoding/json"
"fmt" "fmt"
"os" "os"
"cosmossdk.io/log" "cosmossdk.io/log"
pruningtypes "cosmossdk.io/store/pruning/types" pruningtypes "cosmossdk.io/store/pruning/types"
"github.com/cosmos/cosmos-sdk/codec"
dbm "github.com/cosmos/cosmos-db" dbm "github.com/cosmos/cosmos-db"
bam "github.com/cosmos/cosmos-sdk/baseapp" 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/auth"
"github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/staking" "github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
laconicApp "git.vdb.to/cerc-io/laconicd/app" laconicApp "git.vdb.to/cerc-io/laconicd/app"
auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module" auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module"
bondmodule "git.vdb.to/cerc-io/laconicd/x/bond/module" bondmodule "git.vdb.to/cerc-io/laconicd/x/bond/module"
registrymodule "git.vdb.to/cerc-io/laconicd/x/registry/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/app/params" // import for side-effects (see init)
"git.vdb.to/cerc-io/laconicd/testutil/network" "git.vdb.to/cerc-io/laconicd/testutil/network"
) )
@ -54,16 +58,40 @@ func NewTestNetworkFixture() network.TestFixture {
return app return app
} }
return network.TestFixture{ encodingConfig := testutil.MakeTestEncodingConfig(
AppConstructor: appCtr,
GenesisState: app.DefaultGenesis(),
EncodingConfig: testutil.MakeTestEncodingConfig(
auth.AppModuleBasic{}, auth.AppModuleBasic{},
bank.AppModuleBasic{}, bank.AppModuleBasic{},
staking.AppModuleBasic{}, staking.AppModuleBasic{},
auctionmodule.AppModule{}, auctionmodule.AppModule{},
bondmodule.AppModule{}, bondmodule.AppModule{},
registrymodule.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: 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
}

View File

@ -10,6 +10,7 @@ import (
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"git.vdb.to/cerc-io/laconicd/app/params"
integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration" integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration"
types "git.vdb.to/cerc-io/laconicd/x/auction" 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(), Signer: accounts[0].String(),
CommitsDuration: 5 * time.Minute, CommitsDuration: 5 * time.Minute,
RevealsDuration: 5 * time.Minute, RevealsDuration: 5 * time.Minute,
CommitFee: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000)), CommitFee: sdk.NewCoin(params.CoinUnit, sdkmath.NewInt(1000)),
RevealFee: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000)), RevealFee: sdk.NewCoin(params.CoinUnit, sdkmath.NewInt(1000)),
MinimumBid: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000000)), MinimumBid: sdk.NewCoin(params.CoinUnit, sdkmath.NewInt(1000000)),
}, },
) )
if err != nil { if err != nil {

View File

@ -8,6 +8,7 @@ import (
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"git.vdb.to/cerc-io/laconicd/app/params"
integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration" integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration"
types "git.vdb.to/cerc-io/laconicd/x/bond" types "git.vdb.to/cerc-io/laconicd/x/bond"
) )
@ -185,7 +186,7 @@ func (kts *KeeperTestSuite) TestGrpcGetModuleBalance() {
if !test.errResponse { if !test.errResponse {
kts.Require().Nil(err) kts.Require().Nil(err)
kts.Require().NotNil(resp.GetBalance()) 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 { } else {
kts.Require().NotNil(err) kts.Require().NotNil(err)
kts.Require().Error(err) kts.Require().Error(err)
@ -201,7 +202,7 @@ func (kts *KeeperTestSuite) createBond() (*types.Bond, error) {
// Create funded account(s) // Create funded account(s)
accounts := simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, accCount, math.NewInt(1000)) 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 { if err != nil {
return nil, err return nil, err
} }

View File

@ -23,6 +23,7 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/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" auctionTypes "git.vdb.to/cerc-io/laconicd/x/auction"
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper" auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module" auctionmodule "git.vdb.to/cerc-io/laconicd/x/auction/module"
@ -82,8 +83,8 @@ func (tf *TestFixture) Setup() error {
runtime.NewKVStoreService(keys[authtypes.StoreKey]), runtime.NewKVStoreService(keys[authtypes.StoreKey]),
authtypes.ProtoBaseAccount, authtypes.ProtoBaseAccount,
maccPerms, maccPerms,
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix), addresscodec.NewBech32Codec(params.Bech32PrefixAccAddr),
sdk.Bech32MainPrefix, params.Bech32PrefixAccAddr,
authority.String(), authority.String(),
) )
@ -161,5 +162,5 @@ func (tf *TestFixture) Setup() error {
type BondDenomProvider struct{} type BondDenomProvider struct{}
func (bdp BondDenomProvider) BondDenom(ctx context.Context) (string, error) { func (bdp BondDenomProvider) BondDenom(ctx context.Context) (string, error) {
return sdk.DefaultBondDenom, nil return params.CoinUnit, nil
} }

View File

@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"git.vdb.to/cerc-io/laconicd/app/params"
integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration" integrationTest "git.vdb.to/cerc-io/laconicd/tests/integration"
bondTypes "git.vdb.to/cerc-io/laconicd/x/bond" bondTypes "git.vdb.to/cerc-io/laconicd/x/bond"
types "git.vdb.to/cerc-io/laconicd/x/registry" types "git.vdb.to/cerc-io/laconicd/x/registry"
@ -51,7 +52,7 @@ func (kts *KeeperTestSuite) createBond() (*bondTypes.Bond, error) {
// Create a funded account // Create a funded account
kts.accounts = simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, 1, math.NewInt(1000000000000)) 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 { if err != nil {
return nil, err return nil, err
} }

View File

@ -60,6 +60,8 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank _ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank
_ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank _ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" 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 // 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, TimeoutCommit: 2 * time.Second,
ChainID: "chain-" + unsafe.Str(6), ChainID: "chain-" + unsafe.Str(6),
NumValidators: 4, NumValidators: 4,
BondDenom: sdk.DefaultBondDenom, BondDenom: params.CoinUnit,
MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), MinGasPrices: fmt.Sprintf("0.000006%s", params.CoinUnit),
AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction), AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction),
StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction), StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction),
BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction), BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction),