Skip to content

Commit

Permalink
fix test issues with key store support algo
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Dec 13, 2022
1 parent c9f0b70 commit ee1ee03
Show file tree
Hide file tree
Showing 11 changed files with 412 additions and 408 deletions.
35 changes: 18 additions & 17 deletions client/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,23 +264,24 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err
}
}

if !clientCtx.IsAux || flagSet.Changed(flags.FlagAux) {
isAux, _ := flagSet.GetBool(flags.FlagAux)
clientCtx = clientCtx.WithAux(isAux)
if isAux {
// If the user didn't explicitly set an --output flag, use JSON by
// default.
if clientCtx.OutputFormat == "" || !flagSet.Changed(cli.OutputFlag) {
clientCtx = clientCtx.WithOutputFormat("json")
}

// If the user didn't explicitly set a --sign-mode flag, use
// DIRECT_AUX by default.
if clientCtx.SignModeStr == "" || !flagSet.Changed(flags.FlagSignMode) {
clientCtx = clientCtx.WithSignModeStr(flags.SignModeDirectAux)
}
}
}
// Aux mode is disabled
// if !clientCtx.IsAux || flagSet.Changed(flags.FlagAux) {
// isAux, _ := flagSet.GetBool(flags.FlagAux)
// clientCtx = clientCtx.WithAux(isAux)
// if isAux {
// // If the user didn't explicitly set an --output flag, use JSON by
// // default.
// if clientCtx.OutputFormat == "" || !flagSet.Changed(cli.OutputFlag) {
// clientCtx = clientCtx.WithOutputFormat("json")
// }
//
// // If the user didn't explicitly set a --sign-mode flag, use
// // DIRECT_AUX by default.
// if clientCtx.SignModeStr == "" || !flagSet.Changed(flags.FlagSignMode) {
// clientCtx = clientCtx.WithSignModeStr(flags.SignModeDirectAux)
// }
// }
// }

