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

fix(commands): print consistent addresses in ipfs id #7397

Merged
merged 2 commits into from
Jun 2, 2020
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
8 changes: 7 additions & 1 deletion core/commands/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ func printPeer(ps pstore.Peerstore, p peer.ID) (interface{}, error) {
info.PublicKey = base64.StdEncoding.EncodeToString(pkb)
}

for _, a := range ps.Addrs(p) {
addrInfo := ps.PeerInfo(p)
addrs, err := peer.AddrInfoToP2pAddrs(&addrInfo)
if err != nil {
return nil, err
}

for _, a := range addrs {
info.Addresses = append(info.Addresses, a.String())
}

Expand Down
19 changes: 19 additions & 0 deletions test/sharness/t0140-swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,25 @@ test_expect_success "/p2p addresses work" '
[ $(ipfsi 0 swarm peers | wc -l) -eq 1 ]
'

test_expect_success "ipfs id is consistent for node 0" '
ipfsi 1 id "$(iptb attr get 0 id)" > 1see0 &&
ipfsi 0 id > 0see0 &&
test_cmp 1see0 0see0
'

test_expect_success "ipfs id is consistent for node 1" '
ipfsi 0 id "$(iptb attr get 1 id)" > 0see1 &&
ipfsi 1 id > 1see1 &&
test_cmp 0see1 1see1
'

test_expect_success "addresses contain /p2p/..." '
test_should_contain "/p2p/$(iptb attr get 1 id)\"" 0see1 &&
test_should_contain "/p2p/$(iptb attr get 1 id)\"" 1see1 &&
test_should_contain "/p2p/$(iptb attr get 0 id)\"" 1see0 &&
test_should_contain "/p2p/$(iptb attr get 0 id)\"" 0see0
'

test_expect_success "stopping cluster" '
iptb stop
'
Expand Down