From 796df5b105e64fb5178d2a7594e61f9660276bd5 Mon Sep 17 00:00:00 2001 From: "John C. Vernaleo" Date: Thu, 11 Jul 2013 13:46:32 -0400 Subject: [PATCH] Tests and typos. Increase test coverage. Fix spelling and typos in a comment. Minor update to todo in README.md --- README.md | 3 ++- internal_test.go | 3 +++ jsonapi.go | 4 ++-- test_coverage.txt | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8f9bf58dc..88a574dde 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,8 @@ $ go get github.com/conformal/btcjson ## TODO - Add data structures for remaining commands. -- Increase test coverage to 100% +- Increase test coverage to 100%. +- Add https support. ## GPG Verification Key diff --git a/internal_test.go b/internal_test.go index 7a4d9268d..665618e66 100644 --- a/internal_test.go +++ b/internal_test.go @@ -35,8 +35,11 @@ var resulttests = []struct { {"getinfo", []byte(`{"error":null,"result":null}`), false, false}, {"getinfo", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, {"getblock", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, + {"getblock", []byte(`{"result":{"hash":"000000","confirmations":16007,"size":325648},"error":null,"id":1}`), false, true}, {"getrawtransaction", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, + {"getrawtransaction", []byte(`{"error":null,"id":1,"result":{"hex":"somejunk","version":1}}`), false, true}, {"decoderawtransaction", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, + {"decoderawtransaction", []byte(`{"error":null,"id":1,"result":{"Txid":"something"}}`), false, true}, {"getaddressesbyaccount", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false}, {"getaddressesbyaccount", []byte(`{"error":null,"id":1,"result":["test"]}`), false, true}, } diff --git a/jsonapi.go b/jsonapi.go index 42f30efe3..e07d5aa01 100644 --- a/jsonapi.go +++ b/jsonapi.go @@ -674,8 +674,8 @@ func readResultCmd(cmd string, message []byte) (Reply, error) { } 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. + // correct concrete type for free (but treat them separately + // for clarity). case "getblockcount": err = json.Unmarshal(message, &result) if err != nil { diff --git a/test_coverage.txt b/test_coverage.txt index 2ca69f2ae..4c58d3ec1 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 85.00% (51/60) +github.com/conformal/btcjson/jsonapi.go readResultCmd 90.16% (55/61) github.com/conformal/btcjson/jsonapi.go RpcCommand 66.67% (18/27) -github.com/conformal/btcjson --------------- 95.91% (422/440) +github.com/conformal/btcjson --------------- 96.60% (426/441)