aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args_test.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-18 04:40:05 +0800
committerobscuren <geffobscura@gmail.com>2015-03-18 04:40:05 +0800
commit142e81258cd7b77226d706c84f93da417aaaf426 (patch)
tree3b84c4139d100252512db487c33e2be57191e5d3 /rpc/args_test.go
parent86661de07746cd4e4ad8d016afee9fa8074aa141 (diff)
parent048d4ec5be5352dcb06f5123e3458b99aa151e6b (diff)
downloadgo-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.tar
go-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.tar.gz
go-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.tar.bz2
go-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.tar.lz
go-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.tar.xz
go-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.tar.zst
go-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.zip
Merge branch 'develop' into conversion
Diffstat (limited to 'rpc/args_test.go')
-rw-r--r--rpc/args_test.go120
1 files changed, 120 insertions, 0 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go
index 47d79cc32..61b9dad25 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -74,6 +74,16 @@ func TestGetBlockByHashArgs(t *testing.T) {
}
}
+func TestGetBlockByHashEmpty(t *testing.T) {
+ input := `[]`
+
+ args := new(GetBlockByHashArgs)
+ err := json.Unmarshal([]byte(input), &args)
+ if err == nil {
+ t.Error("Expected error but didn't get one")
+ }
+}
+
func TestGetBlockByNumberArgs(t *testing.T) {
input := `["0x1b4", false]`
expected := new(GetBlockByNumberArgs)
@@ -94,6 +104,16 @@ func TestGetBlockByNumberArgs(t *testing.T) {
}
}
+func TestGetBlockByNumberEmpty(t *testing.T) {
+ input := `[]`
+
+ args := new(GetBlockByNumberArgs)
+ err := json.Unmarshal([]byte(input), &args)
+ if err == nil {
+ t.Error("Expected error but didn't get one")
+ }
+}
+
func TestNewTxArgs(t *testing.T) {
input := `[{"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f072445675",
@@ -139,6 +159,16 @@ func TestNewTxArgs(t *testing.T) {
}
}
+func TestNewTxArgsEmpty(t *testing.T) {
+ input := `[]`
+
+ args := new(NewTxArgs)
+ err := json.Unmarshal([]byte(input), &args)
+ if err == nil {
+ t.Error("Expected error but didn't get one")
+ }
+}
+
func TestGetStorageArgs(t *testing.T) {
input := `["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "latest"]`
expected := new(GetStorageArgs)
@@ -163,6 +193,16 @@ func TestGetStorageArgs(t *testing.T) {
}
}
+func TestGetStorageEmptyArgs(t *testing.T) {
+ input := `[]`
+
+ args := new(GetStorageArgs)
+ err := json.Unmarshal([]byte(input), &args)
+ if err == nil {
+ t.Error("Expected error but didn't get one")
+ }
+}
+
func TestGetStorageAtArgs(t *testing.T) {
input := `["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "0x0", "0x2"]`
expected := new(GetStorageAtArgs)
@@ -192,6 +232,16 @@ func TestGetStorageAtArgs(t *testing.T) {
}
}
+func TestGetStorageAtEmptyArgs(t *testing.T) {
+ input := `[]`
+
+ args := new(GetStorageAtArgs)
+ err := json.Unmarshal([]byte(input), &args)
+ if err == nil {
+ t.Error("Expected error but didn't get one")
+ }
+}
+
func TestGetTxCountArgs(t *testing.T) {
input := `["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "latest"]`
expected := new(GetTxCountArgs)
@@ -216,6 +266,16 @@ func TestGetTxCountArgs(t *testing.T) {
}
}
+func TestGetTxCountEmptyArgs(t *testing.T) {
+ input := `[]`
+
+ args := new(GetTxCountArgs)
+ err := json.Unmarshal([]byte(input), &args)
+ if err == nil {
+ t.Error("Expected error but didn't get one")
+ }
+}
+
func TestGetDataArgs(t *testing.T) {
input := `["0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8", "latest"]`
expected := new(GetDataArgs)
@@ -240,6 +300,16 @@ func TestGetDataArgs(t *testing.T) {
}
}
+func TestGetDataEmptyArgs(t *testing.T) {
+ input := `[]`
+
+ args := new(GetDataArgs)
+ err := json.Unmarshal([]byte(input), &args)
+ if err == nil {
+ t.Error("Expected error but didn't get one")
+ }
+}
+
func TestFilterOptions(t *testing.T) {
input := `[{
"fromBlock": "0x1",
@@ -286,6 +356,56 @@ func TestFilterOptions(t *testing.T) {
// }
}
+func TestFilterOptionsWords(t *testing.T) {
+ input := `[{
+ "fromBlock": "latest",
+ "toBlock": "pending"
+ }]`
+ expected := new(FilterOptions)
+ expected.Earliest = 0
+ expected.Latest = -1
+
+ args := new(FilterOptions)
+ if err := json.Unmarshal([]byte(input), &args); err != nil {
+ t.Error(err)
+ }
+
+ if expected.Earliest != args.Earliest {
+ t.Errorf("Earliest shoud be %#v but is %#v", expected.Earliest, args.Earliest)
+ }
+
+ if expected.Latest != args.Latest {
+ t.Errorf("Latest shoud be %#v but is %#v", expected.Latest, args.Latest)
+ }
+}
+
+func TestFilterOptionsNums(t *testing.T) {
+ input := `[{
+ "fromBlock": 2,
+ "toBlock": 3
+ }]`
+
+ args := new(FilterOptions)
+ err := json.Unmarshal([]byte(input), &args)
+ switch err.(type) {
+ case *DecodeParamError:
+ break
+ default:
+ t.Errorf("Should have *DecodeParamError but instead have %T", err)
+ }
+
+}
+
+func TestFilterOptionsEmptyArgs(t *testing.T) {
+ input := `[]`
+
+ args := new(FilterOptions)
+ err := json.Unmarshal([]byte(input), &args)
+ if err == nil {
+ t.Error("Expected error but didn't get one")
+ }
+}
+
func TestDbArgs(t *testing.T) {
input := `["0x74657374","0x6b6579","0x6d79537472696e67"]`
expected := new(DbArgs)