From fa2bf4423e889807878e5c9f2b43a15feec230b1 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Wed, 20 Nov 2013 11:08:20 -0500 Subject: [PATCH] Add additional tests for importprivkey. --- jsoncmd.go | 2 +- jsoncmd_test.go | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/jsoncmd.go b/jsoncmd.go index 1bb85c45..2119663a 100644 --- a/jsoncmd.go +++ b/jsoncmd.go @@ -3586,7 +3586,7 @@ func (cmd *ImportPrivKeyCmd) UnmarshalJSON(b []byte) error { return err } - if len(r.Params) > 3 { + if len(r.Params) == 0 || len(r.Params) > 3 { return ErrWrongNumberOfParams } diff --git a/jsoncmd_test.go b/jsoncmd_test.go index f5465c33..09656208 100644 --- a/jsoncmd_test.go +++ b/jsoncmd_test.go @@ -674,7 +674,21 @@ var jsoncmdtests = []struct { }, }, { - name: "basic importprivkey + opts", + name: "basic importprivkey + 1 opt", + f: func() (Cmd, error) { + return NewImportPrivKeyCmd(float64(1), + "somereallongprivatekey", + "some text") + }, + result: &ImportPrivKeyCmd{ + id: float64(1), + PrivKey: "somereallongprivatekey", + Label: "some text", + Rescan: true, + }, + }, + { + name: "basic importprivkey + 2 opts", f: func() (Cmd, error) { return NewImportPrivKeyCmd(float64(1), "somereallongprivatekey",