cli: add description to vote command on how to unvote

This commit is contained in:
Anna Shaleva 2021-05-28 15:15:37 +03:00
parent b858be63b4
commit 9340a70aa8
2 changed files with 19 additions and 3 deletions

View file

@ -41,7 +41,7 @@ func TestRegisterCandidate(t *testing.T) {
require.Equal(t, validatorPriv.PublicKey(), vs[0].Key) require.Equal(t, validatorPriv.PublicKey(), vs[0].Key)
require.Equal(t, big.NewInt(0), vs[0].Votes) 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.In.WriteString("one\r")
e.Run(t, "neo-go", "wallet", "candidate", "vote", e.Run(t, "neo-go", "wallet", "candidate", "vote",
"--rpc-endpoint", "http://"+e.RPC.Addr, "--rpc-endpoint", "http://"+e.RPC.Addr,
@ -55,6 +55,19 @@ func TestRegisterCandidate(t *testing.T) {
require.Equal(t, validatorPriv.PublicKey(), vs[0].Key) require.Equal(t, validatorPriv.PublicKey(), vs[0].Key)
b, _ := e.Chain.GetGoverningTokenBalance(validatorPriv.GetScriptHash()) b, _ := e.Chain.GetGoverningTokenBalance(validatorPriv.GetScriptHash())
require.Equal(t, b, vs[0].Votes) 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 // missing address

View file

@ -53,7 +53,10 @@ func newValidatorCommands() []cli.Command {
{ {
Name: "vote", Name: "vote",
Usage: "vote for a validator", Usage: "vote for a validator",
UsageText: "vote -w <path> -r <rpc> [-s <timeout>] [-g gas] -a <addr> -c <public key>", UsageText: "vote -w <path> -r <rpc> [-s <timeout>] [-g gas] -a <addr> [-c <public key>]",
Description: `Votes for a validator by calling "vote" method of a NEO native
contract. Do not provide candidate argument to perform unvoting.
`,
Action: handleVote, Action: handleVote,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
walletPathFlag, walletPathFlag,