WhisperFilterArgs

This commit is contained in:
Taylor Gerring
2015-03-26 20:52:09 +01:00
parent 81f36df910
commit 9ca87afd0b
3 changed files with 60 additions and 13 deletions

View File

@ -1086,10 +1086,9 @@ func TestFilterIdArgsBool(t *testing.T) {
}
}
func TestWhsiperFilterArgs(t *testing.T) {
func TestWhisperFilterArgs(t *testing.T) {
input := `[{"topics": ["0x68656c6c6f20776f726c64"], "to": "0x34ag445g3455b34"}]`
expected := new(WhisperFilterArgs)
expected.From = ""
expected.To = "0x34ag445g3455b34"
expected.Topics = []string{"0x68656c6c6f20776f726c64"}
@ -1098,10 +1097,6 @@ func TestWhsiperFilterArgs(t *testing.T) {
t.Error(err)
}
if expected.From != args.From {
t.Errorf("From shoud be %#v but is %#v", expected.From, args.From)
}
if expected.To != args.To {
t.Errorf("To shoud be %#v but is %#v", expected.To, args.To)
}
@ -1111,6 +1106,46 @@ func TestWhsiperFilterArgs(t *testing.T) {
// }
}
func TestWhisperFilterArgsInvalid(t *testing.T) {
input := `{}`
args := new(WhisperFilterArgs)
str := ExpectDecodeParamError(json.Unmarshal([]byte(input), args))
if len(str) > 0 {
t.Error(str)
}
}
func TestWhisperFilterArgsEmpty(t *testing.T) {
input := `[]`
args := new(WhisperFilterArgs)
str := ExpectInsufficientParamsError(json.Unmarshal([]byte(input), args))
if len(str) > 0 {
t.Error(str)
}
}
func TestWhisperFilterArgsToBool(t *testing.T) {
input := `[{"topics": ["0x68656c6c6f20776f726c64"], "to": false}]`
args := new(WhisperFilterArgs)
str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), args))
if len(str) > 0 {
t.Error(str)
}
}
func TestWhisperFilterArgsTopicInt(t *testing.T) {
input := `[{"topics": [6], "to": "0x34ag445g3455b34"}]`
args := new(WhisperFilterArgs)
str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), args))
if len(str) > 0 {
t.Error(str)
}
}
func TestCompileArgs(t *testing.T) {
input := `["contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"]`
expected := new(CompileArgs)