return clientCtx, nil
}
Expand Down
6 changes: 3 additions & 3 deletions client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const (
FlagFeeGranter = "fee-granter"
FlagReverse = "reverse"
FlagTip = "tip"
FlagAux = "aux"
// FlagAux = "aux"

// Tendermint logging flags
FlagLogLevel = "log_level"
Expand Down Expand Up @@ -121,12 +121,12 @@ func AddTxFlagsToCmd(cmd *cobra.Command) {
cmd.Flags().Bool(FlagOffline, false, "Offline mode (does not allow any online functionality)")
cmd.Flags().BoolP(FlagSkipConfirmation, "y", false, "Skip tx broadcasting prompt confirmation")
cmd.Flags().String(FlagKeyringBackend, DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test|memory)")
cmd.Flags().String(FlagSignMode, "", "Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature")
cmd.Flags().String(FlagSignMode, "", "We disabled this flag in inscription")
cmd.Flags().Uint64(FlagTimeoutHeight, 0, "Set a block timeout height to prevent the tx from being committed past a certain height")
cmd.Flags().String(FlagFeePayer, "", "Fee payer pays fees for the transaction instead of deducting from the signer")
cmd.Flags().String(FlagFeeGranter, "", "Fee granter grants fees for the transaction")
cmd.Flags().String(FlagTip, "", "Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator")
cmd.Flags().Bool(FlagAux, false, "Generate aux signer data instead of sending a tx")
// cmd.Flags().Bool(FlagAux, false, "Generate aux signer data instead of sending a tx")

// --gas can accept integers and "auto"
cmd.Flags().String(FlagGas, "", fmt.Sprintf("gas limit to set per-transaction; set to %q to calculate sufficient gas automatically. Note: %q option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of %q. (default %d)",
Expand Down
4 changes: 2 additions & 2 deletions client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"sort"

"github.com/cosmos/go-bip39"
ethHd "github.com/evmos/ethermint/crypto/hd"
"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
Expand All @@ -19,6 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
ethHd "github.com/evmos/ethermint/crypto/hd"
)

const (
Expand Down Expand Up @@ -121,7 +121,7 @@ func runAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf

if dryRun, _ := cmd.Flags().GetBool(flags.FlagDryRun); dryRun {
// use in memory keybase
kb = keyring.NewInMemory(ctx.Codec)
kb = keyring.NewInMemory(ctx.Codec, ethHd.EthSecp256k1Option())
} else {
_, err = kb.Key(name)
if err == nil {
Expand Down
5 changes: 3 additions & 2 deletions client/keys/add_ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io"
"testing"

ethHd "github.com/evmos/ethermint/crypto/hd"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/cli"

Expand Down Expand Up @@ -64,7 +65,7 @@ func Test_runAddCmdLedgerWithCustomCoinType(t *testing.T) {
require.NoError(t, cmd.ExecuteContext(ctx))

// Now check that it has been stored properly
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc, ethHd.EthSecp256k1Option())
require.NoError(t, err)
require.NotNil(t, kb)
t.Cleanup(func() {
Expand Down Expand Up @@ -171,7 +172,7 @@ func Test_runAddCmdLedgerDryRun(t *testing.T) {

kbHome := t.TempDir()
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc, ethHd.EthSecp256k1Option())
require.NoError(t, err)

clientCtx := client.Context{}.
Expand Down
5 changes: 3 additions & 2 deletions client/keys/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/go-bip39"
ethHd "github.com/evmos/ethermint/crypto/hd"
)

func Test_runAddCmdBasic(t *testing.T) {
Expand All @@ -30,7 +31,7 @@ func Test_runAddCmdBasic(t *testing.T) {

cdc := simapp.MakeTestEncodingConfig().Codec

kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc, ethHd.EthSecp256k1Option())
require.NoError(t, err)

clientCtx := client.Context{}.WithKeyringDir(kbHome).WithInput(mockIn).WithCodec(cdc)
Expand Down Expand Up @@ -193,7 +194,7 @@ func Test_runAddCmdDryRun(t *testing.T) {
kbHome := t.TempDir()
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)

kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc, ethHd.EthSecp256k1Option())
require.NoError(t, err)

clientCtx := client.Context{}.
Expand Down
3 changes: 2 additions & 1 deletion client/keys/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
ethHd "github.com/evmos/ethermint/crypto/hd"
)

func Test_runDeleteCmd(t *testing.T) {
Expand All @@ -37,7 +38,7 @@ func Test_runDeleteCmd(t *testing.T) {
cdc := simapp.MakeTestEncodingConfig().Codec

cmd.SetArgs([]string{"blah", fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome)})
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc)
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc, ethHd.EthSecp256k1Option())
require.NoError(t, err)

_, err = kb.NewAccount(fakeKeyName1, testdata.TestMnemonic, "", path, hd.Secp256k1)
Expand Down
3 changes: 2 additions & 1 deletion client/keys/rename_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
ethHd "github.com/evmos/ethermint/crypto/hd"
)

func Test_runRenameCmd(t *testing.T) {
Expand All @@ -33,7 +34,7 @@ func Test_runRenameCmd(t *testing.T) {
path := sdk.GetConfig().GetFullBIP44Path()

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

// put fakeKeyName1 in keyring
Expand Down
3 changes: 2 additions & 1 deletion client/keys/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
ethHd "github.com/evmos/ethermint/crypto/hd"
)

func Test_multiSigKey_Properties(t *testing.T) {
Expand Down Expand Up @@ -54,7 +55,7 @@ func Test_runShowCmd(t *testing.T) {

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

clientCtx := client.Context{}.
Expand Down
2 changes: 1 addition & 1 deletion simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func initTestnetFiles(
memo := fmt.Sprintf("%s@%s:26656", nodeIDs[i], ip)
genFiles = append(genFiles, nodeConfig.GenesisFile())

kb, err := keyring.New(sdk.KeyringServiceName(), args.keyringBackend, nodeDir, inBuf, clientCtx.Codec)
kb, err := keyring.New(sdk.KeyringServiceName(), args.keyringBackend, nodeDir, inBuf, clientCtx.Codec, ethHd.EthSecp256k1Option())
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit ee1ee03

Please sign in to comment.