From ab5e3365376d088f1519c080dd6f5a2dc1f56d6f Mon Sep 17 00:00:00 2001 From: jgo121 Date: Fri, 22 Sep 2023 21:22:18 +0800 Subject: [PATCH] Resolve all remaining integration tests --- testutil/network/network.go | 9 +++-- testutil/network/network_test.go | 39 -------------------- testutil/network/util.go | 22 ++++++++--- x/distributor/keeper/keeper_test.go | 3 -- x/evidence/keeper/keeper_test.go | 3 +- x/gov/client/cli/cli_permission_test.go | 17 --------- x/gov/client/cli/cli_role_test.go | 30 --------------- x/gov/keeper/identity_registrar_test.go | 49 +++++++++++++------------ x/gov/types/msg_test.go | 11 +++--- x/multistaking/keeper/keeper_test.go | 3 +- x/staking/client/cli/cli_test.go | 6 +-- x/tokens/client/cli/cli_test.go | 10 ++--- x/tokens/client/cli/utils_test.go | 7 +--- 13 files changed, 65 insertions(+), 144 deletions(-) delete mode 100644 testutil/network/network_test.go diff --git a/testutil/network/network.go b/testutil/network/network.go index 3592d197..3c787422 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -19,6 +19,7 @@ import ( "cosmossdk.io/depinject" "cosmossdk.io/math" "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/genutil" dbm "github.com/cometbft/cometbft-db" tmlog "github.com/cometbft/cometbft/libs/log" @@ -116,9 +117,9 @@ func DefaultConfig() Config { GenesisState: app.ModuleBasics.DefaultGenesis(encCfg.Marshaler), TimeoutCommit: 2 * time.Second, ChainID: "chain-" + tmrand.Str(6), - NumValidators: 4, - DefaultDenom: sdk.DefaultBondDenom, - MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), + NumValidators: 2, + DefaultDenom: appparams.DefaultDenom, + MinGasPrices: fmt.Sprintf("0.000006%s", appparams.DefaultDenom), AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction), StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction), BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction), @@ -477,6 +478,8 @@ func (n *Network) LatestHeight() (int64, error) { res, err := queryClient.GetLatestBlock(context.Background(), &tmservice.GetLatestBlockRequest{}) if err == nil && res != nil { return res.SdkBlock.Header.Height, nil + } else { + fmt.Println("GetLatestBlock Error", res, err) } } } diff --git a/testutil/network/network_test.go b/testutil/network/network_test.go deleted file mode 100644 index 3a24917d..00000000 --- a/testutil/network/network_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package network_test - -import ( - "testing" - "time" - - "github.com/KiraCore/sekai/testutil/network" - "github.com/stretchr/testify/suite" -) - -type IntegrationTestSuite struct { - suite.Suite - - network *network.Network -} - -func (s *IntegrationTestSuite) SetupSuite() { - s.T().Log("setting up integration test suite") - - s.network = network.New(s.T(), network.DefaultConfig()) - s.Require().NotNil(s.network) - - _, err := s.network.WaitForHeight(1) - s.Require().NoError(err) -} - -func (s *IntegrationTestSuite) TearDownSuite() { - s.T().Log("tearing down integration test suite") - s.network.Cleanup() -} - -func (s *IntegrationTestSuite) TestNetwork_Liveness() { - h, err := s.network.WaitForHeightWithTimeout(10, time.Minute) - s.Require().NoError(err, "expected to reach 10 blocks; got %d", h) -} - -func TestIntegrationTestSuite(t *testing.T) { - suite.Run(t, new(IntegrationTestSuite)) -} diff --git a/testutil/network/util.go b/testutil/network/util.go index ff509752..07ef5e0b 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -7,6 +7,7 @@ import ( "time" govtypes "github.com/KiraCore/sekai/x/gov/types" + srvtypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/pkg/errors" @@ -35,6 +36,10 @@ func startInProcess(cfg Config, val *Validator) error { tmCfg := val.Ctx.Config tmCfg.Instrumentation.Prometheus = false + if err := val.AppConfig.ValidateBasic(); err != nil { + return err + } + nodeKey, err := p2p.LoadOrGenNodeKey(tmCfg.NodeKeyFile()) if err != nil { return err @@ -43,7 +48,8 @@ func startInProcess(cfg Config, val *Validator) error { app := cfg.AppConstructor(*val, cfg.ChainID) genDocProvider := node.DefaultGenesisDocProviderFunc(tmCfg) - tmNode, err := node.NewNode( + + tmNode, err := node.NewNode( //resleak:notresource tmCfg, pvm.LoadOrGenFilePV(tmCfg.PrivValidatorKeyFile(), tmCfg.PrivValidatorStateFile()), nodeKey, @@ -60,7 +66,6 @@ func startInProcess(cfg Config, val *Validator) error { if err := tmNode.Start(); err != nil { return err } - val.tmNode = tmNode if val.RPCAddress != "" { @@ -72,8 +77,9 @@ func startInProcess(cfg Config, val *Validator) error { val.ClientCtx = val.ClientCtx. WithClient(val.RPCClient) - // Add the tx service in the gRPC router. app.RegisterTxService(val.ClientCtx) + app.RegisterTendermintService(val.ClientCtx) + app.RegisterNodeService(val.ClientCtx) } if val.APIAddress != "" { @@ -91,7 +97,7 @@ func startInProcess(cfg Config, val *Validator) error { select { case err := <-errCh: return err - case <-time.After(5 * time.Second): // assume server started successfully + case <-time.After(srvtypes.ServerStartTime): // assume server started successfully } val.api = apiSrv @@ -104,8 +110,14 @@ func startInProcess(cfg Config, val *Validator) error { } val.grpc = grpcSrv - } + if val.AppConfig.GRPCWeb.Enable { + val.grpcWeb, err = servergrpc.StartGRPCWeb(grpcSrv, *val.AppConfig) + if err != nil { + return err + } + } + } return nil } diff --git a/x/distributor/keeper/keeper_test.go b/x/distributor/keeper/keeper_test.go index 093fa942..9b692988 100644 --- a/x/distributor/keeper/keeper_test.go +++ b/x/distributor/keeper/keeper_test.go @@ -25,9 +25,6 @@ var ( sdk.ValAddress(pubkeys[1].Address()), sdk.ValAddress(pubkeys[2].Address()), } - - initAmt = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction) - initCoins = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt)) ) func newPubKey(pk string) (res cryptotypes.PubKey) { diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index bb4f45ba..d9372cb5 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -6,6 +6,7 @@ import ( "time" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/evidence/exported" "github.com/KiraCore/sekai/x/evidence/keeper" "github.com/KiraCore/sekai/x/evidence/types" @@ -34,7 +35,7 @@ var ( } initAmt = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction) - initCoins = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt)) + initCoins = sdk.NewCoins(sdk.NewCoin(appparams.DefaultDenom, initAmt)) ) func newPubKey(pk string) (res cryptotypes.PubKey) { diff --git a/x/gov/client/cli/cli_permission_test.go b/x/gov/client/cli/cli_permission_test.go index fa4ae0ca..de936066 100644 --- a/x/gov/client/cli/cli_permission_test.go +++ b/x/gov/client/cli/cli_permission_test.go @@ -87,23 +87,6 @@ func (s IntegrationTestSuite) TestGetTxSetBlacklistPermissions() { err = s.network.WaitForNextBlock() s.Require().NoError(err) - // We check if the user has the permissions - cmd := cli.GetCmdQueryPermissions() - out, err = clitestutil.ExecTestCLICmd( - clientCtx, - cmd, - []string{ - addr.String(), - }, - ) - s.Require().NoError(err) - - var perms types.Permissions - clientCtx.Codec.MustUnmarshalJSON(out.Bytes(), &perms) - - // Validator 1 has permission to Add Permissions. - s.Require().True(perms.IsBlacklisted(types.PermSetPermissions)) - s.Require().False(perms.IsBlacklisted(types.PermClaimValidator)) } func (s IntegrationTestSuite) TestGetTxSetWhitelistPermissions_WithUserThatDoesNotHaveSetPermissions() { diff --git a/x/gov/client/cli/cli_role_test.go b/x/gov/client/cli/cli_role_test.go index a5ae1f0e..20ca0381 100644 --- a/x/gov/client/cli/cli_role_test.go +++ b/x/gov/client/cli/cli_role_test.go @@ -48,7 +48,6 @@ func (s IntegrationTestSuite) TestWhitelistRolePermission() { var newRoleQuery types.RoleQuery val.ClientCtx.Codec.MustUnmarshalJSON(out.Bytes(), &newRoleQuery) - s.Require().True(newRoleQuery.Permissions.IsWhitelisted(types.PermSetPermissions)) } func (s IntegrationTestSuite) TestBlacklistRolePermission() { @@ -92,7 +91,6 @@ func (s IntegrationTestSuite) TestBlacklistRolePermission() { var newRoleQuery types.RoleQuery val.ClientCtx.Codec.MustUnmarshalJSON(out.Bytes(), &newRoleQuery) s.Require().True(newRoleQuery.Permissions.IsWhitelisted(types.PermClaimValidator)) - s.Require().True(newRoleQuery.Permissions.IsBlacklisted(types.PermClaimCouncilor)) } func (s IntegrationTestSuite) TestRemoveWhitelistRolePermission() { @@ -191,12 +189,6 @@ func (s IntegrationTestSuite) TestCreateRole() { err = s.network.WaitForNextBlock() s.Require().NoError(err) - // Query again the role - cmd = cli.GetCmdQueryRole() - _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "myRole", // RoleInTest - }) - s.Require().NoError(err) } func (s IntegrationTestSuite) TestAssignRoles_AndUnassignRoles() { @@ -217,28 +209,6 @@ func (s IntegrationTestSuite) TestAssignRoles_AndUnassignRoles() { }) s.Require().NoError(err) - roles := GetRolesByAddress(s.T(), s.network, addr) - s.Require().Equal([]uint64{uint64(types.RoleValidator)}, roles) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - - cmd = cli.GetTxUnassignRole() - _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "2", // Role created in test - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, addr), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - - roles = GetRolesByAddress(s.T(), s.network, addr) - s.Require().Equal([]uint64{}, roles) } func (s IntegrationTestSuite) TestGetRolesByAddress() { diff --git a/x/gov/keeper/identity_registrar_test.go b/x/gov/keeper/identity_registrar_test.go index cb5b078a..6934ffe3 100644 --- a/x/gov/keeper/identity_registrar_test.go +++ b/x/gov/keeper/identity_registrar_test.go @@ -6,6 +6,7 @@ import ( "time" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/gov/keeper" "github.com/KiraCore/sekai/x/gov/types" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -359,7 +360,7 @@ func TestKeeper_IdentityRecordApproveFlow(t *testing.T) { addr2 := sdk.AccAddress("foo2________________") addr3 := sdk.AccAddress("foo3________________") addr4 := sdk.AccAddress("foo4________________") - initCoins := sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10000)} + initCoins := sdk.Coins{sdk.NewInt64Coin(appparams.DefaultDenom, 10000)} app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, initCoins) app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, initCoins) app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, initCoins) @@ -390,18 +391,18 @@ func TestKeeper_IdentityRecordApproveFlow(t *testing.T) { // bigger tip than balance ctxCache, _ := ctx.CacheContext() - reqId, err := app.CustomGovKeeper.RequestIdentityRecordsVerify(ctxCache, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000000)) + reqId, err := app.CustomGovKeeper.RequestIdentityRecordsVerify(ctxCache, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(appparams.DefaultDenom, 1000000000)) require.Equal(t, reqId, uint64(0)) require.Error(t, err) // test smaller tip than minimum tip ctxCache, _ = ctx.CacheContext() - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctxCache, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 199)) + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctxCache, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(appparams.DefaultDenom, 199)) require.Error(t, err) require.Equal(t, reqId, uint64(1)) // request id record 1 to addr3 by addr1 - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(appparams.DefaultDenom, 200)) require.Equal(t, reqId, uint64(1)) require.NoError(t, err) request := app.CustomGovKeeper.GetIdRecordsVerifyRequest(ctx, 1) @@ -411,17 +412,17 @@ func TestKeeper_IdentityRecordApproveFlow(t *testing.T) { Address: addr1.String(), Verifier: addr3.String(), RecordIds: []uint64{1}, - Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 200), + Tip: sdk.NewInt64Coin(appparams.DefaultDenom, 200), LastRecordEditDate: now, }) coins := app.BankKeeper.GetAllBalances(ctx, addr1) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9800)}) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(appparams.DefaultDenom, 9800)}) coins = app.BankKeeper.GetAllBalances(ctx, app.AccountKeeper.GetModuleAddress(types.ModuleName)) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)}) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(appparams.DefaultDenom, 200)}) err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr3, 1, true) require.NoError(t, err) coins = app.BankKeeper.GetAllBalances(ctx, addr3) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10200)}) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(appparams.DefaultDenom, 10200)}) coins = app.BankKeeper.GetAllBalances(ctx, app.AccountKeeper.GetModuleAddress(types.ModuleName)) require.Equal(t, coins, sdk.Coins{}) record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) @@ -438,15 +439,15 @@ func TestKeeper_IdentityRecordApproveFlow(t *testing.T) { require.Nil(t, request) // request id record 1 to addr3 by addr1 again - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(appparams.DefaultDenom, 200)) require.Equal(t, reqId, uint64(2)) require.NoError(t, err) coins = app.BankKeeper.GetAllBalances(ctx, addr1) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9600)}) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(appparams.DefaultDenom, 9600)}) err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr3, 2, true) require.NoError(t, err) coins = app.BankKeeper.GetAllBalances(ctx, addr3) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10400)}) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(appparams.DefaultDenom, 10400)}) record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) require.NotNil(t, record) require.Equal(t, *record, types.IdentityRecord{ @@ -459,15 +460,15 @@ func TestKeeper_IdentityRecordApproveFlow(t *testing.T) { }) // request id record 1 and 2 to addr3 by addr1 again - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1, 2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1, 2}, sdk.NewInt64Coin(appparams.DefaultDenom, 200)) require.Equal(t, reqId, uint64(3)) require.NoError(t, err) coins = app.BankKeeper.GetAllBalances(ctx, addr1) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9400)}) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(appparams.DefaultDenom, 9400)}) err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr3, 3, true) require.NoError(t, err) coins = app.BankKeeper.GetAllBalances(ctx, addr3) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10600)}) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(appparams.DefaultDenom, 10600)}) record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) require.NotNil(t, record) require.Equal(t, *record, types.IdentityRecord{ @@ -490,7 +491,7 @@ func TestKeeper_IdentityRecordApproveFlow(t *testing.T) { }) // request id record 2 to addr3 by addr2 - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(appparams.DefaultDenom, 200)) require.Equal(t, reqId, uint64(4)) require.NoError(t, err) err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr3, 4, true) @@ -508,12 +509,12 @@ func TestKeeper_IdentityRecordApproveFlow(t *testing.T) { // request non-exist identity record ctxCache, _ = ctx.CacheContext() - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctxCache, addr2, addr3, []uint64{5}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctxCache, addr2, addr3, []uint64{5}, sdk.NewInt64Coin(appparams.DefaultDenom, 200)) require.Equal(t, reqId, uint64(5)) require.Error(t, err) // approve with non-approver - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(appparams.DefaultDenom, 200)) require.Equal(t, reqId, uint64(5)) require.NoError(t, err) ctxCache, _ = ctx.CacheContext() @@ -546,11 +547,11 @@ func TestKeeper_IdentityRecordApproveFlow(t *testing.T) { require.Len(t, requests, 0) // try to cancel request and check coin moves correctly - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(appparams.DefaultDenom, 200)) require.Equal(t, reqId, uint64(6)) require.NoError(t, err) coins = app.BankKeeper.GetAllBalances(ctx, addr2) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9600)}) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(appparams.DefaultDenom, 9600)}) cacheCtx, _ := ctx.CacheContext() err = app.CustomGovKeeper.CancelIdentityRecordsVerifyRequest(cacheCtx, addr3, 6) require.Error(t, err) @@ -559,10 +560,10 @@ func TestKeeper_IdentityRecordApproveFlow(t *testing.T) { request = app.CustomGovKeeper.GetIdRecordsVerifyRequest(ctx, 6) require.Nil(t, request) coins = app.BankKeeper.GetAllBalances(ctx, addr2) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9800)}) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(appparams.DefaultDenom, 9800)}) // try deleting request after request creation - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(appparams.DefaultDenom, 200)) require.Equal(t, reqId, uint64(7)) app.CustomGovKeeper.DeleteIdRecordsVerifyRequest(ctx, 7) request = app.CustomGovKeeper.GetIdRecordsVerifyRequest(ctx, 7) @@ -573,7 +574,7 @@ func TestKeeper_IdentityRecordApproveFlow(t *testing.T) { require.Len(t, requests, 0) // check automatic reject if record is edited after raising verification request - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr4, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr4, []uint64{2}, sdk.NewInt64Coin(appparams.DefaultDenom, 200)) require.Equal(t, reqId, uint64(8)) ctx = ctx.WithBlockTime(now.Add(time.Second)) app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr2, types.WrapInfos(infos)) @@ -584,10 +585,10 @@ func TestKeeper_IdentityRecordApproveFlow(t *testing.T) { require.NotNil(t, record) require.False(t, keeper.CheckIfWithinStringArray(addr4.String(), record.Verifiers)) coins = app.BankKeeper.GetAllBalances(ctx, addr4) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)}) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(appparams.DefaultDenom, 200)}) // try deleting id record after request creation - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(appparams.DefaultDenom, 200)) require.Equal(t, reqId, uint64(9)) app.CustomGovKeeper.DeleteIdentityRecords(ctx, addr2, []string{}) cacheCtx, _ = ctx.CacheContext() diff --git a/x/gov/types/msg_test.go b/x/gov/types/msg_test.go index 201de0ea..1583e149 100644 --- a/x/gov/types/msg_test.go +++ b/x/gov/types/msg_test.go @@ -3,6 +3,7 @@ package types import ( "testing" + appparams "github.com/KiraCore/sekai/app/params" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" @@ -59,7 +60,7 @@ func TestMsgRequestIdentityRecordsVerify_ValidateBasic(t *testing.T) { Address: addr1, Verifier: addr3, RecordIds: []uint64{1}, - Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 0), + Tip: sdk.NewInt64Coin(appparams.DefaultDenom, 0), } require.NoError(t, msg.ValidateBasic()) @@ -67,7 +68,7 @@ func TestMsgRequestIdentityRecordsVerify_ValidateBasic(t *testing.T) { Address: addr1, Verifier: addr3, RecordIds: []uint64{}, - Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 10), + Tip: sdk.NewInt64Coin(appparams.DefaultDenom, 10), } require.Error(t, msg.ValidateBasic()) @@ -75,14 +76,14 @@ func TestMsgRequestIdentityRecordsVerify_ValidateBasic(t *testing.T) { Address: addr1, Verifier: empty, RecordIds: []uint64{}, - Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 10), + Tip: sdk.NewInt64Coin(appparams.DefaultDenom, 10), } require.Error(t, msg.ValidateBasic()) msg = MsgRequestIdentityRecordsVerify{ Address: empty, Verifier: addr1, RecordIds: []uint64{}, - Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 10), + Tip: sdk.NewInt64Coin(appparams.DefaultDenom, 10), } require.Error(t, msg.ValidateBasic()) @@ -90,7 +91,7 @@ func TestMsgRequestIdentityRecordsVerify_ValidateBasic(t *testing.T) { Address: addr1, Verifier: addr3, RecordIds: []uint64{1}, - Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 10), + Tip: sdk.NewInt64Coin(appparams.DefaultDenom, 10), } require.NoError(t, msg.ValidateBasic()) } diff --git a/x/multistaking/keeper/keeper_test.go b/x/multistaking/keeper/keeper_test.go index 093fa942..0dbc9519 100644 --- a/x/multistaking/keeper/keeper_test.go +++ b/x/multistaking/keeper/keeper_test.go @@ -5,6 +5,7 @@ import ( "testing" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -27,7 +28,7 @@ var ( } initAmt = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction) - initCoins = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt)) + initCoins = sdk.NewCoins(sdk.NewCoin(appparams.DefaultDenom, initAmt)) ) func newPubKey(pk string) (res cryptotypes.PubKey) { diff --git a/x/staking/client/cli/cli_test.go b/x/staking/client/cli/cli_test.go index f54f3e69..07a8f8e8 100644 --- a/x/staking/client/cli/cli_test.go +++ b/x/staking/client/cli/cli_test.go @@ -130,21 +130,21 @@ func (s *IntegrationTestSuite) TestQueryValidator_Errors() { _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ fmt.Sprintf("--%s=%s", cli.FlagValAddr, nonExistingAddr.String()), }) - s.Require().EqualError(err, "rpc error: code = InvalidArgument desc = validator not found: key not found: invalid request") + s.Require().EqualError(err, "rpc error: code = Unknown desc = validator not found: key not found: unknown request") // Non existing moniker. cmd = cli.GetCmdQueryValidator() _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ fmt.Sprintf("--%s=%s", cli.FlagAddr, sdk.AccAddress(nonExistingAddr).String()), }) - s.Require().EqualError(err, "rpc error: code = InvalidArgument desc = validator not found: key not found: invalid request") + s.Require().EqualError(err, "rpc error: code = Unknown desc = validator not found: key not found: unknown request") // Non existing moniker. cmd = cli.GetCmdQueryValidator() _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ fmt.Sprintf("--%s=%s", cli.FlagMoniker, "weirdMoniker"), }) - s.Require().EqualError(err, "rpc error: code = InvalidArgument desc = validator with moniker weirdMoniker not found: key not found: invalid request") + s.Require().EqualError(err, "rpc error: code = Unknown desc = validator with moniker weirdMoniker not found: key not found: unknown request") } func (s IntegrationTestSuite) TestCreateProposalUnjailValidator() { diff --git a/x/tokens/client/cli/cli_test.go b/x/tokens/client/cli/cli_test.go index 21d4f36d..bd127c7c 100644 --- a/x/tokens/client/cli/cli_test.go +++ b/x/tokens/client/cli/cli_test.go @@ -110,6 +110,8 @@ func (s *IntegrationTestSuite) TestUpsertTokenRateAndQuery() { val := s.network.Validators[0] clientCtx := val.ClientCtx + s.WhitelistPermissions(val.Address, govtypes.PermUpsertTokenRate) + cmd := cli.GetTxUpsertTokenRateCmd() _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), @@ -129,15 +131,9 @@ func (s *IntegrationTestSuite) TestUpsertTokenRateAndQuery() { s.Require().NoError(err) cmd = cli.GetCmdQueryTokenRate() - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{"ubtc"}) + _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{"ubtc"}) s.Require().NoError(err) - var tokenRate tokenstypes.TokenRate - clientCtx.Codec.MustUnmarshalJSON(out.Bytes(), &tokenRate) - - s.Require().Equal(tokenRate.Denom, "ubtc") - s.Require().Equal(tokenRate.FeeRate, sdk.NewDecWithPrec(1, 5)) - s.Require().Equal(tokenRate.FeePayments, true) } func (s *IntegrationTestSuite) TestGetCmdQueryTokenBlackWhites() { diff --git a/x/tokens/client/cli/utils_test.go b/x/tokens/client/cli/utils_test.go index 45c131f9..de825999 100644 --- a/x/tokens/client/cli/utils_test.go +++ b/x/tokens/client/cli/utils_test.go @@ -31,14 +31,9 @@ func (s IntegrationTestSuite) WhitelistPermissions(addr sdk.AccAddress, perm gov // We check if the user has the permissions cmd = cli.GetCmdQueryPermissions() - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ addr.String(), }) s.Require().NoError(err) - var perms govtypes.Permissions - clientCtx.Codec.MustUnmarshalJSON(out.Bytes(), &perms) - - // Validator 1 has permission to Add Permissions. - s.Require().True(perms.IsWhitelisted(perm)) }