Fix sendmany optarg parsing and add tests.
This commit is contained in:
parent
97a4ab6a47
commit
708dce8d99
2 changed files with 50 additions and 1 deletions
|
@ -5110,7 +5110,7 @@ func NewSendManyCmd(id interface{}, fromaccount string, amounts map[string]int64
|
||||||
minconf = m
|
minconf = m
|
||||||
}
|
}
|
||||||
if len(optArgs) > 1 {
|
if len(optArgs) > 1 {
|
||||||
c, ok := optArgs[0].(string)
|
c, ok := optArgs[1].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errors.New("second optional parameter comment is not a string")
|
return nil, errors.New("second optional parameter comment is not a string")
|
||||||
}
|
}
|
||||||
|
|
|
@ -933,6 +933,55 @@ var jsoncmdtests = []struct {
|
||||||
CommentTo: "comment to",
|
CommentTo: "comment to",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "basic sendmany",
|
||||||
|
f: func() (Cmd, error) {
|
||||||
|
pairs := map[string]int64{
|
||||||
|
"address A": 1000,
|
||||||
|
"address B": 2000,
|
||||||
|
"address C": 3000,
|
||||||
|
}
|
||||||
|
return NewSendManyCmd(float64(1),
|
||||||
|
"account",
|
||||||
|
pairs)
|
||||||
|
},
|
||||||
|
result: &SendManyCmd{
|
||||||
|
id: float64(1),
|
||||||
|
FromAccount: "account",
|
||||||
|
Amounts: map[string]int64{
|
||||||
|
"address A": 1000,
|
||||||
|
"address B": 2000,
|
||||||
|
"address C": 3000,
|
||||||
|
},
|
||||||
|
MinConf: 1, // the default
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "sendmany + options",
|
||||||
|
f: func() (Cmd, error) {
|
||||||
|
pairs := map[string]int64{
|
||||||
|
"address A": 1000,
|
||||||
|
"address B": 2000,
|
||||||
|
"address C": 3000,
|
||||||
|
}
|
||||||
|
return NewSendManyCmd(float64(1),
|
||||||
|
"account",
|
||||||
|
pairs,
|
||||||
|
10,
|
||||||
|
"comment")
|
||||||
|
},
|
||||||
|
result: &SendManyCmd{
|
||||||
|
id: float64(1),
|
||||||
|
FromAccount: "account",
|
||||||
|
Amounts: map[string]int64{
|
||||||
|
"address A": 1000,
|
||||||
|
"address B": 2000,
|
||||||
|
"address C": 3000,
|
||||||
|
},
|
||||||
|
MinConf: 10,
|
||||||
|
Comment: "comment",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "basic sendrawtransaction",
|
name: "basic sendrawtransaction",
|
||||||
f: func() (Cmd, error) {
|
f: func() (Cmd, error) {
|
||||||
|
|
Loading…
Reference in a new issue