aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args_test.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-26 17:52:32 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-26 17:52:32 +0800
commitbd1a54f076935d8d42c1f6df2c54fdd4e7f978ac (patch)
tree47158073bb63a5aade110467d462b1191036850d /rpc/args_test.go
parent966cfa4bddb0fbe355dadb83541325a3b5c132f8 (diff)
downloadgo-tangerine-bd1a54f076935d8d42c1f6df2c54fdd4e7f978ac.tar
go-tangerine-bd1a54f076935d8d42c1f6df2c54fdd4e7f978ac.tar.gz
go-tangerine-bd1a54f076935d8d42c1f6df2c54fdd4e7f978ac.tar.bz2
go-tangerine-bd1a54f076935d8d42c1f6df2c54fdd4e7f978ac.tar.lz
go-tangerine-bd1a54f076935d8d42c1f6df2c54fdd4e7f978ac.tar.xz
go-tangerine-bd1a54f076935d8d42c1f6df2c54fdd4e7f978ac.tar.zst
go-tangerine-bd1a54f076935d8d42c1f6df2c54fdd4e7f978ac.zip
GetStorageArgs
Diffstat (limited to 'rpc/args_test.go')
-rw-r--r--rpc/args_test.go58
1 files changed, 52 insertions, 6 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go
index 328eab0ec..20930a3d8 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -239,7 +239,7 @@ func TestNewTxArgsFromEmpty(t *testing.T) {
func TestGetStorageArgs(t *testing.T) {
input := `["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "latest"]`
expected := new(GetStorageArgs)
- expected.Address = "0x407d73d8a49eeb85d32cf465507dd71d507100c1"
+ expected.Address = common.HexToAddress("0x407d73d8a49eeb85d32cf465507dd71d507100c1")
expected.BlockNumber = -1
args := new(GetStorageArgs)
@@ -247,10 +247,6 @@ func TestGetStorageArgs(t *testing.T) {
t.Error(err)
}
- if err := args.requirements(); err != nil {
- t.Error(err)
- }
-
if expected.Address != args.Address {
t.Errorf("Address shoud be %#v but is %#v", expected.Address, args.Address)
}
@@ -260,13 +256,63 @@ func TestGetStorageArgs(t *testing.T) {
}
}
+func TestGetStorageInvalidArgs(t *testing.T) {
+ input := `{}`
+
+ args := new(GetStorageArgs)
+ 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 TestGetStorageInvalidBlockheight(t *testing.T) {
+ input := `["0x407d73d8a49eeb85d32cf465507dd71d507100c1", {}]`
+
+ args := new(GetStorageArgs)
+ 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 TestGetStorageEmptyArgs(t *testing.T) {
input := `[]`
args := new(GetStorageArgs)
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 TestGetStorageAddressInt(t *testing.T) {
+ input := `[32456785432456, "latest"]`
+
+ args := new(GetStorageArgs)
+ 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())
}
}