aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args_test.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-26 19:47:00 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-26 19:47:00 +0800
commit4523a00b91dbe98c6cb03acef362c5592973bcd3 (patch)
tree207aa9b3827cbf243d8f739e71a16c53ccbfe048 /rpc/args_test.go
parent9c4504dc41bbedb590db20519030224df66ce4b1 (diff)
downloaddexon-4523a00b91dbe98c6cb03acef362c5592973bcd3.tar
dexon-4523a00b91dbe98c6cb03acef362c5592973bcd3.tar.gz
dexon-4523a00b91dbe98c6cb03acef362c5592973bcd3.tar.bz2
dexon-4523a00b91dbe98c6cb03acef362c5592973bcd3.tar.lz
dexon-4523a00b91dbe98c6cb03acef362c5592973bcd3.tar.xz
dexon-4523a00b91dbe98c6cb03acef362c5592973bcd3.tar.zst
dexon-4523a00b91dbe98c6cb03acef362c5592973bcd3.zip
GetTxCountArgs
Diffstat (limited to 'rpc/args_test.go')
-rw-r--r--rpc/args_test.go62
1 files changed, 54 insertions, 8 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go
index dea34b956..e13549d00 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -559,20 +559,16 @@ func TestGetStorageAtArgsValueNotString(t *testing.T) {
}
func TestGetTxCountArgs(t *testing.T) {
- input := `["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "latest"]`
+ input := `["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "pending"]`
expected := new(GetTxCountArgs)
- expected.Address = "0x407d73d8a49eeb85d32cf465507dd71d507100c1"
- expected.BlockNumber = -1
+ expected.Address = common.HexToAddress("0x407d73d8a49eeb85d32cf465507dd71d507100c1")
+ expected.BlockNumber = -2
args := new(GetTxCountArgs)
if err := json.Unmarshal([]byte(input), &args); err != nil {
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)
}
@@ -587,8 +583,58 @@ func TestGetTxCountEmptyArgs(t *testing.T) {
args := new(GetTxCountArgs)
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 TestGetTxCountEmptyArgsInvalid(t *testing.T) {
+ input := `false`
+
+ args := new(GetTxCountArgs)
+ 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 TestGetTxCountAddressNotString(t *testing.T) {
+ input := `[false, "pending"]`
+
+ args := new(GetTxCountArgs)
+ 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 TestGetTxCountBlockheightInvalid(t *testing.T) {
+ input := `["0x407d73d8a49eeb85d32cf465507dd71d507100c1", {}]`
+
+ args := new(GetTxCountArgs)
+ 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())
}
}