From 25c3e126b867bb8b9596d724a0e587bcaf0d7e47 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 28 Feb 2017 16:16:16 +0100 Subject: [PATCH] keystore: add self key to the listing License: MIT Signed-off-by: Jakub Sztandera --- core/commands/keystore.go | 6 ++++-- test/sharness/t0165-keystore.sh | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/commands/keystore.go b/core/commands/keystore.go index 729e90088..60d460690 100644 --- a/core/commands/keystore.go +++ b/core/commands/keystore.go @@ -40,7 +40,7 @@ var KeyGenCmd = &cmds.Command{ Tagline: "Create a new keypair", }, Options: []cmds.Option{ - cmds.StringOption("type", "t", "type of the key to create"), + cmds.StringOption("type", "t", "type of the key to create [rsa, ed25519]"), cmds.IntOption("size", "s", "size of the key to generate"), }, Arguments: []cmds.Argument{ @@ -160,7 +160,9 @@ var KeyListCmd = &cmds.Command{ sort.Strings(keys) - list := make([]KeyOutput, 0, len(keys)) + list := make([]KeyOutput, 0, len(keys)+1) + + list = append(list, KeyOutput{Name: "self", Id: n.Identity.Pretty()}) for _, key := range keys { privKey, err := n.Repo.Keystore().Get(key) diff --git a/test/sharness/t0165-keystore.sh b/test/sharness/t0165-keystore.sh index 1d94d4f46..3fafdc90c 100755 --- a/test/sharness/t0165-keystore.sh +++ b/test/sharness/t0165-keystore.sh @@ -22,6 +22,7 @@ test_key_cmd() { test_expect_success "both keys show up in list output" ' echo bazed > list_exp && echo foobarsa >> list_exp && + echo self >> list_exp ipfs key list | sort > list_out && test_cmp list_exp list_out ' @@ -30,6 +31,10 @@ test_key_cmd() { ipfs key list -l | grep $edhash > /dev/null && ipfs key list -l | grep $rsahash > /dev/null ' + + test_expect_success "key list -l contains self key with peerID" ' + ipfs key list -l | grep "$(ipfs config Identity.PeerID) self" + ' } test_key_cmd