cli: check address flag is set for validator-related commands

This commit is contained in:
Anna Shaleva 2021-04-16 12:03:03 +03:00
parent ff2b051646
commit 90b054afd0
2 changed files with 16 additions and 0 deletions

View file

@ -23,6 +23,11 @@ func TestRegisterCandidate(t *testing.T) {
"GAS:"+validatorPriv.Address()+":10000")
e.checkTxPersisted(t)
// missing address
e.RunWithError(t, "neo-go", "wallet", "candidate", "register",
"--rpc-endpoint", "http://"+e.RPC.Addr,
"--wallet", validatorWallet)
e.In.WriteString("one\r")
e.Run(t, "neo-go", "wallet", "candidate", "register",
"--rpc-endpoint", "http://"+e.RPC.Addr,
@ -52,6 +57,11 @@ func TestRegisterCandidate(t *testing.T) {
require.Equal(t, b, vs[0].Votes)
})
// missing address
e.RunWithError(t, "neo-go", "wallet", "candidate", "unregister",
"--rpc-endpoint", "http://"+e.RPC.Addr,
"--wallet", validatorWallet)
e.In.WriteString("one\r")
e.Run(t, "neo-go", "wallet", "candidate", "unregister",
"--rpc-endpoint", "http://"+e.RPC.Addr,

View file

@ -87,6 +87,9 @@ func handleCandidate(ctx *cli.Context, method string, sysGas int64) error {
defer wall.Close()
addrFlag := ctx.Generic("address").(*flags.Address)
if !addrFlag.IsSet {
return cli.NewExitError("address was not provided", 1)
}
addr := addrFlag.Uint160()
acc, err := getDecryptedAccount(ctx, wall, addr)
if err != nil {
@ -139,6 +142,9 @@ func handleVote(ctx *cli.Context) error {
defer wall.Close()
addrFlag := ctx.Generic("address").(*flags.Address)
if !addrFlag.IsSet {
return cli.NewExitError("address was not provided", 1)
}
addr := addrFlag.Uint160()
acc, err := getDecryptedAccount(ctx, wall, addr)
if err != nil {