From 3bca9f88ab79ee926664a308e88ed889394e8aef Mon Sep 17 00:00:00 2001 From: vbstreetz <60554509+vbstreetz@users.noreply.github.com> Date: Thu, 23 Apr 2020 07:09:39 +0300 Subject: [PATCH] fix: pluralize GetNShortestLeases (#111) since it returns a list of keyleases Co-authored-by: Neeraj Murarka --- x/crud/client/cli/query.go | 10 +++++----- x/crud/client/cli/tx.go | 8 ++++---- x/crud/client/rest/query.go | 4 ++-- x/crud/client/rest/rest.go | 4 ++-- x/crud/client/rest/tx.go | 8 ++++---- x/crud/handler.go | 8 ++++---- x/crud/handler_test.go | 12 ++++++------ x/crud/internal/keeper/keeper.go | 4 ++-- x/crud/internal/keeper/keeper_test.go | 8 ++++---- x/crud/internal/keeper/querier.go | 10 +++++----- x/crud/internal/keeper/querier_test.go | 8 ++++---- x/crud/internal/types/codec.go | 2 +- x/crud/internal/types/msgs.go | 12 ++++++------ x/crud/internal/types/msgs_test.go | 22 +++++++++++----------- x/crud/mocks/mock_keeper.go | 12 ++++++------ x/crud/module_test.go | 4 ++-- 16 files changed, 68 insertions(+), 68 deletions(-) diff --git a/x/crud/client/cli/query.go b/x/crud/client/cli/query.go index 3cf18916..c8a7fa63 100644 --- a/x/crud/client/cli/query.go +++ b/x/crud/client/cli/query.go @@ -41,7 +41,7 @@ func GetQueryCmd(storeKey string, cdc *codec.Codec) *cobra.Command { GetCmdQKeyValues(storeKey, cdc), GetCmdQCount(storeKey, cdc), GetCmdQGetLease(storeKey, cdc), - GetCmdQGetNShortestLease(storeKey, cdc), + GetCmdQGetNShortestLeases(storeKey, cdc), )...) return crudQueryCmd @@ -173,10 +173,10 @@ func GetCmdQGetLease(queryRoute string, cdc *codec.Codec) *cobra.Command { } } -func GetCmdQGetNShortestLease(queryRoute string, cdc *codec.Codec) *cobra.Command { +func GetCmdQGetNShortestLeases(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ - Use: "getnshortestlease [UUID] [N]", - Short: "getnshortestlease UUID N", + Use: "getnshortestleases [UUID] [N]", + Short: "getnshortestleases UUID N", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) @@ -188,7 +188,7 @@ func GetCmdQGetNShortestLease(queryRoute string, cdc *codec.Codec) *cobra.Comman return nil } - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/getnshortestlease/%s/%d", queryRoute, UUID, N), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/getnshortestleases/%s/%d", queryRoute, UUID, N), nil) var out types.QueryResultNShortestLeaseKeys cdc.MustUnmarshalJSON(res, &out) diff --git a/x/crud/client/cli/tx.go b/x/crud/client/cli/tx.go index 204fa41b..08645b4e 100644 --- a/x/crud/client/cli/tx.go +++ b/x/crud/client/cli/tx.go @@ -45,7 +45,7 @@ func GetTxCmd(_ string, cdc *codec.Codec) *cobra.Command { GetCmdDelete(cdc), GetCmdDeleteAll(cdc), GetCmdGetLease(cdc), - GetCmdGetNShortestLease(cdc), + GetCmdGetNShortestLeases(cdc), GetCmdHas(cdc), GetCmdKeyValues(cdc), GetCmdKeys(cdc), @@ -329,9 +329,9 @@ func GetCmdGetLease(cdc *codec.Codec) *cobra.Command { } } -func GetCmdGetNShortestLease(cdc *codec.Codec) *cobra.Command { +func GetCmdGetNShortestLeases(cdc *codec.Codec) *cobra.Command { return &cobra.Command{ - Use: "getnshortestlease [UUID] [N]", + Use: "getnshortestleases [UUID] [N]", Short: "get the N shortest remaining lease blocks for an existing UUID", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { @@ -345,7 +345,7 @@ func GetCmdGetNShortestLease(cdc *codec.Codec) *cobra.Command { return err } - msg := types.MsgGetNShortestLease{UUID: args[0], N: N, Owner: cliCtx.GetFromAddress()} + msg := types.MsgGetNShortestLeases{UUID: args[0], N: N, Owner: cliCtx.GetFromAddress()} err = msg.ValidateBasic() if err != nil { diff --git a/x/crud/client/rest/query.go b/x/crud/client/rest/query.go index e0c0f8f3..bb200e09 100644 --- a/x/crud/client/rest/query.go +++ b/x/crud/client/rest/query.go @@ -112,11 +112,11 @@ func BlzQGetLeaseHandler(cliCtx context.CLIContext, storeName string) http.Handl } } -func BlzQGetNShortestLeaseHandler(cliCtx context.CLIContext, storeName string) http.HandlerFunc { +func BlzQGetNShortestLeasesHandler(cliCtx context.CLIContext, storeName string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/getnshortestlease/%s/%s", storeName, vars["UUID"], vars["N"]), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/getnshortestleases/%s/%s", storeName, vars["UUID"], vars["N"]), nil) if err != nil { rest.WriteErrorResponse(w, http.StatusNotFound, err.Error()) return diff --git a/x/crud/client/rest/rest.go b/x/crud/client/rest/rest.go index 26aa959d..f70ea533 100644 --- a/x/crud/client/rest/rest.go +++ b/x/crud/client/rest/rest.go @@ -29,8 +29,8 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, storeName string) r.HandleFunc(fmt.Sprintf("/%s/deleteall", storeName), BlzDeleteAllHandler(cliCtx)).Methods("POST") r.HandleFunc(fmt.Sprintf("/%s/getlease", storeName), BlzGetLeaseHandler(cliCtx)).Methods("POST") r.HandleFunc(fmt.Sprintf("/%s/getlease/{UUID}/{key}", storeName), BlzQGetLeaseHandler(cliCtx, storeName)).Methods("GET") - r.HandleFunc(fmt.Sprintf("/%s/getnshortestlease", storeName), BlzGetNShortestLeaseHandler(cliCtx)).Methods("POST") - r.HandleFunc(fmt.Sprintf("/%s/getnshortestlease/{UUID}/{N}", storeName), BlzQGetNShortestLeaseHandler(cliCtx, storeName)).Methods("GET") + r.HandleFunc(fmt.Sprintf("/%s/getnshortestleases", storeName), BlzGetNShortestLeasesHandler(cliCtx)).Methods("POST") + r.HandleFunc(fmt.Sprintf("/%s/getnshortestleases/{UUID}/{N}", storeName), BlzQGetNShortestLeasesHandler(cliCtx, storeName)).Methods("GET") r.HandleFunc(fmt.Sprintf("/%s/has", storeName), BlzHasHandler(cliCtx)).Methods("POST") r.HandleFunc(fmt.Sprintf("/%s/has/{UUID}/{key}", storeName), BlzQHasHandler(cliCtx, storeName)).Methods("GET") r.HandleFunc(fmt.Sprintf("/%s/keys", storeName), BlzKeysHandler(cliCtx)).Methods("POST") diff --git a/x/crud/client/rest/tx.go b/x/crud/client/rest/tx.go index 3509d0d0..73ed70bf 100644 --- a/x/crud/client/rest/tx.go +++ b/x/crud/client/rest/tx.go @@ -500,16 +500,16 @@ func BlzGetLeaseHandler(cliCtx context.CLIContext) http.HandlerFunc { /////////////////////////////////////////////////////////////////////////////// // Get N Shortest Lease -type GetNShortestLeaseReq struct { +type GetNShortestLeasesReq struct { BaseReq rest.BaseReq UUID string N uint64 Owner string } -func BlzGetNShortestLeaseHandler(cliCtx context.CLIContext) http.HandlerFunc { +func BlzGetNShortestLeasesHandler(cliCtx context.CLIContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - var req GetNShortestLeaseReq + var req GetNShortestLeasesReq if !rest.ReadRESTReq(w, r, cliCtx.Codec, &req) { rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse request") @@ -528,7 +528,7 @@ func BlzGetNShortestLeaseHandler(cliCtx context.CLIContext) http.HandlerFunc { } // create the message - msg := types.MsgGetNShortestLease{UUID: req.UUID, N: req.N, Owner: addr} + msg := types.MsgGetNShortestLeases{UUID: req.UUID, N: req.N, Owner: addr} err = msg.ValidateBasic() if err != nil { rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) diff --git a/x/crud/handler.go b/x/crud/handler.go index 55f72adf..1a62b302 100644 --- a/x/crud/handler.go +++ b/x/crud/handler.go @@ -50,8 +50,8 @@ func NewHandler(keeper keeper.IKeeper) sdk.Handler { return handleMsgMultiUpdate(ctx, keeper, msg) case types.MsgGetLease: return handleMsgGetLease(ctx, keeper, msg) - case types.MsgGetNShortestLease: - return handleMsgGetNShortestLease(ctx, keeper, msg) + case types.MsgGetNShortestLeases: + return handleMsgGetNShortestLeases(ctx, keeper, msg) case types.MsgRenewLease: return handleMsgRenewLease(ctx, keeper, msg) case types.MsgRenewLeaseAll: @@ -298,12 +298,12 @@ func handleMsgGetLease(ctx sdk.Context, keeper keeper.IKeeper, msg types.MsgGetL return &sdk.Result{Data: jsonData}, nil } -func handleMsgGetNShortestLease(ctx sdk.Context, keeper keeper.IKeeper, msg types.MsgGetNShortestLease) (*sdk.Result, error) { +func handleMsgGetNShortestLeases(ctx sdk.Context, keeper keeper.IKeeper, msg types.MsgGetNShortestLeases) (*sdk.Result, error) { if len(msg.UUID) == 0 || msg.N == 0 || msg.Owner.Empty() { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid message") } - value := keeper.GetNShortestLease(ctx, keeper.GetKVStore(ctx), msg.UUID, msg.Owner, msg.N) + value := keeper.GetNShortestLeases(ctx, keeper.GetKVStore(ctx), msg.UUID, msg.Owner, msg.N) jsonData, err := json.Marshal(value) diff --git a/x/crud/handler_test.go b/x/crud/handler_test.go index 03779433..92bfbbcc 100644 --- a/x/crud/handler_test.go +++ b/x/crud/handler_test.go @@ -776,7 +776,7 @@ func Test_handleMsgGetLease(t *testing.T) { } -func Test_handleMsgGetNShortestLease(t *testing.T) { +func Test_handleMsgGetNShortestLeases(t *testing.T) { mockCtrl, mockKeeper, ctx, owner := initTest(t) defer mockCtrl.Finish() @@ -793,9 +793,9 @@ func Test_handleMsgGetNShortestLease(t *testing.T) { } mockKeeper.EXPECT().GetKVStore(gomock.Any()).AnyTimes().Return(nil) - mockKeeper.EXPECT().GetNShortestLease(ctx, nil, "uuid", gomock.Any(), uint64(5)).Return(response) + mockKeeper.EXPECT().GetNShortestLeases(ctx, nil, "uuid", gomock.Any(), uint64(5)).Return(response) - result, err := NewHandler(mockKeeper)(ctx, types.MsgGetNShortestLease{UUID: "uuid", Owner: owner, N: 5}) + result, err := NewHandler(mockKeeper)(ctx, types.MsgGetNShortestLeases{UUID: "uuid", Owner: owner, N: 5}) assert.Nil(t, err) jsonResult := types.QueryResultNShortestLeaseKeys{} @@ -805,13 +805,13 @@ func Test_handleMsgGetNShortestLease(t *testing.T) { // Test for empty message parameters { - _, err := handleMsgGetNShortestLease(ctx, mockKeeper, types.MsgGetNShortestLease{}) + _, err := handleMsgGetNShortestLeases(ctx, mockKeeper, types.MsgGetNShortestLeases{}) assert.NotNil(t, err) - _, err = handleMsgGetNShortestLease(ctx, mockKeeper, types.MsgGetNShortestLease{UUID: "uuid"}) + _, err = handleMsgGetNShortestLeases(ctx, mockKeeper, types.MsgGetNShortestLeases{UUID: "uuid"}) assert.NotNil(t, err) - _, err = handleMsgGetNShortestLease(ctx, mockKeeper, types.MsgGetNShortestLease{UUID: "uuid", N: 11}) + _, err = handleMsgGetNShortestLeases(ctx, mockKeeper, types.MsgGetNShortestLeases{UUID: "uuid", N: 11}) assert.NotNil(t, err) } } diff --git a/x/crud/internal/keeper/keeper.go b/x/crud/internal/keeper/keeper.go index 70c7cb4c..c0d39e70 100644 --- a/x/crud/internal/keeper/keeper.go +++ b/x/crud/internal/keeper/keeper.go @@ -43,7 +43,7 @@ type IKeeper interface { GetKeyValues(ctx sdk.Context, store sdk.KVStore, UUID string, owner sdk.AccAddress) types.QueryResultKeyValues GetKeys(ctx sdk.Context, store sdk.KVStore, UUID string, owner sdk.AccAddress) types.QueryResultKeys GetLeaseStore(ctx sdk.Context) sdk.KVStore - GetNShortestLease(ctx sdk.Context, store sdk.KVStore, UUID string, owner sdk.AccAddress, n uint64) types.QueryResultNShortestLeaseKeys + GetNShortestLeases(ctx sdk.Context, store sdk.KVStore, UUID string, owner sdk.AccAddress, n uint64) types.QueryResultNShortestLeaseKeys GetOwner(ctx sdk.Context, store sdk.KVStore, UUID string, key string) sdk.AccAddress GetValue(ctx sdk.Context, store sdk.KVStore, UUID string, key string) types.BLZValue GetValuesIterator(ctx sdk.Context, store sdk.KVStore) sdk.Iterator @@ -284,7 +284,7 @@ func (k Keeper) ProcessLeasesAtBlockHeight(_ sdk.Context, store sdk.KVStore, lea } } -func (k Keeper) GetNShortestLease(ctx sdk.Context, store sdk.KVStore, UUID string, owner sdk.AccAddress, n uint64) types.QueryResultNShortestLeaseKeys { +func (k Keeper) GetNShortestLeases(ctx sdk.Context, store sdk.KVStore, UUID string, owner sdk.AccAddress, n uint64) types.QueryResultNShortestLeaseKeys { keys := k.GetKeys(ctx, store, UUID, owner) if len(keys.Keys) == 0 { diff --git a/x/crud/internal/keeper/keeper_test.go b/x/crud/internal/keeper/keeper_test.go index f0902c5a..ed241eea 100644 --- a/x/crud/internal/keeper/keeper_test.go +++ b/x/crud/internal/keeper/keeper_test.go @@ -490,7 +490,7 @@ func TestKeeper_GetCdc(t *testing.T) { assert.Equal(t, cdc, keeper.GetCdc()) } -func TestKeeper_GetNShortestLease(t *testing.T) { +func TestKeeper_GetNShortestLeases(t *testing.T) { ctx, testStore, owner, cdc := initKeeperTest() keeper := NewKeeper(nil, nil, nil, cdc, MaxKeeperSizes{MaxKeysSize: 1024}) @@ -509,7 +509,7 @@ func TestKeeper_GetNShortestLease(t *testing.T) { // there are at least 10 keys newCtx := ctx.WithBlockHeight(currentBlockHeight) - response := keeper.GetNShortestLease(newCtx, testStore, "uuid", owner, 5) + response := keeper.GetNShortestLeases(newCtx, testStore, "uuid", owner, 5) assert.Equal(t, "uuid", response.UUID) assert.Equal(t, 5, len(response.KeyLeases)) @@ -517,11 +517,11 @@ func TestKeeper_GetNShortestLease(t *testing.T) { assert.Equal(t, "key9910", response.KeyLeases[0].Key) assert.Equal(t, 9910+1000-currentBlockHeight, response.KeyLeases[0].Lease) - response = keeper.GetNShortestLease(newCtx, testStore, "wronguuid", owner, 5) + response = keeper.GetNShortestLeases(newCtx, testStore, "wronguuid", owner, 5) assert.Equal(t, "wronguuid", response.UUID) assert.Equal(t, 0, len(response.KeyLeases)) - response = keeper.GetNShortestLease(newCtx, testStore, "uuid", owner, 11) + response = keeper.GetNShortestLeases(newCtx, testStore, "uuid", owner, 11) assert.Equal(t, "uuid", response.UUID) assert.Equal(t, 10, len(response.KeyLeases)) diff --git a/x/crud/internal/keeper/querier.go b/x/crud/internal/keeper/querier.go index a807d512..aeec75e6 100644 --- a/x/crud/internal/keeper/querier.go +++ b/x/crud/internal/keeper/querier.go @@ -30,7 +30,7 @@ const ( QueryKeyValues = "keyvalues" QueryCount = "count" QueryGetLease = "getlease" - QueryGetNShortestLease = "getnshortestlease" + QueryGetNShortestLeases = "getnshortestleases" ) func NewQuerier(keeper IKeeper) sdk.Querier { @@ -48,8 +48,8 @@ func NewQuerier(keeper IKeeper) sdk.Querier { return queryCount(ctx, path[1:], req, keeper, keeper.GetCdc()) case QueryGetLease: return queryGetLease(ctx, path[1:], req, keeper, keeper.GetCdc()) - case QueryGetNShortestLease: - return queryGetNShortestLease(ctx, path[1:], req, keeper, keeper.GetCdc()) + case QueryGetNShortestLeases: + return queryGetNShortestLeases(ctx, path[1:], req, keeper, keeper.GetCdc()) default: return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown crud query endpoint") } @@ -124,14 +124,14 @@ func queryGetLease(ctx sdk.Context, path []string, _ abci.RequestQuery, keeper I return res, nil } -func queryGetNShortestLease(ctx sdk.Context, path []string, _ abci.RequestQuery, keeper IKeeper, cdc *codec.Codec) ([]byte, error) { +func queryGetNShortestLeases(ctx sdk.Context, path []string, _ abci.RequestQuery, keeper IKeeper, cdc *codec.Codec) ([]byte, error) { N, err := strconv.ParseUint(path[1], 10, 64) if err != nil { return []byte{}, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } - value := keeper.GetNShortestLease(ctx, keeper.GetKVStore(ctx), path[0], nil, N) + value := keeper.GetNShortestLeases(ctx, keeper.GetKVStore(ctx), path[0], nil, N) res, err := codec.MarshalJSONIndent(cdc, value) if err != nil { diff --git a/x/crud/internal/keeper/querier_test.go b/x/crud/internal/keeper/querier_test.go index c29bca31..0c8fb128 100644 --- a/x/crud/internal/keeper/querier_test.go +++ b/x/crud/internal/keeper/querier_test.go @@ -191,11 +191,11 @@ func Test_queryGetLease(t *testing.T) { assert.NotNil(t, err) } -func Test_queryGetNShortestLease(t *testing.T) { +func Test_queryGetNShortestLeases(t *testing.T) { ctx, cdc, mockKeeper := initTest(t) mockKeeper.EXPECT().GetKVStore(gomock.Any()).AnyTimes().Return(nil) - mockKeeper.EXPECT().GetNShortestLease(ctx, nil, "uuid", nil, uint64(10)).Return(types.QueryResultNShortestLeaseKeys{ + mockKeeper.EXPECT().GetNShortestLeases(ctx, nil, "uuid", nil, uint64(10)).Return(types.QueryResultNShortestLeaseKeys{ UUID: "uuid", KeyLeases: types.KeyLeases{ types.KeyLease{ @@ -207,7 +207,7 @@ func Test_queryGetNShortestLease(t *testing.T) { mockKeeper.EXPECT().GetCdc().AnyTimes().Return(cdc) - result, err := NewQuerier(mockKeeper)(ctx, []string{"getnshortestlease", "uuid", "10"}, abci.RequestQuery{}) + result, err := NewQuerier(mockKeeper)(ctx, []string{"getnshortestleases", "uuid", "10"}, abci.RequestQuery{}) assert.Nil(t, err) jsonResult := types.QueryResultNShortestLeaseKeys{} @@ -217,7 +217,7 @@ func Test_queryGetNShortestLease(t *testing.T) { assert.Equal(t, "key00", jsonResult.KeyLeases[0].Key) assert.Equal(t, int64(100), jsonResult.KeyLeases[0].Lease) - _, err = NewQuerier(mockKeeper)(ctx, []string{"getnshortestlease", "uuid", "abcd"}, abci.RequestQuery{}) + _, err = NewQuerier(mockKeeper)(ctx, []string{"getnshortestleases", "uuid", "abcd"}, abci.RequestQuery{}) assert.NotNil(t, err) } diff --git a/x/crud/internal/types/codec.go b/x/crud/internal/types/codec.go index 4ca38715..a0f97b3e 100644 --- a/x/crud/internal/types/codec.go +++ b/x/crud/internal/types/codec.go @@ -30,7 +30,7 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgDeleteAll{}, "crud/deleteall", nil) cdc.RegisterConcrete(MsgDelete{}, "crud/delete", nil) cdc.RegisterConcrete(MsgGetLease{}, "crud/getlease", nil) - cdc.RegisterConcrete(MsgGetNShortestLease{}, "crud/getnshortestlease", nil) + cdc.RegisterConcrete(MsgGetNShortestLeases{}, "crud/getnshortestleases", nil) cdc.RegisterConcrete(MsgHas{}, "crud/has", nil) cdc.RegisterConcrete(MsgKeyValues{}, "crud/keyvalues", nil) cdc.RegisterConcrete(MsgKeys{}, "crud/keys", nil) diff --git a/x/crud/internal/types/msgs.go b/x/crud/internal/types/msgs.go index 938c6fbc..01ae9d99 100644 --- a/x/crud/internal/types/msgs.go +++ b/x/crud/internal/types/msgs.go @@ -503,17 +503,17 @@ func (msg MsgGetLease) GetSigners() []sdk.AccAddress { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // GetLease -type MsgGetNShortestLease struct { +type MsgGetNShortestLeases struct { UUID string N uint64 Owner sdk.AccAddress } -func (msg MsgGetNShortestLease) Route() string { return RouterKey } +func (msg MsgGetNShortestLeases) Route() string { return RouterKey } -func (msg MsgGetNShortestLease) Type() string { return "getnshortestlease" } +func (msg MsgGetNShortestLeases) Type() string { return "getnshortestleases" } -func (msg MsgGetNShortestLease) ValidateBasic() error { +func (msg MsgGetNShortestLeases) ValidateBasic() error { if msg.Owner.Empty() { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Owner.String()) } @@ -529,11 +529,11 @@ func (msg MsgGetNShortestLease) ValidateBasic() error { return nil } -func (msg MsgGetNShortestLease) GetSignBytes() []byte { +func (msg MsgGetNShortestLeases) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) } -func (msg MsgGetNShortestLease) GetSigners() []sdk.AccAddress { +func (msg MsgGetNShortestLeases) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Owner} } diff --git a/x/crud/internal/types/msgs_test.go b/x/crud/internal/types/msgs_test.go index cdc1ce61..13f57105 100644 --- a/x/crud/internal/types/msgs_test.go +++ b/x/crud/internal/types/msgs_test.go @@ -614,16 +614,16 @@ func TestMsgGetLease_GetSigners(t *testing.T) { } ///////////////////////////////////////////////////////////////////////////////// -func TestMsgGetNShortestLease_Route(t *testing.T) { - Equal(t, "crud", MsgGetNShortestLease{}.Route()) +func TestMsgGetNShortestLeases_Route(t *testing.T) { + Equal(t, "crud", MsgGetNShortestLeases{}.Route()) } -func TestMsgGetNShortestLease_Type(t *testing.T) { - Equal(t, "getnshortestlease", MsgGetNShortestLease{}.Type()) +func TestMsgGetNShortestLeases_Type(t *testing.T) { + Equal(t, "getnshortestleases", MsgGetNShortestLeases{}.Type()) } -func TestMsgGetNShortestLease_ValidateBasic(t *testing.T) { - sut := MsgGetNShortestLease{ +func TestMsgGetNShortestLeases_ValidateBasic(t *testing.T) { + sut := MsgGetNShortestLeases{ UUID: "uuid", N: 10, Owner: []byte("bluzelle1t0ywtmrduldf6h4wqrnnpyp9wr6law2u5jwa23"), @@ -644,17 +644,17 @@ func TestMsgGetNShortestLease_ValidateBasic(t *testing.T) { } -func TestMsgGetNShortestLease_GetSignBytes(t *testing.T) { - sut := MsgGetNShortestLease{ +func TestMsgGetNShortestLeases_GetSignBytes(t *testing.T) { + sut := MsgGetNShortestLeases{ UUID: "uuid", N: 10, Owner: []byte("bluzelle1t0ywtmrduldf6h4wqrnnpyp9wr6law2u5jwa23"), } - Equal(t, "{\"type\":\"crud/getnshortestlease\",\"value\":{\"N\":\"10\",\"Owner\":\"cosmos1vfk827n9d3kx2vt5xpuhwardwfj82mryvcmxsdrhw9exumns09crjamjxekxzaejw56k5ampxgeslhg4h3\",\"UUID\":\"uuid\"}}", string(sut.GetSignBytes())) + Equal(t, "{\"type\":\"crud/getnshortestleases\",\"value\":{\"N\":\"10\",\"Owner\":\"cosmos1vfk827n9d3kx2vt5xpuhwardwfj82mryvcmxsdrhw9exumns09crjamjxekxzaejw56k5ampxgeslhg4h3\",\"UUID\":\"uuid\"}}", string(sut.GetSignBytes())) } -func TestMsgGetNShortestLease_GetSigners(t *testing.T) { - sut := MsgGetNShortestLease{ +func TestMsgGetNShortestLeases_GetSigners(t *testing.T) { + sut := MsgGetNShortestLeases{ UUID: "uuid", N: 10, Owner: []byte("bluzelle1t0ywtmrduldf6h4wqrnnpyp9wr6law2u5jwa23"), diff --git a/x/crud/mocks/mock_keeper.go b/x/crud/mocks/mock_keeper.go index baaf12e9..07068495 100644 --- a/x/crud/mocks/mock_keeper.go +++ b/x/crud/mocks/mock_keeper.go @@ -171,18 +171,18 @@ func (mr *MockIKeeperMockRecorder) GetLeaseStore(arg0 interface{}) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLeaseStore", reflect.TypeOf((*MockIKeeper)(nil).GetLeaseStore), arg0) } -// GetNShortestLease mocks base method -func (m *MockIKeeper) GetNShortestLease(arg0 types1.Context, arg1 types0.KVStore, arg2 string, arg3 types1.AccAddress, arg4 uint64) types.QueryResultNShortestLeaseKeys { +// GetNShortestLeases mocks base method +func (m *MockIKeeper) GetNShortestLeases(arg0 types1.Context, arg1 types0.KVStore, arg2 string, arg3 types1.AccAddress, arg4 uint64) types.QueryResultNShortestLeaseKeys { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetNShortestLease", arg0, arg1, arg2, arg3, arg4) + ret := m.ctrl.Call(m, "GetNShortestLeases", arg0, arg1, arg2, arg3, arg4) ret0, _ := ret[0].(types.QueryResultNShortestLeaseKeys) return ret0 } -// GetNShortestLease indicates an expected call of GetNShortestLease -func (mr *MockIKeeperMockRecorder) GetNShortestLease(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +// GetNShortestLeases indicates an expected call of GetNShortestLeases +func (mr *MockIKeeperMockRecorder) GetNShortestLeases(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNShortestLease", reflect.TypeOf((*MockIKeeper)(nil).GetNShortestLease), arg0, arg1, arg2, arg3, arg4) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNShortestLeases", reflect.TypeOf((*MockIKeeper)(nil).GetNShortestLeases), arg0, arg1, arg2, arg3, arg4) } // GetOwner mocks base method diff --git a/x/crud/module_test.go b/x/crud/module_test.go index 32776268..5411bdc9 100644 --- a/x/crud/module_test.go +++ b/x/crud/module_test.go @@ -77,8 +77,8 @@ func TestAppModuleBasic_GetQueryCmd_CrudQueries(t *testing.T) { commands := command.Commands() assert.Len(t, command.Commands(), 7) - expectedUses := [...]string{"count [UUID]", "getlease [UUID] [key]", "getnshortestlease [UUID] [N]", "has [UUID] [key]", "keys [UUID]", "keyvalues [UUID]", "read [UUID] [key]"} - expectedNames := [...]string{"count", "getlease", "getnshortestlease", "has", "keys", "keyvalues", "read"} + expectedUses := [...]string{"count [UUID]", "getlease [UUID] [key]", "getnshortestleases [UUID] [N]", "has [UUID] [key]", "keys [UUID]", "keyvalues [UUID]", "read [UUID] [key]"} + expectedNames := [...]string{"count", "getlease", "getnshortestleases", "has", "keys", "keyvalues", "read"} for i := 0; i < len(command.Commands()); i++ { expectedUse := expectedUses[i]