Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove unnecessary depinject usage #15529

Merged
merged 6 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions client/keys/add_ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
)

func Test_runAddCmdLedgerWithCustomCoinType(t *testing.T) {
Expand All @@ -44,7 +44,7 @@ func Test_runAddCmdLedgerWithCustomCoinType(t *testing.T) {
// Prepare a keybase
kbHome := t.TempDir()

cdc := clienttestutil.MakeTestCodec(t)
cdc := moduletestutil.MakeTestEncodingConfig().Codec
clientCtx := client.Context{}.WithKeyringDir(kbHome).WithCodec(cdc)
ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx)

Expand Down Expand Up @@ -96,7 +96,7 @@ func Test_runAddCmdLedger(t *testing.T) {

mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
kbHome := t.TempDir()
cdc := clienttestutil.MakeTestCodec(t)
cdc := moduletestutil.MakeTestEncodingConfig().Codec

clientCtx := client.Context{}.WithKeyringDir(kbHome).WithCodec(cdc)
ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx)
Expand Down Expand Up @@ -137,7 +137,7 @@ func Test_runAddCmdLedger(t *testing.T) {
}

func Test_runAddCmdLedgerDryRun(t *testing.T) {
cdc := clienttestutil.MakeTestCodec(t)
cdc := moduletestutil.MakeTestEncodingConfig().Codec
testData := []struct {
name string
args []string
Expand Down
9 changes: 4 additions & 5 deletions client/keys/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/go-bip39"
)

Expand All @@ -28,8 +28,7 @@ func Test_runAddCmdBasic(t *testing.T) {
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
kbHome := t.TempDir()

cdc := clienttestutil.MakeTestCodec(t)

cdc := moduletestutil.MakeTestEncodingConfig().Codec
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
require.NoError(t, err)

Expand Down Expand Up @@ -124,7 +123,7 @@ func Test_runAddCmdBasic(t *testing.T) {
func Test_runAddCmdDryRun(t *testing.T) {
pubkey1 := `{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AtObiFVE4s+9+RX5SP8TN9r2mxpoaT4eGj9CJfK7VRzN"}`
pubkey2 := `{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A/se1vkqgdQ7VJQCM4mxN+L+ciGhnnJ4XYsQCRBMrdRi"}`
cdc := clienttestutil.MakeTestCodec(t)
cdc := moduletestutil.MakeTestEncodingConfig().Codec

testData := []struct {
name string
Expand Down Expand Up @@ -235,7 +234,7 @@ func Test_runAddCmdDryRun(t *testing.T) {
func TestAddRecoverFileBackend(t *testing.T) {
cmd := AddKeyCommand()
cmd.Flags().AddFlagSet(Commands("home").PersistentFlags())
cdc := clienttestutil.MakeTestCodec(t)
cdc := moduletestutil.MakeTestEncodingConfig().Codec

mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
kbHome := t.TempDir()
Expand Down
4 changes: 2 additions & 2 deletions client/keys/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
)

func Test_runDeleteCmd(t *testing.T) {
Expand All @@ -34,7 +34,7 @@ func Test_runDeleteCmd(t *testing.T) {
fakeKeyName2 := "runDeleteCmd_Key2"

path := sdk.GetConfig().GetFullBIP44Path()
cdc := clienttestutil.MakeTestCodec(t)
cdc := moduletestutil.MakeTestEncodingConfig().Codec

cmd.SetArgs([]string{"blah", fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome)})
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
Expand Down
4 changes: 2 additions & 2 deletions client/keys/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import (
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/client"
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func Test_runExportCmd(t *testing.T) {
cdc := clienttestutil.MakeTestCodec(t)
cdc := moduletestutil.MakeTestEncodingConfig().Codec
testCases := []struct {
name string
keyringBackend string
Expand Down
4 changes: 2 additions & 2 deletions client/keys/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
)

func Test_runImportCmd(t *testing.T) {
cdc := clienttestutil.MakeTestCodec(t)
cdc := moduletestutil.MakeTestEncodingConfig().Codec
testCases := []struct {
name string
keyringBackend string
Expand Down
6 changes: 3 additions & 3 deletions client/keys/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
)

func cleanupKeys(t *testing.T, kb keyring.Keyring, keys ...string) func() {
Expand All @@ -37,7 +37,7 @@ func Test_runListCmd(t *testing.T) {
kbHome2 := t.TempDir()

mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
cdc := clienttestutil.MakeTestCodec(t)
cdc := moduletestutil.MakeTestEncodingConfig().Codec
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome2, mockIn, cdc)
assert.NilError(t, err)

Expand Down Expand Up @@ -85,7 +85,7 @@ func Test_runListCmd(t *testing.T) {
func Test_runListKeyTypeCmd(t *testing.T) {
cmd := ListKeyTypesCmd()

cdc := clienttestutil.MakeTestCodec(t)
cdc := moduletestutil.MakeTestEncodingConfig().Codec
kbHome := t.TempDir()
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)

Expand Down
4 changes: 2 additions & 2 deletions client/keys/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
)

type setter interface {
Expand All @@ -36,7 +36,7 @@ type MigrateTestSuite struct {

func (s *MigrateTestSuite) SetupSuite() {
s.dir = s.T().TempDir()
s.cdc = clienttestutil.MakeTestCodec(s.T())
s.cdc = moduletestutil.MakeTestEncodingConfig().Codec
s.appName = "cosmos"
s.priv = cryptotypes.PrivKey(secp256k1.GenPrivKey())
s.pub = s.priv.PubKey()
Expand Down
4 changes: 2 additions & 2 deletions client/keys/rename_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
)

func Test_runRenameCmd(t *testing.T) {
Expand All @@ -32,7 +32,7 @@ func Test_runRenameCmd(t *testing.T) {

path := sdk.GetConfig().GetFullBIP44Path()

cdc := clienttestutil.MakeTestCodec(t)
cdc := moduletestutil.MakeTestEncodingConfig().Codec
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
require.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions client/keys/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
Expand All @@ -18,6 +17,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
)

func Test_multiSigKey_Properties(t *testing.T) {
Expand Down Expand Up @@ -53,7 +53,7 @@ func Test_runShowCmd(t *testing.T) {
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)

kbHome := t.TempDir()
cdc := clienttestutil.MakeTestCodec(t)
cdc := moduletestutil.MakeTestEncodingConfig().Codec
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
require.NoError(t, err)

Expand Down
32 changes: 0 additions & 32 deletions client/testutil/util.go

This file was deleted.

12 changes: 3 additions & 9 deletions client/tx/aux_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,23 @@ import (

"github.com/stretchr/testify/require"

_ "cosmossdk.io/api/cosmos/bank/v1beta1"
"cosmossdk.io/depinject"
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
typestx "github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/bank"
)

func TestAuxTxBuilder(t *testing.T) {
var (
reg codectypes.InterfaceRegistry
cdc codec.Codec
)
err := depinject.Inject(clienttestutil.TestConfig, &reg, &cdc)
bankModule := bank.AppModuleBasic{}
cdc := moduletestutil.MakeTestEncodingConfig(bankModule).Codec
reg := codectypes.NewInterfaceRegistry()

require.NoError(t, err)
testdata.RegisterInterfaces(reg)
// required for test case: "GetAuxSignerData works for DIRECT_AUX"
bankModule.RegisterInterfaces(reg)
Expand Down
12 changes: 3 additions & 9 deletions client/tx/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import (
"strings"
"testing"

"cosmossdk.io/depinject"
sdkmath "cosmossdk.io/math"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"

"github.com/cosmos/cosmos-sdk/client"
clienttestutil "github.com/cosmos/cosmos-sdk/client/testutil"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand All @@ -21,6 +19,7 @@ import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
ante "github.com/cosmos/cosmos-sdk/x/auth/ante"
Expand All @@ -30,13 +29,8 @@ import (
)

func newTestTxConfig(t *testing.T) (client.TxConfig, codec.Codec) {
var (
pcdc codec.ProtoCodecMarshaler
cdc codec.Codec
)
err := depinject.Inject(clienttestutil.TestConfig, &pcdc, &cdc)
require.NoError(t, err)
return authtx.NewTxConfig(pcdc, authtx.DefaultSignModes), cdc
encodingConfig := moduletestutil.MakeTestEncodingConfig()
return authtx.NewTxConfig(codec.NewProtoCodec(encodingConfig.InterfaceRegistry), authtx.DefaultSignModes), encodingConfig.Codec
}

// mockContext is a mock client.Context to return abitrary simulation response, used to
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions tests/e2e/params/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/params/client/cli"
"github.com/cosmos/cosmos-sdk/x/params/keeper"
"github.com/cosmos/cosmos-sdk/x/params/testutil"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)

Expand Down Expand Up @@ -58,7 +57,7 @@ func (s *E2ETestSuite) SetupSuite() {
appBuilder *runtime.AppBuilder
paramsKeeper keeper.Keeper
)
if err := depinject.Inject(testutil.AppConfig, &appBuilder, &paramsKeeper); err != nil {
if err := depinject.Inject(AppConfig, &appBuilder, &paramsKeeper); err != nil {
panic(err)
}

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/bank/keeper/deterministic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/testutil/configurator"
"github.com/cosmos/cosmos-sdk/testutil/sims"
simstestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank/keeper"
Expand Down Expand Up @@ -61,7 +61,7 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {

var interfaceRegistry codectypes.InterfaceRegistry

app, err := sims.Setup(
app, err := simstestutil.Setup(
configurator.NewAppConfig(
configurator.AuthModule(),
configurator.TxModule(),
Expand Down
Loading