diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-27 04:07:50 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-27 04:07:50 +0800 |
commit | 1f3814141b94166cc5bf5b439babe6cc56b3cebf (patch) | |
tree | 1552094d748d5cea9d5c0a5902be167014a2a653 /rpc/args_test.go | |
parent | 9ca87afd0ba043043a3d2b4919d72b7f7a39ffe8 (diff) | |
download | go-tangerine-1f3814141b94166cc5bf5b439babe6cc56b3cebf.tar go-tangerine-1f3814141b94166cc5bf5b439babe6cc56b3cebf.tar.gz go-tangerine-1f3814141b94166cc5bf5b439babe6cc56b3cebf.tar.bz2 go-tangerine-1f3814141b94166cc5bf5b439babe6cc56b3cebf.tar.lz go-tangerine-1f3814141b94166cc5bf5b439babe6cc56b3cebf.tar.xz go-tangerine-1f3814141b94166cc5bf5b439babe6cc56b3cebf.tar.zst go-tangerine-1f3814141b94166cc5bf5b439babe6cc56b3cebf.zip |
WhisperMessageArgs
Diffstat (limited to 'rpc/args_test.go')
-rw-r--r-- | rpc/args_test.go | 92 |
1 files changed, 91 insertions, 1 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go index f668dfdd4..da98071e9 100644 --- a/rpc/args_test.go +++ b/rpc/args_test.go @@ -1009,7 +1009,7 @@ func TestWhisperMessageArgs(t *testing.T) { expected.Payload = "0x68656c6c6f20776f726c64" expected.Priority = 100 expected.Ttl = 100 - expected.Topics = []string{"0x68656c6c6f20776f726c64"} + // expected.Topics = []string{"0x68656c6c6f20776f726c64"} args := new(WhisperMessageArgs) if err := json.Unmarshal([]byte(input), &args); err != nil { @@ -1041,6 +1041,96 @@ func TestWhisperMessageArgs(t *testing.T) { // } } +func TestWhisperMessageArgsInt(t *testing.T) { + input := `[{"from":"0xc931d93e97ab07fe42d923478ba2465f2", + "topics": ["0x68656c6c6f20776f726c64"], + "payload":"0x68656c6c6f20776f726c64", + "ttl": 12, + "priority": 16}]` + expected := new(WhisperMessageArgs) + expected.From = "0xc931d93e97ab07fe42d923478ba2465f2" + expected.To = "" + expected.Payload = "0x68656c6c6f20776f726c64" + expected.Priority = 16 + expected.Ttl = 12 + // expected.Topics = []string{"0x68656c6c6f20776f726c64"} + + args := new(WhisperMessageArgs) + if err := json.Unmarshal([]byte(input), &args); err != nil { + 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) + } + + if expected.Payload != args.Payload { + t.Errorf("Value shoud be %#v but is %#v", expected.Payload, args.Payload) + } + + if expected.Ttl != args.Ttl { + t.Errorf("Ttl shoud be %v but is %v", expected.Ttl, args.Ttl) + } + + if expected.Priority != args.Priority { + t.Errorf("Priority shoud be %v but is %v", expected.Priority, args.Priority) + } + + // if expected.Topics != args.Topics { + // t.Errorf("Topic shoud be %#v but is %#v", expected.Topic, args.Topic) + // } +} + +func TestWhisperMessageArgsInvalid(t *testing.T) { + input := `{}` + + args := new(WhisperMessageArgs) + str := ExpectDecodeParamError(json.Unmarshal([]byte(input), args)) + if len(str) > 0 { + t.Error(str) + } +} + +func TestWhisperMessageArgsEmpty(t *testing.T) { + input := `[]` + + args := new(WhisperMessageArgs) + str := ExpectInsufficientParamsError(json.Unmarshal([]byte(input), args)) + if len(str) > 0 { + t.Error(str) + } +} + +func TestWhisperMessageArgsTtlBool(t *testing.T) { + input := `[{"from":"0xc931d93e97ab07fe42d923478ba2465f2", + "topics": ["0x68656c6c6f20776f726c64"], + "payload":"0x68656c6c6f20776f726c64", + "ttl": true, + "priority": "0x64"}]` + args := new(WhisperMessageArgs) + str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), args)) + if len(str) > 0 { + t.Error(str) + } +} + +func TestWhisperMessageArgsPriorityBool(t *testing.T) { + input := `[{"from":"0xc931d93e97ab07fe42d923478ba2465f2", + "topics": ["0x68656c6c6f20776f726c64"], + "payload":"0x68656c6c6f20776f726c64", + "ttl": "0x12", + "priority": true}]` + args := new(WhisperMessageArgs) + str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), args)) + if len(str) > 0 { + t.Error(str) + } +} + func TestFilterIdArgs(t *testing.T) { input := `["0x7"]` expected := new(FilterIdArgs) |