From d1c3f36bbeeb298f0df518e1b871debb834e080d Mon Sep 17 00:00:00 2001 From: Solovyov1796 Date: Wed, 1 May 2024 16:07:32 +0800 Subject: [PATCH] fix test --- cli_test/test_helpers.go | 3 +-- x/bep3/genesis_test.go | 4 ++-- x/bep3/keeper/asset_test.go | 4 ++-- x/bep3/keeper/keeper_test.go | 4 ++-- x/bep3/keeper/swap_test.go | 4 ++-- x/bep3/legacy/v0_17/migrate_test.go | 3 ++- x/bep3/types/genesis_test.go | 5 ++--- x/bep3/types/msg_test.go | 7 +++---- x/bep3/types/params_test.go | 4 ++-- x/bep3/types/swap_test.go | 4 ++-- x/committee/testutil/suite.go | 4 ++-- x/evmutil/types/msg_test.go | 5 +++-- x/evmutil/types/params_test.go | 4 ++-- x/issuance/legacy/v0_16/migrate_test.go | 3 ++- x/pricefeed/legacy/v0_16/migrate_test.go | 3 ++- 15 files changed, 31 insertions(+), 30 deletions(-) diff --git a/cli_test/test_helpers.go b/cli_test/test_helpers.go index be1046f8..58f4b75f 100644 --- a/cli_test/test_helpers.go +++ b/cli_test/test_helpers.go @@ -65,8 +65,7 @@ var ( func init() { // set the address prefixes - config := sdk.GetConfig() - app.SetBech32AddressPrefixes(config) + chaincfg.SetSDKConfig() // config.Seal() } diff --git a/x/bep3/genesis_test.go b/x/bep3/genesis_test.go index aff40b8d..0771b368 100644 --- a/x/bep3/genesis_test.go +++ b/x/bep3/genesis_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/bep3/keeper" "github.com/0glabs/0g-chain/x/bep3/types" ) @@ -25,8 +26,7 @@ type GenesisTestSuite struct { } func (suite *GenesisTestSuite) SetupTest() { - config := sdk.GetConfig() - app.SetBech32AddressPrefixes(config) + chaincfg.SetSDKConfig() tApp := app.NewTestApp() suite.ctx = tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()}) diff --git a/x/bep3/keeper/asset_test.go b/x/bep3/keeper/asset_test.go index 74910709..6fd33023 100644 --- a/x/bep3/keeper/asset_test.go +++ b/x/bep3/keeper/asset_test.go @@ -14,6 +14,7 @@ import ( tmtime "github.com/cometbft/cometbft/types/time" "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/bep3/keeper" "github.com/0glabs/0g-chain/x/bep3/types" ) @@ -27,8 +28,7 @@ type AssetTestSuite struct { } func (suite *AssetTestSuite) SetupTest() { - config := sdk.GetConfig() - app.SetBech32AddressPrefixes(config) + chaincfg.SetSDKConfig() // Initialize test app and set context tApp := app.NewTestApp() diff --git a/x/bep3/keeper/keeper_test.go b/x/bep3/keeper/keeper_test.go index 909c283c..278ff324 100644 --- a/x/bep3/keeper/keeper_test.go +++ b/x/bep3/keeper/keeper_test.go @@ -12,6 +12,7 @@ import ( tmtime "github.com/cometbft/cometbft/types/time" "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/bep3/keeper" "github.com/0glabs/0g-chain/x/bep3/types" ) @@ -27,8 +28,7 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - config := sdk.GetConfig() - app.SetBech32AddressPrefixes(config) + chaincfg.SetSDKConfig() suite.ResetChain() } diff --git a/x/bep3/keeper/swap_test.go b/x/bep3/keeper/swap_test.go index 59d388d3..bca2f081 100644 --- a/x/bep3/keeper/swap_test.go +++ b/x/bep3/keeper/swap_test.go @@ -13,6 +13,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/bep3" "github.com/0glabs/0g-chain/x/bep3/keeper" "github.com/0glabs/0g-chain/x/bep3/types" @@ -40,8 +41,7 @@ const ( ) func (suite *AtomicSwapTestSuite) SetupTest() { - config := sdk.GetConfig() - app.SetBech32AddressPrefixes(config) + chaincfg.SetSDKConfig() // Initialize test app and set context tApp := app.NewTestApp() diff --git a/x/bep3/legacy/v0_17/migrate_test.go b/x/bep3/legacy/v0_17/migrate_test.go index 7a61d47f..ed7ae385 100644 --- a/x/bep3/legacy/v0_17/migrate_test.go +++ b/x/bep3/legacy/v0_17/migrate_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/suite" app "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/bep3/types" ) @@ -25,7 +26,7 @@ type migrateTestSuite struct { } func (s *migrateTestSuite) SetupTest() { - app.SetSDKConfig() + chaincfg.SetSDKConfig() s.v16genstate = types.GenesisState{ PreviousBlockTime: time.Date(2021, 4, 8, 15, 0, 0, 0, time.UTC), diff --git a/x/bep3/types/genesis_test.go b/x/bep3/types/genesis_test.go index 0b516c2e..eecbde98 100644 --- a/x/bep3/types/genesis_test.go +++ b/x/bep3/types/genesis_test.go @@ -9,7 +9,7 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/bep3/types" ) @@ -99,8 +99,7 @@ func (suite *GenesisTestSuite) TestValidate() { for _, tc := range testCases { suite.Run(tc.name, func() { - config := sdk.GetConfig() - app.SetBech32AddressPrefixes(config) + chaincfg.SetSDKConfig() var gs types.GenesisState if tc.name == "default" { gs = types.DefaultGenesisState() diff --git a/x/bep3/types/msg_test.go b/x/bep3/types/msg_test.go index bc15efd9..8354c6a9 100644 --- a/x/bep3/types/msg_test.go +++ b/x/bep3/types/msg_test.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" - "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/bep3/types" ) @@ -22,7 +22,7 @@ var ( ) func init() { - app.SetSDKConfig() + chaincfg.SetSDKConfig() // Must be set after SetSDKConfig to use 0g Bech32 prefix instead of cosmos binanceAddrs = []sdk.AccAddress{ @@ -40,8 +40,7 @@ type MsgTestSuite struct { } func (suite *MsgTestSuite) SetupTest() { - config := sdk.GetConfig() - app.SetBech32AddressPrefixes(config) + chaincfg.SetSDKConfig() } func (suite *MsgTestSuite) TestMsgCreateAtomicSwap() { diff --git a/x/bep3/types/params_test.go b/x/bep3/types/params_test.go index 4a42663a..b09665d3 100644 --- a/x/bep3/types/params_test.go +++ b/x/bep3/types/params_test.go @@ -10,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/bep3/types" ) @@ -20,8 +21,7 @@ type ParamsTestSuite struct { } func (suite *ParamsTestSuite) SetupTest() { - config := sdk.GetConfig() - app.SetBech32AddressPrefixes(config) + chaincfg.SetSDKConfig() _, addrs := app.GeneratePrivKeyAddressPairs(1) suite.addr = addrs[0] supply1 := types.SupplyLimit{ diff --git a/x/bep3/types/swap_test.go b/x/bep3/types/swap_test.go index 5ad432b7..f4014871 100644 --- a/x/bep3/types/swap_test.go +++ b/x/bep3/types/swap_test.go @@ -11,6 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/bep3/types" ) @@ -23,8 +24,7 @@ type AtomicSwapTestSuite struct { func (suite *AtomicSwapTestSuite) SetupTest() { // Generate 10 addresses - config := sdk.GetConfig() - app.SetBech32AddressPrefixes(config) + chaincfg.SetSDKConfig() _, addrs := app.GeneratePrivKeyAddressPairs(10) // Generate 10 timestamps and random number hashes diff --git a/x/committee/testutil/suite.go b/x/committee/testutil/suite.go index 5504a2bf..1af18959 100644 --- a/x/committee/testutil/suite.go +++ b/x/committee/testutil/suite.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/committee/keeper" "github.com/0glabs/0g-chain/x/committee/types" ) @@ -25,8 +26,7 @@ type Suite struct { // SetupTest instantiates a new app, keepers, and sets suite state func (suite *Suite) SetupTest() { - config := sdk.GetConfig() - app.SetBech32AddressPrefixes(config) + chaincfg.SetSDKConfig() suite.App = app.NewTestApp() suite.Keeper = suite.App.GetCommitteeKeeper() suite.BankKeeper = suite.App.GetBankKeeper() diff --git a/x/evmutil/types/msg_test.go b/x/evmutil/types/msg_test.go index ab17f4fa..de0d58d2 100644 --- a/x/evmutil/types/msg_test.go +++ b/x/evmutil/types/msg_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/evmutil/testutil" "github.com/0glabs/0g-chain/x/evmutil/types" "github.com/stretchr/testify/require" @@ -13,7 +14,7 @@ import ( ) func TestMsgConvertCoinToERC20(t *testing.T) { - app.SetSDKConfig() + chaincfg.SetSDKConfig() type errArgs struct { expectPass bool @@ -118,7 +119,7 @@ func TestMsgConvertCoinToERC20(t *testing.T) { } func TestMsgConvertERC20ToCoin(t *testing.T) { - app.SetSDKConfig() + chaincfg.SetSDKConfig() type errArgs struct { expectPass bool diff --git a/x/evmutil/types/params_test.go b/x/evmutil/types/params_test.go index 30d1a290..8daabd0a 100644 --- a/x/evmutil/types/params_test.go +++ b/x/evmutil/types/params_test.go @@ -9,7 +9,7 @@ import ( paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" "github.com/0glabs/0g-chain/x/evmutil/testutil" "github.com/0glabs/0g-chain/x/evmutil/types" ) @@ -19,7 +19,7 @@ type ParamsTestSuite struct { } func (suite *ParamsTestSuite) SetupTest() { - app.SetSDKConfig() + chaincfg.SetSDKConfig() } func (suite *ParamsTestSuite) TestDefault() { diff --git a/x/issuance/legacy/v0_16/migrate_test.go b/x/issuance/legacy/v0_16/migrate_test.go index aad8b522..822de87e 100644 --- a/x/issuance/legacy/v0_16/migrate_test.go +++ b/x/issuance/legacy/v0_16/migrate_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/suite" app "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" v015issuance "github.com/0glabs/0g-chain/x/issuance/legacy/v0_15" v016issuance "github.com/0glabs/0g-chain/x/issuance/types" ) @@ -24,7 +25,7 @@ type migrateTestSuite struct { } func (s *migrateTestSuite) SetupTest() { - app.SetSDKConfig() + chaincfg.SetSDKConfig() s.v15genstate = v015issuance.GenesisState{ Params: v015issuance.Params{}, diff --git a/x/pricefeed/legacy/v0_16/migrate_test.go b/x/pricefeed/legacy/v0_16/migrate_test.go index eb1658b2..fdbdf8ec 100644 --- a/x/pricefeed/legacy/v0_16/migrate_test.go +++ b/x/pricefeed/legacy/v0_16/migrate_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/suite" app "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" v015pricefeed "github.com/0glabs/0g-chain/x/pricefeed/legacy/v0_15" v016pricefeed "github.com/0glabs/0g-chain/x/pricefeed/types" ) @@ -23,7 +24,7 @@ type migrateTestSuite struct { } func (s *migrateTestSuite) SetupTest() { - app.SetSDKConfig() + chaincfg.SetSDKConfig() s.v15genstate = v015pricefeed.GenesisState{ Params: v015pricefeed.Params{},