@cryptotaxi247 / kubo / commits / 25c3e126b

keystore: add self key to the listing

License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed Feb 28, 2017 at 16:16 UTC 25c3e126b867bb8b9596d724a0e587bcaf0d7e47
2 files changed +9 -2
core/commands/keystore.go
+4 -2
@@ -40,7 +40,7 @@ var KeyGenCmd = &cmds.Command{
40 Tagline: "Create a new keypair",
41 },
42 Options: []cmds.Option{
43 - cmds.StringOption("type", "t", "type of the key to create"),
43 + cmds.StringOption("type", "t", "type of the key to create [rsa, ed25519]"),
44 cmds.IntOption("size", "s", "size of the key to generate"),
45 },
46 Arguments: []cmds.Argument{
@@ -160,7 +160,9 @@ var KeyListCmd = &cmds.Command{
160
161 sort.Strings(keys)
162
163 - list := make([]KeyOutput, 0, len(keys))
163 + list := make([]KeyOutput, 0, len(keys)+1)
164 +
165 + list = append(list, KeyOutput{Name: "self", Id: n.Identity.Pretty()})
166
167 for _, key := range keys {
168 privKey, err := n.Repo.Keystore().Get(key)
test/sharness/t0165-keystore.sh
+5
@@ -22,6 +22,7 @@ test_key_cmd() {
22 test_expect_success "both keys show up in list output" '
23 echo bazed > list_exp &&
24 echo foobarsa >> list_exp &&
25 + echo self >> list_exp
26 ipfs key list | sort > list_out &&
27 test_cmp list_exp list_out
28 '
@@ -30,6 +31,10 @@ test_key_cmd() {
31 ipfs key list -l | grep $edhash > /dev/null &&
32 ipfs key list -l | grep $rsahash > /dev/null
33 '
34 +
35 + test_expect_success "key list -l contains self key with peerID" '
36 + ipfs key list -l | grep "$(ipfs config Identity.PeerID) self"
37 + '
38 }
39
40 test_key_cmd