From cb6dca43c60dbff76f4ac3693bc0bb074d2a098c Mon Sep 17 00:00:00 2001 From: jgo121 Date: Tue, 2 Jul 2024 23:10:13 +0800 Subject: [PATCH] resolve unit test and unhandled errors --- app/ante/ante_test.go | 13 +++++++------ x/layer2/keeper/keeper.go | 1 + x/layer2/keeper/lp_swap_redeem_convert_test.go | 10 +++++----- x/tokens/client/cli/cli_test.go | 7 +++++++ x/tokens/client/cli/tx.go | 4 ++++ 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/ante/ante_test.go b/app/ante/ante_test.go index ce5f14a4..31109cb9 100644 --- a/app/ante/ante_test.go +++ b/app/ante/ante_test.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + "cosmossdk.io/math" customante "github.com/KiraCore/sekai/app/ante" "github.com/KiraCore/sekai/types" govtypes "github.com/KiraCore/sekai/x/gov/types" @@ -557,17 +558,17 @@ func (suite *AnteTestSuite) TestPoorNetworkManagementDecorator() { msgs := []sdk.Msg{ tokenstypes.NewMsgUpsertTokenInfo( accounts[4].acc.GetAddress(), + "adr20", "foo", - sdk.NewDec(1), - true, - sdk.ZeroDec(), - sdk.ZeroInt(), - false, - false, + sdk.NewDec(1), true, + sdk.ZeroInt(), sdk.ZeroInt(), + sdk.ZeroDec(), sdk.ZeroInt(), + false, false, "FOO", "Foo", "", 6, + "", "", "", 0, math.ZeroInt(), "", false, "", "", ), } return msgs, privs[0:1], accNums[0:1], []uint64{1}, sdk.NewCoins(sdk.NewInt64Coin("ukex", 100)) diff --git a/x/layer2/keeper/keeper.go b/x/layer2/keeper/keeper.go index 582d3b00..e4fc315e 100644 --- a/x/layer2/keeper/keeper.go +++ b/x/layer2/keeper/keeper.go @@ -34,6 +34,7 @@ func NewKeeper(storeKey storetypes.StoreKey, cdc codec.BinaryCodec, sk: sk, gk: gk, spk: spk, + tk: tk, } } diff --git a/x/layer2/keeper/lp_swap_redeem_convert_test.go b/x/layer2/keeper/lp_swap_redeem_convert_test.go index 21a87915..70899459 100644 --- a/x/layer2/keeper/lp_swap_redeem_convert_test.go +++ b/x/layer2/keeper/lp_swap_redeem_convert_test.go @@ -134,14 +134,14 @@ func (suite *KeeperTestSuite) TestRedeemDappPoolTx() { lpToken := dapp.LpToken() lpCoins := sdk.Coins{sdk.NewInt64Coin(lpToken, 10000)} - err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, lpCoins) + err := suite.app.TokensKeeper.MintCoins(suite.ctx, minttypes.ModuleName, lpCoins) suite.Require().NoError(err) addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr, lpCoins) suite.Require().NoError(err) - err = suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, sdk.Coins{dapp.TotalBond}) + err = suite.app.TokensKeeper.MintCoins(suite.ctx, types.ModuleName, sdk.Coins{dapp.TotalBond}) suite.Require().NoError(err) price := suite.app.Layer2Keeper.LpTokenPrice(suite.ctx, dapp) @@ -262,17 +262,17 @@ func (suite *KeeperTestSuite) TestConvertDappPoolTx() { lpToken1 := dapp1.LpToken() lpCoins1 := sdk.Coins{sdk.NewInt64Coin(lpToken1, 10000)} - err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, lpCoins1) + err := suite.app.TokensKeeper.MintCoins(suite.ctx, minttypes.ModuleName, lpCoins1) suite.Require().NoError(err) err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr, lpCoins1) suite.Require().NoError(err) lpToken2 := dapp2.LpToken() lpCoins2 := sdk.Coins{sdk.NewInt64Coin(lpToken2, 10000)} - err = suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, lpCoins2) + err = suite.app.TokensKeeper.MintCoins(suite.ctx, types.ModuleName, lpCoins2) suite.Require().NoError(err) - err = suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, sdk.Coins{dapp1.TotalBond}) + err = suite.app.TokensKeeper.MintCoins(suite.ctx, types.ModuleName, sdk.Coins{dapp1.TotalBond}) suite.Require().NoError(err) price := suite.app.Layer2Keeper.LpTokenPrice(suite.ctx, dapp1) diff --git a/x/tokens/client/cli/cli_test.go b/x/tokens/client/cli/cli_test.go index e4cefd2e..999c2fac 100644 --- a/x/tokens/client/cli/cli_test.go +++ b/x/tokens/client/cli/cli_test.go @@ -75,10 +75,12 @@ func (s *IntegrationTestSuite) TestUpsertTokenInfoAndQuery() { cmd := cli.GetTxUpsertTokenInfoCmd() _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), fmt.Sprintf("--%s=%s", cli.FlagDenom, "ubtc"), fmt.Sprintf("--%s=%s", cli.FlagSupply, "0"), fmt.Sprintf("--%s=%s", cli.FlagSupplyCap, "0"), fmt.Sprintf("--%s=%f", cli.FlagFeeRate, 0.00001), + fmt.Sprintf("--%s=%d", cli.FlagMintingFee, 2), fmt.Sprintf("--%s=%s", cli.FlagFeeEnabled, "true"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), @@ -126,6 +128,11 @@ func (s IntegrationTestSuite) TestCreateProposalUpsertTokenInfo() { fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), fmt.Sprintf("--%s=%s", cli.FlagFeeEnabled, "true"), fmt.Sprintf("--%s=%s", cli.FlagDecimals, "6"), + fmt.Sprintf("--%s=%s", cli.FlagStakeCap, "0.3"), + fmt.Sprintf("--%s=%s", cli.FlagTokenRate, "1"), + fmt.Sprintf("--%s=%s", cli.FlagSupply, "0"), + fmt.Sprintf("--%s=%s", cli.FlagSupplyCap, "0"), + fmt.Sprintf("--%s=%s", cli.FlagMintingFee, "1"), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), diff --git a/x/tokens/client/cli/tx.go b/x/tokens/client/cli/tx.go index f7a121f0..475cfc59 100644 --- a/x/tokens/client/cli/tx.go +++ b/x/tokens/client/cli/tx.go @@ -309,6 +309,9 @@ func GetTxUpsertTokenInfoCmd() *cobra.Command { Short: "Upsert token rate", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } denom, err := cmd.Flags().GetString(FlagDenom) if err != nil { @@ -513,6 +516,7 @@ func GetTxUpsertTokenInfoCmd() *cobra.Command { cmd.Flags().String(FlagNftMetadata, "", "Nft metadata") cmd.Flags().String(FlagNftHash, "", "Nft hash") cmd.Flags().String(FlagTokenType, "", "Token type") + cmd.Flags().String(FlagDescription, "", "Token description") cmd.Flags().String(FlagTokenRate, "", "Token rate") flags.AddTxFlagsToCmd(cmd)