Skip to content

Commit

Permalink
refactor(testutil)!: remove cmdtest (backport #22826) (#22828)
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Robert <[email protected]>
  • Loading branch information
mergify[bot] and julienrbrt authored Dec 11, 2024
1 parent d7e7af4 commit 95e9406
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 585 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (testutil/integration) [#22616](https://github.com/cosmos/cosmos-sdk/pull/22616) Remove double context in integration tests v1.
* Use `integrationApp.Context()` instead of creating a context prior.
* (version) [#22807](https://github.com/cosmos/cosmos-sdk/pull/22807) Return server/v2 information in the `version` functions and commands.
* [#22826](https://github.com/cosmos/cosmos-sdk/pull/22826) Simplify testing frameworks by removing `testutil/cmdtest`.

### Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func printCreate(ctx client.Context, cmd *cobra.Command, k *keyring.Record, show
return fmt.Errorf("failed to print mnemonic: %w", err)
}
} else {
if err = printDiscreetly(ctx, cmd.ErrOrStderr(), "**Important** write this mnemonic phrase in a safe place.\nIt is the only way to recover your account if you ever forget your password.", mnemonic); err != nil {
if err = printDiscreetly(cmd.ErrOrStderr(), "**Important** write this mnemonic phrase in a safe place.\nIt is the only way to recover your account if you ever forget your password.", mnemonic); err != nil {
return fmt.Errorf("failed to print mnemonic: %w", err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/keys/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func exportUnsafeUnarmored(ctx client.Context, cmd *cobra.Command, uid string, b
cmd.Println(hexPrivKey)
return nil
}
if err = printDiscreetly(ctx, cmd.ErrOrStderr(), "**Important** Do not share this private key.", hexPrivKey); err != nil {
if err = printDiscreetly(cmd.ErrOrStderr(), "**Important** Do not share this private key.", hexPrivKey); err != nil {
return fmt.Errorf("failed to print private key: %w", err)
}
cmd.Println("Export private key successfully")
Expand Down
3 changes: 1 addition & 2 deletions client/keys/mnemonic.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/cosmos/go-bip39"
"github.com/spf13/cobra"

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

Expand Down Expand Up @@ -69,7 +68,7 @@ func MnemonicKeyCommand() *cobra.Command {
}
indiscreet, _ := cmd.Flags().GetBool(flagIndiscreet)
if !indiscreet {
return printDiscreetly(client.GetClientContextFromCmd(cmd), cmd.ErrOrStderr(), "**Important** write this mnemonic phrase in a safe place. Do not share it to anyone.", mnemonic)
return printDiscreetly(cmd.ErrOrStderr(), "**Important** write this mnemonic phrase in a safe place. Do not share it to anyone.", mnemonic)
}
cmd.Println(mnemonic)
return nil
Expand Down
4 changes: 1 addition & 3 deletions client/keys/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ func runShowCmd(cmd *cobra.Command, args []string) (err error) {
qrterminal.GenerateHalfBlock(out, qrterminal.H, cmd.OutOrStdout())
}

if _, err := fmt.Fprintln(cmd.OutOrStdout(), out); err != nil {
return err
}
cmd.Println(out)
default:
if err := printKeyringRecord(cmd.OutOrStdout(), ko, outputFormat); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion client/keys/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func printTextRecords(w io.Writer, kos []KeyOutput) error {
}

// printDiscreetly Print a secret string to an alternate screen, so the string isn't printed to the terminal.
func printDiscreetly(clientCtx client.Context, w io.Writer, promptMsg, secretMsg string) error {
func printDiscreetly(w io.Writer, promptMsg, secretMsg string) error {
output := termenv.NewOutput(w)
output.AltScreen()
defer output.ExitAltScreen()
Expand Down
2 changes: 1 addition & 1 deletion tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ require (
github.com/google/go-cmp v0.6.0
github.com/google/gofuzz v1.2.0
github.com/jhump/protoreflect v1.17.0
github.com/rs/zerolog v1.33.0
github.com/spf13/viper v1.19.0
gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b
)
Expand Down Expand Up @@ -196,6 +195,7 @@ require (
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/rs/cors v1.11.1 // indirect
github.com/rs/zerolog v1.33.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sasha-s/go-deadlock v0.3.5 // indirect
Expand Down
Loading

0 comments on commit 95e9406

Please sign in to comment.