Skip to content

Commit

Permalink
Rename GRPCRouter (#8079)
Browse files Browse the repository at this point in the history
* rename GRPCRouter

* Update store/types/store.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Fix gofmt

Co-authored-by: Robert Zaremba <robert@zaremba.ch>
  • Loading branch information
anilcse and robert-zaremba authored Dec 4, 2020
1 parent 7ec3bcd commit 4a233b8
Show file tree
Hide file tree
Showing 31 changed files with 76 additions and 53 deletions.
2 changes: 1 addition & 1 deletion baseapp/grpcrouter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

func TestGRPCRouter(t *testing.T) {
func TestGRPCGatewayRouter(t *testing.T) {
qr := baseapp.NewGRPCQueryRouter()
interfaceRegistry := testdata.NewTestInterfaceRegistry()
qr.SetInterfaceRegistry(interfaceRegistry)
Expand Down
10 changes: 5 additions & 5 deletions server/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (

// Server defines the server's API interface.
type Server struct {
Router *mux.Router
GRPCRouter *runtime.ServeMux
ClientCtx client.Context
Router *mux.Router
GRPCGatewayRouter *runtime.ServeMux
ClientCtx client.Context

logger log.Logger
metrics *telemetry.Metrics
Expand Down Expand Up @@ -63,7 +63,7 @@ func New(clientCtx client.Context, logger log.Logger) *Server {
Router: mux.NewRouter(),
ClientCtx: clientCtx,
logger: logger,
GRPCRouter: runtime.NewServeMux(
GRPCGatewayRouter: runtime.NewServeMux(
// Custom marshaler option is required for gogo proto
runtime.WithMarshalerOption(runtime.MIMEWildcard, marshalerOption),

Expand Down Expand Up @@ -124,7 +124,7 @@ func (s *Server) Close() error {
}

func (s *Server) registerGRPCGatewayRoutes() {
s.Router.PathPrefix("/").Handler(s.GRPCRouter)
s.Router.PathPrefix("/").Handler(s.GRPCGatewayRouter)
}

func (s *Server) registerMetrics() {
Expand Down
3 changes: 2 additions & 1 deletion server/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
"strings"
"testing"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client/flags"
)

var CancelledInPreRun = errors.New("Canelled in prerun")
Expand Down
6 changes: 3 additions & 3 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,13 @@ func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICon
// Register legacy tx routes.
authrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCRouter)
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register new tendermint queries routes from grpc-gateway.
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCRouter)
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register legacy and grpc-gateway routes for all modules.
ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router)
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCRouter)
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// register swagger API from root so that other applications can override easily
if apiConfig.Swagger {
Expand Down
2 changes: 1 addition & 1 deletion store/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"io"

abci "github.com/tendermint/tendermint/abci/types"
tmstrings "github.com/tendermint/tendermint/libs/strings"
dbm "github.com/tendermint/tm-db"

snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
"github.com/cosmos/cosmos-sdk/types/kv"
tmstrings "github.com/tendermint/tendermint/libs/strings"
)

type Store interface {
Expand Down
3 changes: 2 additions & 1 deletion types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"sort"
"strings"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/gogo/protobuf/jsonpb"
proto "github.com/gogo/protobuf/proto"
abci "github.com/tendermint/tendermint/abci/types"

"github.com/cosmos/cosmos-sdk/codec"
)

// ----------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion types/tx_msg.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package types

import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/gogo/protobuf/proto"

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
)

type (
Expand Down
3 changes: 2 additions & 1 deletion x/bank/client/rest/rest.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package rest

import (
"github.com/cosmos/cosmos-sdk/client/rest"
"github.com/gorilla/mux"

"github.com/cosmos/cosmos-sdk/client/rest"

"github.com/cosmos/cosmos-sdk/client"
)

Expand Down
1 change: 1 addition & 0 deletions x/distribution/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/armon/go-metrics"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
Expand Down
2 changes: 1 addition & 1 deletion x/evidence/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (s *IntegrationTestSuite) TestGetQueryCmd() {
expectedOutput string
expectErr bool
}{
"non-existant evidence": {
"non-existent evidence": {
[]string{"DF0C23E8634E480F84B9D5674A7CDC9816466DEC28A3358F73260F68D28D7660"},
"evidence DF0C23E8634E480F84B9D5674A7CDC9816466DEC28A3358F73260F68D28D7660 not found",
true,
Expand Down
3 changes: 2 additions & 1 deletion x/gov/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package keeper_test
import (
"testing"

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
)

var (
Expand Down
1 change: 1 addition & 0 deletions x/gov/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"

"github.com/armon/go-metrics"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
Expand Down
10 changes: 5 additions & 5 deletions x/ibc/core/02-client/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (suite *KeeperTestSuite) TestQueryClientState() {
{
"success",
func() {
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)

var err error
Expand Down Expand Up @@ -183,10 +183,10 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() {
"invalid height",
func() {
req = &types.QueryConsensusStateRequest{
ClientId: testClientID,
ClientId: testClientID,
RevisionNumber: 0,
RevisionHeight: 0,
LatestHeight: false,
LatestHeight: false,
}
},
false,
Expand All @@ -204,7 +204,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() {
{
"success latest height",
func() {
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
cs := ibctmtypes.NewConsensusState(
suite.consensusState.Timestamp, commitmenttypes.NewMerkleRoot([]byte("hash1")), nil,
)
Expand Down Expand Up @@ -235,7 +235,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() {
suite.Require().NoError(err)

req = &types.QueryConsensusStateRequest{
ClientId: testClientID,
ClientId: testClientID,
RevisionNumber: 0,
RevisionHeight: height,
}
Expand Down
3 changes: 2 additions & 1 deletion x/ibc/core/02-client/types/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"math"
"testing"

"github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
)

// tests ParseClientIdentifier and IsValidClientID
Expand Down
3 changes: 2 additions & 1 deletion x/ibc/core/02-client/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package types
import (
"testing"

"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
)

func TestValidateParams(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions x/ibc/core/03-connection/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() {
"invalid connection ID",
func() {
req = &types.QueryConnectionConsensusStateRequest{
ConnectionId: "",
ConnectionId: "",
RevisionNumber: 0,
RevisionHeight: 1,
}
Expand All @@ -349,7 +349,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() {
"connection not found",
func() {
req = &types.QueryConnectionConsensusStateRequest{
ConnectionId: "test-connection-id",
ConnectionId: "test-connection-id",
RevisionNumber: 0,
RevisionHeight: 1,
}
Expand All @@ -362,7 +362,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() {
_, _, connA, _, _, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.UNORDERED)

req = &types.QueryConnectionConsensusStateRequest{
ConnectionId: connA.ID,
ConnectionId: connA.ID,
RevisionNumber: 0,
RevisionHeight: uint64(suite.chainA.GetContext().BlockHeight()), // use current height
}
Expand All @@ -379,7 +379,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() {
expClientID = clientA

req = &types.QueryConnectionConsensusStateRequest{
ConnectionId: connA.ID,
ConnectionId: connA.ID,
RevisionNumber: clientState.GetLatestHeight().GetRevisionNumber(),
RevisionHeight: clientState.GetLatestHeight().GetRevisionHeight(),
}
Expand Down
3 changes: 2 additions & 1 deletion x/ibc/core/03-connection/types/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"math"
"testing"

"github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"
)

// tests ParseConnectionSequence and IsValidConnectionID
Expand Down
24 changes: 12 additions & 12 deletions x/ibc/core/04-channel/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
"invalid port ID",
func() {
req = &types.QueryChannelConsensusStateRequest{
PortId: "",
ChannelId: "test-channel-id",
PortId: "",
ChannelId: "test-channel-id",
RevisionNumber: 0,
RevisionHeight: 1,
}
Expand All @@ -449,8 +449,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
"invalid channel ID",
func() {
req = &types.QueryChannelConsensusStateRequest{
PortId: "test-port-id",
ChannelId: "",
PortId: "test-port-id",
ChannelId: "",
RevisionNumber: 0,
RevisionHeight: 1,
}
Expand All @@ -461,8 +461,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
"channel not found",
func() {
req = &types.QueryChannelConsensusStateRequest{
PortId: "test-port-id",
ChannelId: "test-channel-id",
PortId: "test-port-id",
ChannelId: "test-channel-id",
RevisionNumber: 0,
RevisionHeight: 1,
}
Expand All @@ -482,8 +482,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
suite.chainA.App.IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), channelA.PortID, channelA.ID, channel)

req = &types.QueryChannelConsensusStateRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
PortId: channelA.PortID,
ChannelId: channelA.ID,
RevisionNumber: 0,
RevisionHeight: 1,
}
Expand All @@ -495,8 +495,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)

req = &types.QueryChannelConsensusStateRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
PortId: channelA.PortID,
ChannelId: channelA.ID,
RevisionNumber: 0,
RevisionHeight: uint64(suite.chainA.GetContext().BlockHeight()), // use current height
}
Expand All @@ -516,8 +516,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
expClientID = clientA

req = &types.QueryChannelConsensusStateRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
PortId: channelA.PortID,
ChannelId: channelA.ID,
RevisionNumber: clientState.GetLatestHeight().GetRevisionNumber(),
RevisionHeight: clientState.GetLatestHeight().GetRevisionHeight(),
}
Expand Down
3 changes: 2 additions & 1 deletion x/ibc/core/04-channel/types/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package types_test
import (
"testing"

"github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"
)

// tests ParseChannelSequence and IsValidChannelID
Expand Down
3 changes: 2 additions & 1 deletion x/ibc/core/23-commitment/types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package types

import (
ics23 "github.com/confio/ics23/go"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
crypto "github.com/tendermint/tendermint/proto/tendermint/crypto"

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

// ConvertProofs converts crypto.ProofOps into MerkleProof
Expand Down
3 changes: 2 additions & 1 deletion x/ibc/core/23-commitment/types/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package types_test
import (
"fmt"

"github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
crypto "github.com/tendermint/tendermint/proto/tendermint/crypto"

"github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types"
)

func (suite *MerkleTestSuite) TestConvertProofs() {
Expand Down
5 changes: 3 additions & 2 deletions x/ibc/core/24-host/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"math"
"testing"

"github.com/stretchr/testify/require"

connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"
host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host"
"github.com/stretchr/testify/require"
)

func TestParseIdentifier(t *testing.T) {
Expand All @@ -23,7 +24,7 @@ func TestParseIdentifier(t *testing.T) {
// one above uint64 max
{"invalid uint64", "connection-18446744073709551616", "connection-", 0, false},
// uint64 == 20 characters
{"invalid large sequence", "connection-2345682193567182931243", "conenction-", 0, false},
{"invalid large sequence", "connection-2345682193567182931243", "connection-", 0, false},
{"capital prefix", "Connection-0", "connection-", 0, false},
{"double prefix", "connection-connection-0", "connection-", 0, false},
{"doesn't have prefix", "connection-0", "prefix", 0, false},
Expand Down
1 change: 1 addition & 0 deletions x/ibc/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/armon/go-metrics"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down
Loading

0 comments on commit 4a233b8

Please sign in to comment.