Rename GRPCRouter (#8079)

* 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>
This commit is contained in:
Anil Kumar Kammari 2020-12-04 20:36:50 +05:30 committed by GitHub
parent 7ec3bcd23a
commit 4a233b8dcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 76 additions and 53 deletions

View File

@ -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)

View File

@ -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
@ -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),
@ -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() {

View File

@ -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")

View File

@ -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 {

View File

@ -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 {

View File

@ -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"
)
// ----------------------------------------------------------------------------

View File

@ -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 (

View File

@ -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"
)

View File

@ -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"

View File

@ -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,

View File

@ -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 (

View File

@ -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"

View File

@ -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
@ -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,
@ -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,
)
@ -235,7 +235,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() {
suite.Require().NoError(err)
req = &types.QueryConsensusStateRequest{
ClientId: testClientID,
ClientId: testClientID,
RevisionNumber: 0,
RevisionHeight: height,
}

View File

@ -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

View File

@ -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) {

View File

@ -338,7 +338,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() {
"invalid connection ID",
func() {
req = &types.QueryConnectionConsensusStateRequest{
ConnectionId: "",
ConnectionId: "",
RevisionNumber: 0,
RevisionHeight: 1,
}
@ -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,
}
@ -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
}
@ -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(),
}

View File

@ -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

View File

@ -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,
}
@ -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,
}
@ -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,
}
@ -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,
}
@ -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
}
@ -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(),
}

View File

@ -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

View File

@ -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

View File

@ -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() {

View File

@ -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) {
@ -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},

View File

@ -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"

View File

@ -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"
)

View File

@ -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"
)

View File

@ -11,6 +11,8 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/golang/protobuf/proto"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
@ -23,7 +25,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/golang/protobuf/proto"
)
func bootstrapHandlerGenesisTest(t *testing.T, power int64, numAddrs int, accAmount sdk.Int) (*simapp.SimApp, sdk.Context, []sdk.AccAddress, []sdk.ValAddress) {

View File

@ -5,13 +5,14 @@ import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
)
func (suite *KeeperTestSuite) TestGRPCQueryValidators() {

View File

@ -3,12 +3,13 @@ package v036_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
v034staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v034"
v036staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v036"
"github.com/stretchr/testify/require"
)
func TestMigrate(t *testing.T) {

View File

@ -5,9 +5,10 @@ import (
"sort"
"testing"
"github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
var header = tmproto.Header{

View File

@ -3,8 +3,9 @@ package types_test
import (
"testing"
"github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
func TestParamsEqual(t *testing.T) {

View File

@ -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"
)