Merge pull request #1217 from tgerring/rpcsign

Fix RPC sign
This commit is contained in:
Jeffrey Wilcke
2015-06-09 06:19:39 -07:00
2 changed files with 74 additions and 13 deletions

View File

@ -2508,3 +2508,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)
}
}