diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-06-09 20:47:20 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-06-09 20:47:20 +0800 |
commit | 046411866b257f6242a37b561b8e417199f7e52b (patch) | |
tree | 36aacc636447efd98f7659dc5677bc5162fa6fe5 /rpc/args_test.go | |
parent | 3054fd481175286591e5d867ec119e9151d02cb8 (diff) | |
download | dexon-046411866b257f6242a37b561b8e417199f7e52b.tar.gz dexon-046411866b257f6242a37b561b8e417199f7e52b.tar.zst dexon-046411866b257f6242a37b561b8e417199f7e52b.zip |
Fixed signing + tests
Diffstat (limited to 'rpc/args_test.go')
-rw-r--r-- | rpc/args_test.go | 61 |
1 files changed, 61 insertions, 0 deletions
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) + } +} |