aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api_test.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-23 23:35:49 +0800
committerobscuren <geffobscura@gmail.com>2015-03-23 23:35:49 +0800
commit253ecdc8bba1b522e80fdee69410854f19a5a972 (patch)
tree4cdad80599f03c741634d7e6f9a856b8fe070ee1 /rpc/api_test.go
parent9be7853e349f97917120fd925e2c5a462bd78846 (diff)
parent3f6e1b2fd3cbc6aeb1bbe658dd5b70945a57dffa (diff)
downloaddexon-253ecdc8bba1b522e80fdee69410854f19a5a972.tar
dexon-253ecdc8bba1b522e80fdee69410854f19a5a972.tar.gz
dexon-253ecdc8bba1b522e80fdee69410854f19a5a972.tar.bz2
dexon-253ecdc8bba1b522e80fdee69410854f19a5a972.tar.lz
dexon-253ecdc8bba1b522e80fdee69410854f19a5a972.tar.xz
dexon-253ecdc8bba1b522e80fdee69410854f19a5a972.tar.zst
dexon-253ecdc8bba1b522e80fdee69410854f19a5a972.zip
Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
Diffstat (limited to 'rpc/api_test.go')
-rw-r--r--rpc/api_test.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/rpc/api_test.go b/rpc/api_test.go
index 727ade007..a00c2f3f1 100644
--- a/rpc/api_test.go
+++ b/rpc/api_test.go
@@ -5,6 +5,8 @@ import (
// "sync"
"testing"
// "time"
+
+ "github.com/ethereum/go-ethereum/xeth"
)
func TestWeb3Sha3(t *testing.T) {
@@ -24,6 +26,50 @@ func TestWeb3Sha3(t *testing.T) {
}
}
+func TestDbStr(t *testing.T) {
+ jsonput := `{"jsonrpc":"2.0","method":"db_putString","params":["testDB","myKey","myString"],"id":64}`
+ jsonget := `{"jsonrpc":"2.0","method":"db_getString","params":["testDB","myKey"],"id":64}`
+ expected := "myString"
+
+ xeth := &xeth.XEth{}
+ api := NewEthereumApi(xeth, "")
+ defer api.db.Close()
+ var response interface{}
+
+ var req RpcRequest
+ json.Unmarshal([]byte(jsonput), &req)
+ _ = api.GetRequestReply(&req, &response)
+
+ json.Unmarshal([]byte(jsonget), &req)
+ _ = api.GetRequestReply(&req, &response)
+
+ if response.(string) != expected {
+ t.Errorf("Expected %s got %s", expected, response)
+ }
+}
+
+func TestDbHexStr(t *testing.T) {
+ jsonput := `{"jsonrpc":"2.0","method":"db_putHex","params":["testDB","beefKey","0xbeef"],"id":64}`
+ jsonget := `{"jsonrpc":"2.0","method":"db_getHex","params":["testDB","beefKey"],"id":64}`
+ expected := "0xbeef"
+
+ xeth := &xeth.XEth{}
+ api := NewEthereumApi(xeth, "")
+ defer api.db.Close()
+ var response interface{}
+
+ var req RpcRequest
+ json.Unmarshal([]byte(jsonput), &req)
+ _ = api.GetRequestReply(&req, &response)
+
+ json.Unmarshal([]byte(jsonget), &req)
+ _ = api.GetRequestReply(&req, &response)
+
+ if response.(string) != expected {
+ t.Errorf("Expected %s got %s", expected, response)
+ }
+}
+
// func TestFilterClose(t *testing.T) {
// t.Skip()
// api := &EthereumApi{