getaddressesbyaccoutn and getbalance test.

and one bug in the marshalling code for getbalance
This commit is contained in:
Owain G. Ainsworth 2013-10-25 18:32:51 +01:00
parent fedafbdd49
commit d1ac7b9384
2 changed files with 55 additions and 4 deletions

View file

@ -1453,9 +1453,7 @@ func (cmd *GetBalanceCmd) MarshalJSON() ([]byte, error) {
Jsonrpc: "1.0",
Method: "getbalance",
Id: cmd.id,
Params: []interface{}{
cmd.Account,
},
Params: []interface{}{},
}
if cmd.Account != "" || cmd.Minconf != 1 {
@ -1493,7 +1491,7 @@ func (cmd *GetBalanceCmd) UnmarshalJSON(b []byte) error {
if len(r.Params) > 1 {
minconf, ok := r.Params[1].(float64)
if !ok {
return errors.New("first optional parameter minconf must be a number")
return errors.New("second optional parameter minconf must be a number")
}
optArgs = append(optArgs, int(minconf))
}

View file

@ -222,6 +222,59 @@ var jsoncmdtests = []struct {
Node: "thisisanode",
},
},
{
name: "basic getaddressesbyaccount",
f: func() (Cmd, error) {
return NewGetAddressesByAccountCmd(float64(1),
"account")
},
result: &GetAddressesByAccountCmd{
id: float64(1),
Account: "account",
},
},
{
name: "basic getbalance",
f: func() (Cmd, error) {
return NewGetBalanceCmd(float64(1))
},
result: &GetBalanceCmd{
id: float64(1),
Minconf: 1, // the default
},
},
{
name: "basic getbalance + account",
f: func() (Cmd, error) {
return NewGetBalanceCmd(float64(1), "account")
},
result: &GetBalanceCmd{
id: float64(1),
Account: "account",
Minconf: 1, // the default
},
},
{
name: "basic getbalance + minconf",
f: func() (Cmd, error) {
return NewGetBalanceCmd(float64(1), "", 2)
},
result: &GetBalanceCmd{
id: float64(1),
Minconf: 2,
},
},
{
name: "basic getbalance + account + minconf",
f: func() (Cmd, error) {
return NewGetBalanceCmd(float64(1), "account", 2)
},
result: &GetBalanceCmd{
id: float64(1),
Account: "account",
Minconf: 2,
},
},
{
name: "basic ping",
f: func() (Cmd, error) {