Skip to content

Commit

Permalink
s/--print-sigs/--validate-signatures/
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessio Treglia committed Oct 23, 2018
1 parent d0a0fdb commit ab36fba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
12 changes: 7 additions & 5 deletions cmd/gaia/cli_test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
flags := fmt.Sprintf("--home=%s --node=%v --chain-id=%v", gaiacliHome, servAddr, chainID)

// start gaiad server
proc := tests.GoExecuteTWithStdout(t, fmt.Sprintf("gaiad start --home=%s --rpc.laddr=%v", gaiadHome, servAddr))
proc := tests.GoExecuteTWithStdout(t, fmt.Sprintf(
"gaiad start --home=%s --rpc.laddr=%v", gaiadHome, servAddr))

defer proc.Stop(false)
tests.WaitForTMStart(port)
Expand Down Expand Up @@ -484,9 +485,9 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
unsignedTxFile := writeToNewTempFile(t, stdout)
defer os.Remove(unsignedTxFile.Name())

// Test sign --print-sigs
// Test sign --validate-signatures
success, stdout, _ = executeWriteRetStdStreams(t, fmt.Sprintf(
"gaiacli tx sign %v --print-sigs %v", flags, unsignedTxFile.Name()))
"gaiacli tx sign %v --validate-signatures %v", flags, unsignedTxFile.Name()))
require.False(t, success)
require.Equal(t, fmt.Sprintf("Signers:\n 0: %v\n\nSignatures:\n\n", fooAddr.String()), stdout)

Expand All @@ -505,7 +506,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {

// Test sign --print-signatures
success, stdout, _ = executeWriteRetStdStreams(t, fmt.Sprintf(
"gaiacli tx sign %v --print-sigs %v", flags, signedTxFile.Name()))
"gaiacli tx sign %v --validate-signatures %v", flags, signedTxFile.Name()))
require.True(t, success)
require.Equal(t, fmt.Sprintf("Signers:\n 0: %v\n\nSignatures:\n 0: %v\t[OK]\n\n", fooAddr.String(),
fooAddr.String()), stdout)
Expand All @@ -514,7 +515,8 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
fooAcc := executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", fooAddr, flags))
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf("steak").Int64())

success, stdout, _ = executeWriteRetStdStreams(t, fmt.Sprintf("gaiacli tx broadcast %v --json %v", flags, signedTxFile.Name()))
success, stdout, _ = executeWriteRetStdStreams(t, fmt.Sprintf(
"gaiacli tx broadcast %v --json %v", flags, signedTxFile.Name()))
require.True(t, success)
var result struct {
Response abci.ResponseDeliverTx
Expand Down
14 changes: 8 additions & 6 deletions x/auth/client/cli/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (

const (
flagAppend = "append"
flagPrintSigs = "print-sigs"
flagPrintSigs = "validate-signatures"
flagOffline = "offline"
flagRawSignature = "raw-signature"
flagRawSignature = "sig-only"
)

// GetSignCommand returns the sign command
Expand All @@ -31,7 +31,7 @@ func GetSignCommand(codec *amino.Codec, decoder auth.AccountDecoder) *cobra.Comm
Long: `Sign transactions created with the --generate-only flag.
Read a transaction from <file>, sign it, and print its JSON encoding.
If the flag --raw-signature flag is on, it outputs a JSON representation
If the flag --sig-only flag is on, it outputs a JSON representation
of the generated signature only.
The --offline flag makes sure that the client will not reach out to the local cache.
Expand All @@ -41,9 +41,11 @@ recommended to set such parameters manually.`,
Args: cobra.ExactArgs(1),
}
cmd.Flags().String(client.FlagName, "", "Name of private key with which to sign")
cmd.Flags().Bool(flagAppend, true, "Append the signature to the existing ones. If disabled, old signatures would be overwritten")
cmd.Flags().Bool(flagAppend, true,
"Append the signature to the existing ones. If disabled, old signatures would be overwritten")
cmd.Flags().Bool(flagRawSignature, false, "Print only the generated signature, then exit.")
cmd.Flags().Bool(flagPrintSigs, false, "Print the addresses that must sign the transaction and those who have already signed it, then exit")
cmd.Flags().Bool(flagPrintSigs, false, "Print the addresses that must sign the transaction, "+
"those who have already signed it, and make sure that signatures are in the correct order.")
cmd.Flags().Bool(flagOffline, false, "Offline mode. Do not query local cache.")
return cmd
}
Expand All @@ -69,7 +71,7 @@ func makeSignCmd(cdc *amino.Codec, decoder auth.AccountDecoder) func(cmd *cobra.
cliCtx := context.NewCLIContext().WithCodec(cdc).WithAccountDecoder(decoder)
txBldr := authtxb.NewTxBuilderFromCLI()

// if --print-signature-only is on, then override --append
// if --sig-only is on, then override --append
generateSignatureOnly := viper.GetBool(flagRawSignature)
append := viper.GetBool(flagAppend) && !generateSignatureOnly
newTx, err := utils.SignStdTx(txBldr, cliCtx, name, stdTx, append, viper.GetBool(flagOffline))
Expand Down

0 comments on commit ab36fba

Please sign in to comment.