diff --git a/rpc/args_test.go b/rpc/args_test.go index d6e4bee62c..bdf05cad14 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)