Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 committed Jan 14, 2025
1 parent d444dd7 commit 1b9b8f7
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 406 deletions.
28 changes: 0 additions & 28 deletions core/testing/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,19 @@ toolchain go1.23.4
require (
cosmossdk.io/core v1.0.0
github.com/cometbft/cometbft/api v1.0.0
github.com/cosmos/cosmos-sdk v0.50.11
github.com/cosmos/gogoproto v1.7.0
github.com/tidwall/btree v1.7.0
go.uber.org/mock v0.5.0
google.golang.org/grpc v1.69.4
)

require (
cosmossdk.io/api v0.7.6 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/math v1.4.0 // indirect
cosmossdk.io/schema v1.0.0 // indirect
cosmossdk.io/x/tx v0.13.7 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/cometbft/cometbft v0.38.12 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
352 changes: 0 additions & 352 deletions core/testing/go.sum

Large diffs are not rendered by default.

21 changes: 5 additions & 16 deletions core/testing/queryclient/queryclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,29 @@ import (
gogogrpc "github.com/cosmos/gogoproto/grpc"
"google.golang.org/grpc"
"google.golang.org/grpc/encoding"

"github.com/cosmos/cosmos-sdk/client/grpc/reflection"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
)

var (
_ gogogrpc.ClientConn = &QueryHelper{}
_ gogogrpc.Server = &QueryHelper{}
)

// GRPCQueryHandler defines a function type which handles ABCI Query requests
// using gRPC
type GRPCQueryHandler = func(ctx context.Context, req *abci.QueryRequest) (*abci.QueryResponse, error)

// QueryHelper is a test utility for building a query client from a proto interface registry.
type QueryHelper struct {
cdc encoding.Codec
routes map[string]GRPCQueryHandler
}

func NewQueryHelper(interfaceRegistry codectypes.InterfaceRegistry) *QueryHelper {
// instantiate the codec
cdc := codec.NewProtoCodec(interfaceRegistry).GRPCCodec()
// Once we have an interface registry, we can register the interface
// registry reflection gRPC service.

func NewQueryHelper(cdc encoding.Codec) *QueryHelper {
qh := &QueryHelper{
cdc: cdc,
routes: map[string]GRPCQueryHandler{},
}

reflection.RegisterReflectionServiceServer(qh, reflection.NewReflectionServiceServer(interfaceRegistry))

return qh
}

Expand Down Expand Up @@ -70,10 +63,6 @@ func (q *QueryHelper) NewStream(context.Context, *grpc.StreamDesc, string, ...gr
panic("not implemented")
}

// GRPCQueryHandler defines a function type which handles ABCI Query requests
// using gRPC
type GRPCQueryHandler = func(ctx context.Context, req *abci.QueryRequest) (*abci.QueryResponse, error)

// Route returns the GRPCQueryHandler for a given query route path or nil
// if not found
func (q *QueryHelper) Route(path string) GRPCQueryHandler {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/v2/accounts/fixture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/require"

"cosmossdk.io/core/router"
"cosmossdk.io/core/testing/msgrouter"
"cosmossdk.io/core/transaction"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
Expand All @@ -25,7 +26,6 @@ import (
minttypes "cosmossdk.io/x/mint/types"
_ "cosmossdk.io/x/staking" // import as blank for app wirings

"cosmossdk.io/core/testing/msgrouter"
"github.com/cosmos/cosmos-sdk/codec"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/tests/integration/v2"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/v2/accounts/lockup/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/suite"

"cosmossdk.io/core/router"
"cosmossdk.io/core/testing/msgrouter"
"cosmossdk.io/core/transaction"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
Expand All @@ -28,7 +29,6 @@ import (
stakingkeeper "cosmossdk.io/x/staking/keeper"
stakingtypes "cosmossdk.io/x/staking/types"

"cosmossdk.io/core/testing/msgrouter"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/tests/integration/v2"
"github.com/cosmos/cosmos-sdk/testutil/configurator"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/v2/accounts/multisig/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/stretchr/testify/suite"

"cosmossdk.io/core/router"
"cosmossdk.io/core/testing/msgrouter"
"cosmossdk.io/core/transaction"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
Expand All @@ -26,7 +27,6 @@ import (
_ "cosmossdk.io/x/staking" // import as blank for app wiring
stakingkeeper "cosmossdk.io/x/staking/keeper"

"cosmossdk.io/core/testing/msgrouter"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/tests/integration/v2"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/v2/auth/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/require"

"cosmossdk.io/core/router"
"cosmossdk.io/core/testing/msgrouter"
"cosmossdk.io/core/transaction"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
Expand All @@ -22,7 +23,6 @@ import (
_ "cosmossdk.io/x/consensus" // import as blank for app wiring
_ "cosmossdk.io/x/staking" // import as blank for app wirings

"cosmossdk.io/core/testing/msgrouter"
"github.com/cosmos/cosmos-sdk/tests/integration/v2"
"github.com/cosmos/cosmos-sdk/testutil/configurator"
_ "github.com/cosmos/cosmos-sdk/x/auth" // import as blank for app wiring
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/v2/distribution/fixture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"cosmossdk.io/core/comet"
corecontext "cosmossdk.io/core/context"
"cosmossdk.io/core/router"
"cosmossdk.io/core/testing/msgrouter"
"cosmossdk.io/core/transaction"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
Expand All @@ -26,7 +27,6 @@ import (
_ "cosmossdk.io/x/staking" // import as blank for app wiring
stakingkeeper "cosmossdk.io/x/staking/keeper"

"cosmossdk.io/core/testing/msgrouter"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/tests/integration/v2"
"github.com/cosmos/cosmos-sdk/testutil/configurator"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/v2/gov/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"gotest.tools/v3/assert"

"cosmossdk.io/core/router"
"cosmossdk.io/core/testing/msgrouter"
"cosmossdk.io/core/transaction"
"cosmossdk.io/depinject"
sdklog "cosmossdk.io/log"
Expand All @@ -32,7 +33,6 @@ import (
stakingkeeper "cosmossdk.io/x/staking/keeper"
stakingtypes "cosmossdk.io/x/staking/types"

"cosmossdk.io/core/testing/msgrouter"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/v2/gov/keeper/fixture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/require"

"cosmossdk.io/core/router"
"cosmossdk.io/core/testing/msgrouter"
"cosmossdk.io/core/transaction"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
Expand All @@ -23,7 +24,6 @@ import (
_ "cosmossdk.io/x/staking"
stakingkeeper "cosmossdk.io/x/staking/keeper"

"cosmossdk.io/core/testing/msgrouter"
"github.com/cosmos/cosmos-sdk/tests/integration/v2"
"github.com/cosmos/cosmos-sdk/testutil/configurator"
_ "github.com/cosmos/cosmos-sdk/x/auth"
Expand Down
2 changes: 1 addition & 1 deletion x/accounts/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1"
"cosmossdk.io/core/address"
coretesting "cosmossdk.io/core/testing"
"cosmossdk.io/core/testing/msgrouter"
"cosmossdk.io/core/transaction"
"cosmossdk.io/math"
"cosmossdk.io/x/accounts/internal/implementation"
banktypes "cosmossdk.io/x/bank/types"
"cosmossdk.io/x/tx/signing"

"cosmossdk.io/core/testing/msgrouter"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
7 changes: 5 additions & 2 deletions x/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ import (
"testing"
"time"

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

"github.com/stretchr/testify/suite"
"go.uber.org/mock/gomock"

"cosmossdk.io/core/address"
coreevent "cosmossdk.io/core/event"
"cosmossdk.io/core/header"
coretesting "cosmossdk.io/core/testing"
"cosmossdk.io/core/testing/queryclient"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/log"
"cosmossdk.io/math"
Expand All @@ -25,7 +28,7 @@ import (
banktestutil "cosmossdk.io/x/bank/testutil"
banktypes "cosmossdk.io/x/bank/types"

"cosmossdk.io/core/testing/queryclient"
"github.com/cosmos/cosmos-sdk/codec"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -186,7 +189,7 @@ func (suite *KeeperTestSuite) SetupTest() {
DefaultSendEnabled: banktypes.DefaultDefaultSendEnabled,
}))

queryHelper := queryclient.NewQueryHelper(encCfg.InterfaceRegistry)
queryHelper := queryclient.NewQueryHelper(codec.NewProtoCodec(encCfg.InterfaceRegistry).GRPCCodec())
banktypes.RegisterQueryServer(queryHelper, suite.bankKeeper)
banktypes.RegisterInterfaces(encCfg.InterfaceRegistry)

Expand Down

0 comments on commit 1b9b8f7

Please sign in to comment.