Skip to content

Commit

Permalink
address CR feedback
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jeromy <[email protected]>
  • Loading branch information
whyrusleeping committed Jan 17, 2016
1 parent 52da1e3 commit 39d0b33
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func bootstrapConnect(ctx context.Context, ph host.Host, peers []peer.PeerInfo)
return nil
}

func toPeerInfos(bpeers []config.BootstrapPeer) ([]peer.PeerInfo, error) {
func toPeerInfos(bpeers []config.BootstrapPeer) []peer.PeerInfo {
pinfos := make(map[peer.ID]*peer.PeerInfo)
for _, bootstrap := range bpeers {
pinfo, ok := pinfos[bootstrap.ID()]
Expand All @@ -219,7 +219,7 @@ func toPeerInfos(bpeers []config.BootstrapPeer) ([]peer.PeerInfo, error) {
peers = append(peers, *pinfo)
}

return peers, nil
return peers
}

func randomSubsetOfPeers(in []peer.PeerInfo, max int) []peer.PeerInfo {
Expand Down
2 changes: 1 addition & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func (n *IpfsNode) loadBootstrapPeers() ([]peer.PeerInfo, error) {
if err != nil {
return nil, err
}
return toPeerInfos(parsed)
return toPeerInfos(parsed), nil
}

func (n *IpfsNode) loadFilesRoot() error {
Expand Down
37 changes: 36 additions & 1 deletion test/sharness/t0121-bootstrap-iptb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,41 @@ test_expect_success "setup iptb nodes" '
iptb init -n 5 -f --bootstrap=none --port=0
'

test_expect_success "start up iptb nodes" '
iptb start
'

test_expect_success "check peers works" '
ipfs swarm peers >peers_out
'

test_expect_success "correct number of peers" '
test -z "`cat peers_out`"
'

betterwait() {
while kill -0 $1; do true; done
}

test_expect_success "bring down iptb nodes" '
PID0=$(cat "$IPTB_ROOT/0/daemon.pid") &&
PID1=$(cat "$IPTB_ROOT/1/daemon.pid") &&
PID2=$(cat "$IPTB_ROOT/2/daemon.pid") &&
PID3=$(cat "$IPTB_ROOT/3/daemon.pid") &&
PID4=$(cat "$IPTB_ROOT/4/daemon.pid") &&
iptb stop && # TODO: add --wait flag to iptb stop
betterwait $PID0
betterwait $PID1
betterwait $PID2
betterwait $PID3
betterwait $PID4
'

test_expect_success "reset iptb nodes" '
# the api doesnt seem to get cleaned up in sharness tests for some reason
iptb init -n 5 -f --bootstrap=none --port=0
'

test_expect_success "set bootstrap addrs" '
bsn_peer_id=$(ipfs id -f "<id>") &&
BADDR="/ip4/127.0.0.1/tcp/$PORT_SWARM/ipfs/$bsn_peer_id" &&
Expand All @@ -53,7 +88,7 @@ test_expect_success "check peers works" '
'

test_expect_success "correct number of peers" '
test `cat peers_out | wc -l` == 5
test `cat peers_out | wc -l` = 5
'

test_kill_ipfs_daemon
Expand Down

0 comments on commit 39d0b33

Please sign in to comment.