/
vote_case.go
73 lines (63 loc) · 1.45 KB
/
vote_case.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package run
import (
"github.com/empow-blockchain/go-empow/itest"
"github.com/urfave/cli"
)
// VoteCaseCommand is the command of vote test case
var VoteCaseCommand = cli.Command{
Name: "vote_case",
ShortName: "v_case",
Usage: "run VoteProducer test case",
Flags: VoteCaseFlags,
Action: VoteCaseAction,
}
// VoteCaseFlags is the flags of vote test case
var VoteCaseFlags = []cli.Flag{
cli.IntFlag{
Name: "number, n",
Value: 1000,
Usage: "number of transaction",
},
cli.IntFlag{
Name: "pnumber, pn",
Value: 1,
Usage: "number of producer",
},
cli.StringFlag{
Name: "account, a",
Value: "accounts.json",
Usage: "load accounts from `FILE`",
},
cli.StringFlag{
Name: "output, o",
Value: "accounts.json",
Usage: "output of account information",
},
}
// VoteCaseAction is the action of vote test case
var VoteCaseAction = func(c *cli.Context) error {
afile := c.String("account")
output := c.String("output")
tnum := c.Int("number")
punm := c.Int("pnumber")
keysfile := c.GlobalString("keys")
configfile := c.GlobalString("config")
it, err := itest.Load(keysfile, configfile)
if err != nil {
return err
}
accounts, err := itest.LoadAccounts(afile)
if err != nil {
return err
}
if err := it.VoteN(tnum, punm, accounts); err != nil {
return err
}
if err := it.CheckAccounts(accounts); err != nil {
return err
}
if err := itest.DumpAccounts(accounts, output); err != nil {
return err
}
return nil
}