aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args_test.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-26 21:17:32 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-26 21:17:32 +0800
commit3472823be94acc5b999dcb8741901b3e0c07f5d6 (patch)
treeb9dbde3af918ed179e0aff69a089c496bff0e105 /rpc/args_test.go
parentcb103c089a7c9238326e6a9bb336e375281ca622 (diff)
downloadgo-tangerine-3472823be94acc5b999dcb8741901b3e0c07f5d6.tar
go-tangerine-3472823be94acc5b999dcb8741901b3e0c07f5d6.tar.gz
go-tangerine-3472823be94acc5b999dcb8741901b3e0c07f5d6.tar.bz2
go-tangerine-3472823be94acc5b999dcb8741901b3e0c07f5d6.tar.lz
go-tangerine-3472823be94acc5b999dcb8741901b3e0c07f5d6.tar.xz
go-tangerine-3472823be94acc5b999dcb8741901b3e0c07f5d6.tar.zst
go-tangerine-3472823be94acc5b999dcb8741901b3e0c07f5d6.zip
HashIndexArgs
Diffstat (limited to 'rpc/args_test.go')
-rw-r--r--rpc/args_test.go62
1 files changed, 61 insertions, 1 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go
index 82bdcd257..ab74721b3 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -1139,7 +1139,7 @@ func TestBlockNumIndexArgsIndexInvalid(t *testing.T) {
func TestHashIndexArgs(t *testing.T) {
input := `["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x1"]`
expected := new(HashIndexArgs)
- expected.Hash = "0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b"
+ expected.Hash = common.HexToHash("0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b")
expected.Index = 1
args := new(HashIndexArgs)
@@ -1156,6 +1156,66 @@ func TestHashIndexArgs(t *testing.T) {
}
}
+func TestHashIndexArgsEmpty(t *testing.T) {
+ input := `[]`
+
+ args := new(HashIndexArgs)
+ err := json.Unmarshal([]byte(input), &args)
+ switch err.(type) {
+ case nil:
+ t.Error("Expected error but didn't get one")
+ case *InsufficientParamsError:
+ break
+ default:
+ t.Errorf("Expected *rpc.InsufficientParamsError but got %T with message `%s`", err, err.Error())
+ }
+}
+
+func TestHashIndexArgsInvalid(t *testing.T) {
+ input := `{}`
+
+ args := new(HashIndexArgs)
+ err := json.Unmarshal([]byte(input), &args)
+ switch err.(type) {
+ case nil:
+ t.Error("Expected error but didn't get one")
+ case *DecodeParamError:
+ break
+ default:
+ t.Errorf("Expected *rpc.DecodeParamError but got %T with message `%s`", err, err.Error())
+ }
+}
+
+func TestHashIndexArgsInvalidHash(t *testing.T) {
+ input := `[7, "0x1"]`
+
+ args := new(HashIndexArgs)
+ err := json.Unmarshal([]byte(input), &args)
+ switch err.(type) {
+ case nil:
+ t.Error("Expected error but didn't get one")
+ case *InvalidTypeError:
+ break
+ default:
+ t.Errorf("Expected *rpc.InvalidTypeError but got %T with message `%s`", err, err.Error())
+ }
+}
+
+func TestHashIndexArgsInvalidIndex(t *testing.T) {
+ input := `["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", false]`
+
+ args := new(HashIndexArgs)
+ err := json.Unmarshal([]byte(input), &args)
+ switch err.(type) {
+ case nil:
+ t.Error("Expected error but didn't get one")
+ case *InvalidTypeError:
+ break
+ default:
+ t.Errorf("Expected *rpc.InvalidTypeError but got %T with message `%s`", err, err.Error())
+ }
+}
+
func TestSubmitWorkArgs(t *testing.T) {
input := `["0x0000000000000001", "0x1234567890abcdef1234567890abcdef", "0xD1GE5700000000000000000000000000"]`
expected := new(SubmitWorkArgs)