tools/tm-bench: bounds check for txSize and improving test cases (#2410)

Fixes #2409
This commit is contained in:
zhangzheng 2018-09-17 17:08:47 +08:00 committed by Anton Kaliaev
parent e3e3c13741
commit c6c0b52d0c
2 changed files with 10 additions and 2 deletions

View File

@ -25,7 +25,7 @@ func main() {
flagSet.IntVar(&connections, "c", 1, "Connections to keep open per endpoint")
flagSet.IntVar(&durationInt, "T", 10, "Exit after the specified amount of time in seconds")
flagSet.IntVar(&txsRate, "r", 1000, "Txs per second to send in a connection")
flagSet.IntVar(&txSize, "s", 250, "The size of a transaction in bytes.")
flagSet.IntVar(&txSize, "s", 250, "The size of a transaction in bytes, must be greater than or equal to 40.")
flagSet.StringVar(&outputFormat, "output-format", "plain", "Output format: plain or json")
flagSet.StringVar(&broadcastTxMethod, "broadcast-tx-method", "async", "Broadcast method: async (no guarantees; fastest), sync (ensures tx is checked) or commit (ensures tx is checked and committed; slowest)")
flagSet.BoolVar(&verbose, "v", false, "Verbose output")
@ -68,6 +68,14 @@ Examples:
fmt.Printf("Running %ds test @ %s\n", durationInt, flagSet.Arg(0))
}
if txSize < 40 {
fmt.Fprintln(
os.Stderr,
"The size of a transaction must be greater than or equal to 40.",
)
os.Exit(1)
}
if broadcastTxMethod != "async" &&
broadcastTxMethod != "sync" &&
broadcastTxMethod != "commit" {

View File

@ -22,7 +22,7 @@ func TestGenerateTxUpdateTxConsistentency(t *testing.T) {
hostname string
numTxsToTest int
}{
{0, 0, 50, "localhost:26657", 1000},
{0, 0, 40, "localhost:26657", 1000},
{70, 300, 10000, "localhost:26657", 1000},
{0, 50, 100000, "localhost:26657", 1000},
}