aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-06-19 22:44:39 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-06-19 22:44:39 +0800
commit0fa2750fc92caf3341e4fca3ba6fbc5755e57835 (patch)
treefc5498d186394d460365c2cecf51e6eccaf428f4
parentd5871fc20022b6d50140cc2b266f98122c6aa3bd (diff)
parent5afebc2a4b490bef9618c3f55a8c52e25ab716ef (diff)
downloaddexon-0fa2750fc92caf3341e4fca3ba6fbc5755e57835.tar
dexon-0fa2750fc92caf3341e4fca3ba6fbc5755e57835.tar.gz
dexon-0fa2750fc92caf3341e4fca3ba6fbc5755e57835.tar.bz2
dexon-0fa2750fc92caf3341e4fca3ba6fbc5755e57835.tar.lz
dexon-0fa2750fc92caf3341e4fca3ba6fbc5755e57835.tar.xz
dexon-0fa2750fc92caf3341e4fca3ba6fbc5755e57835.tar.zst
dexon-0fa2750fc92caf3341e4fca3ba6fbc5755e57835.zip
Merge pull request #1290 from tgerring/dataargs
unit test coverage for NewDataArgs
-rw-r--r--rpc/args_test.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go
index 81a2972cd..fd20dbab8 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -2577,3 +2577,57 @@ func TestSigArgsEmpty(t *testing.T) {
t.Error(str)
}
}
+
+func TestDataArgs(t *testing.T) {
+ input := `["0x0123"]`
+ expected := new(NewDataArgs)
+ expected.Data = "0x0123"
+
+ args := new(NewDataArgs)
+ if err := json.Unmarshal([]byte(input), &args); err != nil {
+ t.Error(err)
+ }
+
+ if expected.Data != args.Data {
+ t.Errorf("Data should be %v but is %v", expected.Data, args.Data)
+ }
+}
+
+func TestDataArgsEmptyData(t *testing.T) {
+ input := `[""]`
+
+ args := new(NewDataArgs)
+ str := ExpectValidationError(json.Unmarshal([]byte(input), args))
+ if len(str) > 0 {
+ t.Error(str)
+ }
+}
+
+func TestDataArgsDataType(t *testing.T) {
+ input := `[13]`
+
+ args := new(NewDataArgs)
+ str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), args))
+ if len(str) > 0 {
+ t.Error(str)
+ }
+}
+
+func TestDataArgsEmpty(t *testing.T) {
+ input := `[]`
+ args := new(NewDataArgs)
+ str := ExpectInsufficientParamsError(json.Unmarshal([]byte(input), args))
+ if len(str) > 0 {
+ t.Error(str)
+ }
+}
+
+func TestDataArgsInvalid(t *testing.T) {
+ input := `{}`
+
+ args := new(NewDataArgs)
+ str := ExpectDecodeParamError(json.Unmarshal([]byte(input), args))
+ if len(str) > 0 {
+ t.Error(str)
+ }
+}