Skip to content

Commit

Permalink
Revert "CM-145 REST Version String Interface (#64)"
Browse files Browse the repository at this point in the history
This reverts commit 8895e3e
  • Loading branch information
ebruck committed Mar 30, 2020
1 parent 20538d5 commit a9c523b
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 33 deletions.
8 changes: 0 additions & 8 deletions x/crud/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@ func BlzQCountHandler(cliCtx context.CLIContext, storeName string) http.HandlerF
}
}

func BlzQVersionHandler(cliCtx context.CLIContext, storeName string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
res, _, _ := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/version", storeName), nil)

rest.PostProcessResponse(w, cliCtx, res)
}
}

func BlzQGetLeaseHandler(cliCtx context.CLIContext, storeName string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
Expand Down
1 change: 0 additions & 1 deletion x/crud/client/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, storeName string)
r.HandleFunc(fmt.Sprintf("/%s/read/{UUID}/{key}", storeName), BlzQReadHandler(cliCtx, storeName)).Methods("GET")
r.HandleFunc(fmt.Sprintf("/%s/rename", storeName), BlzRenameHandler(cliCtx)).Methods("POST")
r.HandleFunc(fmt.Sprintf("/%s/update", storeName), BlzUpdateHandler(cliCtx)).Methods("POST")
r.HandleFunc(fmt.Sprintf("/%s/version", storeName), BlzQVersionHandler(cliCtx, storeName)).Methods("GET")
}
9 changes: 0 additions & 9 deletions x/crud/internal/keeper/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
package keeper

import (
"encoding/json"
"github.com/bluzelle/curium/x/crud/internal/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/version"
abci "github.com/tendermint/tendermint/abci/types"
"strconv"
)
Expand All @@ -31,7 +29,6 @@ const (
QueryKeys = "keys"
QueryKeyValues = "keyvalues"
QueryCount = "count"
QueryVersion = "version"
QueryGetLease = "getlease"
QueryGetNShortestLease = "getnshortestlease"
)
Expand All @@ -49,8 +46,6 @@ func NewQuerier(keeper IKeeper) sdk.Querier {
return queryKeyValues(ctx, path[1:], req, keeper, keeper.GetCdc())
case QueryCount:
return queryCount(ctx, path[1:], req, keeper, keeper.GetCdc())
case QueryVersion:
return queryVersion()
case QueryGetLease:
return queryGetLease(ctx, path[1:], req, keeper, keeper.GetCdc())
case QueryGetNShortestLease:
Expand Down Expand Up @@ -114,10 +109,6 @@ func queryCount(ctx sdk.Context, path []string, _ abci.RequestQuery, keeper IKee
return res, nil
}

func queryVersion() ([]byte, error) {
return json.Marshal(version.NewInfo())
}

func queryGetLease(ctx sdk.Context, path []string, _ abci.RequestQuery, keeper IKeeper, cdc *codec.Codec) ([]byte, error) {
blzValue := keeper.GetValue(ctx, keeper.GetKVStore(ctx), path[0], path[1])

Expand Down
15 changes: 0 additions & 15 deletions x/crud/internal/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/bluzelle/curium/x/crud/mocks"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
abci "github.com/tendermint/tendermint/abci/types"
Expand Down Expand Up @@ -159,20 +158,6 @@ func Test_queryCount(t *testing.T) {
assert.Equal(t, uint64(2), json_result.Count)
}

func Test_queryVersion(t *testing.T) {
ctx, _, mockKeeper := initTest(t)
result, err := NewQuerier(mockKeeper)(ctx, []string{"version"}, abci.RequestQuery{})
assert.Nil(t, err)

json_result := version.Info{}
json.Unmarshal(result, &json_result)

// We can only verify that the api got called and not the data since that is set
// only when we build the client & server processes.
assert.Equal(t, json_result.ServerName, "<appd>")
assert.Equal(t, json_result.ClientName, "<appcli>")
}

func Test_queryGetLease(t *testing.T) {
ctx, cdc, mockKeeper := initTest(t)

Expand Down

0 comments on commit a9c523b

Please sign in to comment.