mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 12:51:22 +00:00
rpc: unsafe_set_config
This commit is contained in:
@ -11,6 +11,10 @@ import (
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Test the HTTP client
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// status
|
||||
|
||||
func TestURIStatus(t *testing.T) {
|
||||
tmResult := new(ctypes.TMResult)
|
||||
@ -39,6 +43,63 @@ func testStatus(t *testing.T, statusI interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// unsafe_set_config
|
||||
|
||||
var stringVal = "my string"
|
||||
var intVal = 987654321
|
||||
var boolVal = true
|
||||
|
||||
// don't change these
|
||||
var testCasesUnsafeSetConfig = [][]string{
|
||||
[]string{"string", "key1", stringVal},
|
||||
[]string{"int", "key2", fmt.Sprintf("%v", intVal)},
|
||||
[]string{"bool", "key3", fmt.Sprintf("%v", boolVal)},
|
||||
}
|
||||
|
||||
func TestURIUnsafeSetConfig(t *testing.T) {
|
||||
for _, testCase := range testCasesUnsafeSetConfig {
|
||||
tmResult := new(ctypes.TMResult)
|
||||
_, err := clientURI.Call("unsafe_set_config", map[string]interface{}{
|
||||
"type": testCase[0],
|
||||
"key": testCase[1],
|
||||
"value": testCase[2],
|
||||
}, tmResult)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
testUnsafeSetConfig(t)
|
||||
}
|
||||
|
||||
func TestJSONUnsafeSetConfig(t *testing.T) {
|
||||
for _, testCase := range testCasesUnsafeSetConfig {
|
||||
tmResult := new(ctypes.TMResult)
|
||||
_, err := clientJSON.Call("unsafe_set_config", []interface{}{testCase[0], testCase[1], testCase[2]}, tmResult)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
testUnsafeSetConfig(t)
|
||||
}
|
||||
|
||||
func testUnsafeSetConfig(t *testing.T) {
|
||||
s := config.GetString("key1")
|
||||
if s != stringVal {
|
||||
t.Fatalf("got %v, expected %v", s, stringVal)
|
||||
}
|
||||
|
||||
i := config.GetInt("key2")
|
||||
if i != intVal {
|
||||
t.Fatalf("got %v, expected %v", i, intVal)
|
||||
}
|
||||
|
||||
b := config.GetBool("key3")
|
||||
if b != boolVal {
|
||||
t.Fatalf("got %v, expected %v", b, boolVal)
|
||||
}
|
||||
}
|
||||
|
||||
/*func TestURIBroadcastTx(t *testing.T) {
|
||||
testBroadcastTx(t, "HTTP")
|
||||
}*/
|
||||
|
Reference in New Issue
Block a user