simplify json handling in LCD tests

This commit is contained in:
Alessio Treglia 2018-08-24 07:54:25 +01:00
parent 2dea46779c
commit fb5fe9914d
No known key found for this signature in database
GPG Key ID: E8A48AE5311D765A
1 changed files with 16 additions and 21 deletions

View File

@ -738,27 +738,22 @@ func doSendWithGas(t *testing.T, port, seed, name, password string, addr sdk.Acc
panic(err) panic(err)
} }
jsonStr := func() []byte { gasStr := ""
if gas > 0 { if gas > 0 {
return []byte(fmt.Sprintf(`{ gasStr = fmt.Sprintf(`
"name":"%s", "gas":"%v",
"password":"%s", `, gas)
"account_number":"%d", }
"sequence":"%d", jsonStr := []byte(fmt.Sprintf(`{
"amount":[%s], %v
"chain_id":"%s", "name":"%s",
"gas":"%v" "password":"%s",
}`, name, password, accnum, sequence, coinbz, chainID, gas)) "account_number":"%d",
} "sequence":"%d",
return []byte(fmt.Sprintf(`{ "amount":[%s],
"name":"%s", "chain_id":"%s"
"password":"%s", }`, gasStr, name, password, accnum, sequence, coinbz, chainID))
"account_number":"%d",
"sequence":"%d",
"amount":[%s],
"chain_id":"%s"
}`, name, password, accnum, sequence, coinbz, chainID))
}()
res, body = Request(t, port, "POST", fmt.Sprintf("/accounts/%s/send", receiveAddr), jsonStr) res, body = Request(t, port, "POST", fmt.Sprintf("/accounts/%s/send", receiveAddr), jsonStr)
return return
} }