aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args_test.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-26 18:06:45 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-26 18:06:45 +0800
commit93af30a6f6308fe4e59b3a96f65ef535f1855865 (patch)
treea23a52d33f5aeeb79e07d60b7bd041b58438846f /rpc/args_test.go
parentbd1a54f076935d8d42c1f6df2c54fdd4e7f978ac (diff)
downloaddexon-93af30a6f6308fe4e59b3a96f65ef535f1855865.tar
dexon-93af30a6f6308fe4e59b3a96f65ef535f1855865.tar.gz
dexon-93af30a6f6308fe4e59b3a96f65ef535f1855865.tar.bz2
dexon-93af30a6f6308fe4e59b3a96f65ef535f1855865.tar.lz
dexon-93af30a6f6308fe4e59b3a96f65ef535f1855865.tar.xz
dexon-93af30a6f6308fe4e59b3a96f65ef535f1855865.tar.zst
dexon-93af30a6f6308fe4e59b3a96f65ef535f1855865.zip
improved GetBlockByHashArgs tests
Diffstat (limited to 'rpc/args_test.go')
-rw-r--r--rpc/args_test.go39
1 files changed, 37 insertions, 2 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go
index 20930a3d8..b6d592a09 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -100,13 +100,48 @@ func TestGetBlockByHashArgs(t *testing.T) {
}
}
-func TestGetBlockByHashEmpty(t *testing.T) {
+func TestGetBlockByHashArgsEmpty(t *testing.T) {
input := `[]`
args := new(GetBlockByHashArgs)
err := json.Unmarshal([]byte(input), &args)
- if err == nil {
+ 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 TestGetBlockByHashArgsInvalid(t *testing.T) {
+ input := `{}`
+
+ args := new(GetBlockByHashArgs)
+ 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 TestGetBlockByHashArgsHashInt(t *testing.T) {
+ input := `[8]`
+
+ args := new(GetBlockByHashArgs)
+ 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())
}
}