From 046411866b257f6242a37b561b8e417199f7e52b Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Tue, 9 Jun 2015 08:47:20 -0400 Subject: Fixed signing + tests --- rpc/args_test.go | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'rpc/args_test.go') diff --git a/rpc/args_test.go b/rpc/args_test.go index 09ce12467..9ca73660a 100644 --- a/rpc/args_test.go +++ b/rpc/args_test.go @@ -2504,3 +2504,64 @@ func TestSourceArgsEmpty(t *testing.T) { t.Error(str) } } + +func TestSigArgs(t *testing.T) { + input := `["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x0"]` + expected := new(NewSigArgs) + expected.From = "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" + expected.Data = "0x0" + + args := new(NewSigArgs) + if err := json.Unmarshal([]byte(input), &args); err != nil { + t.Error(err) + } +} + +func TestSigArgsEmptyData(t *testing.T) { + input := `["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", ""]` + + args := new(NewSigArgs) + str := ExpectValidationError(json.Unmarshal([]byte(input), args)) + if len(str) > 0 { + t.Error(str) + } +} + +func TestSigArgsDataType(t *testing.T) { + input := `["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", 13]` + + args := new(NewSigArgs) + str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), args)) + if len(str) > 0 { + t.Error(str) + } +} + +func TestSigArgsEmptyFrom(t *testing.T) { + input := `["", "0x0"]` + + args := new(NewSigArgs) + str := ExpectValidationError(json.Unmarshal([]byte(input), args)) + if len(str) > 0 { + t.Error(str) + } +} + +func TestSigArgsFromType(t *testing.T) { + input := `[false, "0x0"]` + + args := new(NewSigArgs) + str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), args)) + if len(str) > 0 { + t.Error(str) + } +} + +func TestSigArgsEmpty(t *testing.T) { + input := `[]` + args := new(NewSigArgs) + str := ExpectInsufficientParamsError(json.Unmarshal([]byte(input), args)) + if len(str) > 0 { + t.Error(str) + } +} -- cgit v1.2.3