mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-27 03:31:42 +00:00
Handle hex strings and quoted strings in HTTP params
Use 0x-prefixed hex strings in client server: Decode hex string args Encode all string args as 0x<hex> without trying to encode as JSON Added tests for special string arguments Fix server handling quoted string args Added string arg handling test cases to bash test script
This commit is contained in:
36
rpc_test.go
36
rpc_test.go
@ -164,3 +164,39 @@ func TestWS_UNIX(t *testing.T) {
|
||||
}
|
||||
testWS(t, cl)
|
||||
}
|
||||
|
||||
func TestHexStringArg(t *testing.T) {
|
||||
cl := rpcclient.NewClientURI(tcpAddr)
|
||||
// should NOT be handled as hex
|
||||
val := "0xabc"
|
||||
params := map[string]interface{}{
|
||||
"arg": val,
|
||||
}
|
||||
var result Result
|
||||
_, err := cl.Call("status", params, &result)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := result.(*ResultStatus).Value
|
||||
if got != val {
|
||||
t.Fatalf("Got: %v .... Expected: %v \n", got, val)
|
||||
}
|
||||
}
|
||||
|
||||
func TestQuotedStringArg(t *testing.T) {
|
||||
cl := rpcclient.NewClientURI(tcpAddr)
|
||||
// should NOT be unquoted
|
||||
val := "\"abc\""
|
||||
params := map[string]interface{}{
|
||||
"arg": val,
|
||||
}
|
||||
var result Result
|
||||
_, err := cl.Call("status", params, &result)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := result.(*ResultStatus).Value
|
||||
if got != val {
|
||||
t.Fatalf("Got: %v .... Expected: %v \n", got, val)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user