diff --git a/internal_test.go b/internal_test.go index 2e11d805..7a4d9268 100644 --- a/internal_test.go +++ b/internal_test.go @@ -37,6 +37,8 @@ var resulttests = []struct { {"getblock", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, {"getrawtransaction", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, {"decoderawtransaction", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, + {"getaddressesbyaccount", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, + {"getaddressesbyaccount", []byte(`{"error":null,"id":1,"result":["test"]}`), false, true}, } // TestReadResultCmd tests that readResultCmd can properly unmarshall the diff --git a/jsonapi.go b/jsonapi.go index db2d94b0..42f30efe 100644 --- a/jsonapi.go +++ b/jsonapi.go @@ -665,6 +665,23 @@ func readResultCmd(cmd string, message []byte) (Reply, error) { return result, err } result.Result = res + case "getaddressesbyaccount": + var res []string + err = json.Unmarshal(objmap["result"], &res) + if err != nil { + err = fmt.Errorf("Error unmarshalling json reply: %v", err) + return result, err + } + result.Result = res + // For commands that return a single item, we get it with the + // correct concrete type for free (but treat them seperately + // for clarity. + case "getblockcount": + err = json.Unmarshal(message, &result) + if err != nil { + err = fmt.Errorf("Error unmarshalling json reply: %v", err) + return result, err + } // For anything else put it in an interface. All the data is still // there, just a little less convenient to deal with. default: diff --git a/test_coverage.txt b/test_coverage.txt index 1c42bb88..2ca69f2a 100644 --- a/test_coverage.txt +++ b/test_coverage.txt @@ -6,7 +6,7 @@ github.com/conformal/btcjson/jsonfxns.go MarshallAndSend 100.00% (7/7) github.com/conformal/btcjson/jsonfxns.go GetRaw 100.00% (6/6) github.com/conformal/btcjson/jsonapi.go jsonWithArgs 100.00% (5/5) github.com/conformal/btcjson/jsonapi.go IsValidIdType 100.00% (3/3) -github.com/conformal/btcjson/jsonapi.go readResultCmd 90.00% (45/50) +github.com/conformal/btcjson/jsonapi.go readResultCmd 85.00% (51/60) github.com/conformal/btcjson/jsonapi.go RpcCommand 66.67% (18/27) -github.com/conformal/btcjson --------------- 96.74% (416/430) +github.com/conformal/btcjson --------------- 95.91% (422/440)