|
|
@ -67,8 +67,10 @@ func TestJSONBroadcastTxSync(t *testing.T) { |
|
|
|
} |
|
|
|
|
|
|
|
func testBroadcastTxSync(t *testing.T, client rpc.HTTPClient) { |
|
|
|
config.Set("block_size", 0) |
|
|
|
defer config.Set("block_size", -1) |
|
|
|
// config.Set("block_size", 0)
|
|
|
|
// defer config.Set("block_size", -1)
|
|
|
|
mem := node.MempoolReactor().Mempool |
|
|
|
initMemSize := mem.Size() |
|
|
|
tmResult := new(ctypes.TMResult) |
|
|
|
tx := randBytes(t) |
|
|
|
_, err := client.Call("broadcast_tx_sync", map[string]interface{}{"tx": tx}, tmResult) |
|
|
@ -76,8 +78,7 @@ func testBroadcastTxSync(t *testing.T, client rpc.HTTPClient) { |
|
|
|
|
|
|
|
res := (*tmResult).(*ctypes.ResultBroadcastTx) |
|
|
|
require.Equal(t, abci.CodeType_OK, res.Code) |
|
|
|
mem := node.MempoolReactor().Mempool |
|
|
|
require.Equal(t, 1, mem.Size()) |
|
|
|
require.Equal(t, initMemSize+1, mem.Size()) |
|
|
|
txs := mem.Reap(1) |
|
|
|
require.EqualValues(t, tx, txs[0]) |
|
|
|
mem.Flush() |
|
|
@ -358,51 +359,52 @@ func TestWSDoubleFire(t *testing.T) { |
|
|
|
}*/ |
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
//TODO needs to be refactored so we don't use a mutable config but rather update specific values we're interested in
|
|
|
|
// 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 := GetURIClient().Call("unsafe_set_config", map[string]interface{}{ |
|
|
|
"type": testCase[0], |
|
|
|
"key": testCase[1], |
|
|
|
"value": testCase[2], |
|
|
|
}, tmResult) |
|
|
|
require.Nil(t, err) |
|
|
|
} |
|
|
|
testUnsafeSetConfig(t) |
|
|
|
} |
|
|
|
|
|
|
|
func TestJSONUnsafeSetConfig(t *testing.T) { |
|
|
|
for _, testCase := range testCasesUnsafeSetConfig { |
|
|
|
tmResult := new(ctypes.TMResult) |
|
|
|
_, err := GetJSONClient().Call("unsafe_set_config", |
|
|
|
map[string]interface{}{"type": testCase[0], "key": testCase[1], "value": testCase[2]}, |
|
|
|
tmResult) |
|
|
|
require.Nil(t, err) |
|
|
|
} |
|
|
|
testUnsafeSetConfig(t) |
|
|
|
} |
|
|
|
|
|
|
|
func testUnsafeSetConfig(t *testing.T) { |
|
|
|
require := require.New(t) |
|
|
|
s := config.GetString("key1") |
|
|
|
require.Equal(stringVal, s) |
|
|
|
|
|
|
|
i := config.GetInt("key2") |
|
|
|
require.Equal(intVal, i) |
|
|
|
|
|
|
|
b := config.GetBool("key3") |
|
|
|
require.Equal(boolVal, b) |
|
|
|
} |
|
|
|
//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 := GetURIClient().Call("unsafe_set_config", map[string]interface{}{
|
|
|
|
// "type": testCase[0],
|
|
|
|
// "key": testCase[1],
|
|
|
|
// "value": testCase[2],
|
|
|
|
// }, tmResult)
|
|
|
|
// require.Nil(t, err)
|
|
|
|
// }
|
|
|
|
// testUnsafeSetConfig(t)
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//func TestJSONUnsafeSetConfig(t *testing.T) {
|
|
|
|
// for _, testCase := range testCasesUnsafeSetConfig {
|
|
|
|
// tmResult := new(ctypes.TMResult)
|
|
|
|
// _, err := GetJSONClient().Call("unsafe_set_config",
|
|
|
|
// map[string]interface{}{"type": testCase[0], "key": testCase[1], "value": testCase[2]},
|
|
|
|
// tmResult)
|
|
|
|
// require.Nil(t, err)
|
|
|
|
// }
|
|
|
|
// testUnsafeSetConfig(t)
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//func testUnsafeSetConfig(t *testing.T) {
|
|
|
|
// require := require.New(t)
|
|
|
|
// s := config.GetString("key1")
|
|
|
|
// require.Equal(stringVal, s)
|
|
|
|
//
|
|
|
|
// i := config.GetInt("key2")
|
|
|
|
// require.Equal(intVal, i)
|
|
|
|
//
|
|
|
|
// b := config.GetBool("key3")
|
|
|
|
// require.Equal(boolVal, b)
|
|
|
|
//}
|