aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args_test.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-03 23:09:21 +0800
committerobscuren <geffobscura@gmail.com>2015-04-03 23:09:21 +0800
commit11d90d9b2229917b00459ffbad4b1ff6e3c180a2 (patch)
tree187751e89b8654f575da00b4ff80fc5fc1813244 /rpc/args_test.go
parent4558e04c0d35d2d057a7182593e8baaa2d3adec0 (diff)
parent47feff361113fd4b28f81f7b7094c4662b4e8786 (diff)
downloaddexon-11d90d9b2229917b00459ffbad4b1ff6e3c180a2.tar
dexon-11d90d9b2229917b00459ffbad4b1ff6e3c180a2.tar.gz
dexon-11d90d9b2229917b00459ffbad4b1ff6e3c180a2.tar.bz2
dexon-11d90d9b2229917b00459ffbad4b1ff6e3c180a2.tar.lz
dexon-11d90d9b2229917b00459ffbad4b1ff6e3c180a2.tar.xz
dexon-11d90d9b2229917b00459ffbad4b1ff6e3c180a2.tar.zst
dexon-11d90d9b2229917b00459ffbad4b1ff6e3c180a2.zip
Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
Diffstat (limited to 'rpc/args_test.go')
-rw-r--r--rpc/args_test.go70
1 files changed, 70 insertions, 0 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go
index 902f8013e..b88bab280 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -1805,6 +1805,16 @@ func TestWhisperFilterArgsEmpty(t *testing.T) {
}
}
+func TestWhisperFilterArgsToInt(t *testing.T) {
+ input := `[{"to": 2}]`
+
+ args := new(WhisperFilterArgs)
+ str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), args))
+ if len(str) > 0 {
+ t.Error(str)
+ }
+}
+
func TestWhisperFilterArgsToBool(t *testing.T) {
input := `[{"topics": ["0x68656c6c6f20776f726c64"], "to": false}]`
@@ -1815,6 +1825,21 @@ func TestWhisperFilterArgsToBool(t *testing.T) {
}
}
+func TestWhisperFilterArgsToMissing(t *testing.T) {
+ input := `[{"topics": ["0x68656c6c6f20776f726c64"]}]`
+ expected := new(WhisperFilterArgs)
+ expected.To = ""
+
+ args := new(WhisperFilterArgs)
+ if err := json.Unmarshal([]byte(input), &args); err != nil {
+ t.Error(err)
+ }
+
+ if args.To != expected.To {
+ t.Errorf("To shoud be %v but is %v", expected.To, args.To)
+ }
+}
+
func TestWhisperFilterArgsTopicInt(t *testing.T) {
input := `[{"topics": [6], "to": "0x34ag445g3455b34"}]`
@@ -2090,6 +2115,51 @@ func TestHashIndexArgsInvalidIndex(t *testing.T) {
}
}
+func TestHashArgs(t *testing.T) {
+ input := `["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b"]`
+ expected := new(HashIndexArgs)
+ expected.Hash = "0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b"
+
+ args := new(HashArgs)
+ if err := json.Unmarshal([]byte(input), &args); err != nil {
+ t.Error(err)
+ }
+
+ if expected.Hash != args.Hash {
+ t.Errorf("Hash shoud be %#v but is %#v", expected.Hash, args.Hash)
+ }
+}
+
+func TestHashArgsEmpty(t *testing.T) {
+ input := `[]`
+
+ args := new(HashArgs)
+ str := ExpectInsufficientParamsError(json.Unmarshal([]byte(input), &args))
+ if len(str) > 0 {
+ t.Error(str)
+ }
+}
+
+func TestHashArgsInvalid(t *testing.T) {
+ input := `{}`
+
+ args := new(HashArgs)
+ str := ExpectDecodeParamError(json.Unmarshal([]byte(input), &args))
+ if len(str) > 0 {
+ t.Error(str)
+ }
+}
+
+func TestHashArgsInvalidHash(t *testing.T) {
+ input := `[7]`
+
+ args := new(HashArgs)
+ str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), &args))
+ if len(str) > 0 {
+ t.Error(str)
+ }
+}
+
func TestSubmitWorkArgs(t *testing.T) {
input := `["0x0000000000000001", "0x1234567890abcdef1234567890abcdef", "0xD1GE5700000000000000000000000000"]`
expected := new(SubmitWorkArgs)