Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keystore: add self key to the listing #3734

Merged
merged 2 commits into from
Mar 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions core/commands/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions test/sharness/t0165-keystore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
'
Expand All @@ -30,6 +31,11 @@ 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" '
PeerID="$(ipfs config Identity.PeerID)"
ipfs key list -l | grep "$PeerID self"
'
}

test_key_cmd
Expand Down