From b7ce80c0f587b637bfb721f8b45db4515680dd88 Mon Sep 17 00:00:00 2001 From: Xiaoyi Wang Date: Sun, 22 Apr 2018 11:45:37 +0800 Subject: [PATCH 1/2] Fix key rename command output error License: MIT Signed-off-by: Xiaoyi Wang --- core/commands/keystore.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/commands/keystore.go b/core/commands/keystore.go index 815b45d20b4..e6a98c45a44 100644 --- a/core/commands/keystore.go +++ b/core/commands/keystore.go @@ -306,7 +306,11 @@ var keyRenameCmd = &cmds.Command{ }, Marshalers: cmds.MarshalerMap{ cmds.Text: func(res cmds.Response) (io.Reader, error) { - k, ok := res.Output().(*KeyRenameOutput) + v, err := unwrapOutput(res.Output()) + if err != nil { + return nil, err + } + k, ok := v.(*KeyRenameOutput) if !ok { return nil, fmt.Errorf("expected a KeyRenameOutput as command result") } From be6920fe9b34c518e1ad60c8b96aee355af408d0 Mon Sep 17 00:00:00 2001 From: Xiaoyi Wang Date: Mon, 23 Apr 2018 22:33:31 +0800 Subject: [PATCH 2/2] Add testcase for key rename command output License: MIT Signed-off-by: Xiaoyi Wang --- test/sharness/t0165-keystore.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/sharness/t0165-keystore.sh b/test/sharness/t0165-keystore.sh index 39c3b5dd990..80d39ab8257 100755 --- a/test/sharness/t0165-keystore.sh +++ b/test/sharness/t0165-keystore.sh @@ -58,6 +58,13 @@ test_key_cmd() { test_cmp list_exp list_out ' + test_expect_success "key rename rename key output succeeds" ' + key_content=$(ipfs key gen key1 --type=rsa --size=2048) && + ipfs key rename key1 key2 >rs && + echo "Key $key_content renamed to key2" >expect && + test_cmp rs expect + ' + test_expect_success "key rename can't rename self" ' test_must_fail ipfs key rename self bar 2>&1 | tee key_rename_out && grep -q "Error: cannot rename key with name" key_rename_out