diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-17 04:21:51 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-17 04:21:51 +0800 |
commit | 0339a138625aca8647e5d51488e6d679202cdddb (patch) | |
tree | dcbde8199f25b7369ad78f31820f58db1b4024c6 | |
parent | 719effa7ecdef925a5a8fa61ac060e2ec5f0d612 (diff) | |
download | dexon-0339a138625aca8647e5d51488e6d679202cdddb.tar.gz dexon-0339a138625aca8647e5d51488e6d679202cdddb.tar.zst dexon-0339a138625aca8647e5d51488e6d679202cdddb.zip |
RPC empty args tests
-rw-r--r-- | rpc/args_test.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go index d6e4bee62..bdf05cad1 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", @@ -309,6 +329,33 @@ func TestFilterOptionsWords(t *testing.T) { } } +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) |