From 9340a70aa81c9668aa5c30e5282e456defb082de Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 28 May 2021 15:15:37 +0300 Subject: [PATCH] cli: add description to `vote` command on how to `unvote` --- cli/candidate_test.go | 15 ++++++++++++++- cli/wallet/validator.go | 7 +++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/cli/candidate_test.go b/cli/candidate_test.go index f247bf9d0..d0ca3e46a 100644 --- a/cli/candidate_test.go +++ b/cli/candidate_test.go @@ -41,7 +41,7 @@ func TestRegisterCandidate(t *testing.T) { require.Equal(t, validatorPriv.PublicKey(), vs[0].Key) require.Equal(t, big.NewInt(0), vs[0].Votes) - t.Run("Vote", func(t *testing.T) { + t.Run("VoteUnvote", func(t *testing.T) { e.In.WriteString("one\r") e.Run(t, "neo-go", "wallet", "candidate", "vote", "--rpc-endpoint", "http://"+e.RPC.Addr, @@ -55,6 +55,19 @@ func TestRegisterCandidate(t *testing.T) { require.Equal(t, validatorPriv.PublicKey(), vs[0].Key) b, _ := e.Chain.GetGoverningTokenBalance(validatorPriv.GetScriptHash()) require.Equal(t, b, vs[0].Votes) + + // unvote + e.In.WriteString("one\r") + e.Run(t, "neo-go", "wallet", "candidate", "vote", + "--rpc-endpoint", "http://"+e.RPC.Addr, + "--wallet", validatorWallet, + "--address", validatorPriv.Address()) + e.checkTxPersisted(t) + + vs, err = e.Chain.GetEnrollments() + require.Equal(t, 1, len(vs)) + require.Equal(t, validatorPriv.PublicKey(), vs[0].Key) + require.Equal(t, big.NewInt(0), vs[0].Votes) }) // missing address diff --git a/cli/wallet/validator.go b/cli/wallet/validator.go index 53b78f9db..1e2475400 100644 --- a/cli/wallet/validator.go +++ b/cli/wallet/validator.go @@ -53,8 +53,11 @@ func newValidatorCommands() []cli.Command { { Name: "vote", Usage: "vote for a validator", - UsageText: "vote -w -r [-s ] [-g gas] -a -c ", - Action: handleVote, + UsageText: "vote -w -r [-s ] [-g gas] -a [-c ]", + Description: `Votes for a validator by calling "vote" method of a NEO native + contract. Do not provide candidate argument to perform unvoting. +`, + Action: handleVote, Flags: append([]cli.Flag{ walletPathFlag, gasFlag,