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

Generalize peerid check #1692

Merged
merged 6 commits into from
Sep 13, 2015
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
9 changes: 9 additions & 0 deletions test/sharness/lib/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,12 @@ generic_stat() {
esac
$_STAT "$1"
}

test_check_peerid() {
peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") &&
test "$peeridlen" = "46" || {
echo "Bad peerid '$1' with len '$peeridlen'"
return 1
}
}

4 changes: 0 additions & 4 deletions test/sharness/t0020-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ test_expect_success "ipfs config succeeds" '
test_cmp expected_config actual_config
'

test_check_peerid() {
test $(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") = "46"
}

test_expect_success "ipfs peer id looks good" '
PEERID=$(ipfs config Identity.PeerID) &&
test_check_peerid "$PEERID"
Expand Down
9 changes: 2 additions & 7 deletions test/sharness/t0060-daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,15 @@ test_expect_success "initialization ended" '

# this errors if daemon didnt --init $IPFS_PATH correctly
test_expect_success "'ipfs config Identity.PeerID' works" '
ipfs config Identity.PeerID >config_peerId
PEERID=$(ipfs config Identity.PeerID)
'

test_expect_success "'ipfs swarm addrs local' works" '
ipfs swarm addrs local >local_addrs
'


# this is lifted straight from t0020-init.sh
test_expect_success "ipfs peer id looks good" '
PEERID=$(cat config_peerId) &&
echo $PEERID | tr -dC "[:alnum:]" | wc -c | tr -d " " >actual_id &&
echo "46" >expected_id &&
test_cmp_repeat_10_sec expected_id actual_id
test_check_peerid "$PEERID"
'

# This is like t0020-init.sh "ipfs init output looks good"
Expand Down
3 changes: 2 additions & 1 deletion test/sharness/t0062-daemon-api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ api_unreachable="/ip4/127.0.0.1/tcp/1"

test_expect_success "config setup" '
api_fromcfg=$(ipfs config Addresses.API) &&
peerid=$(ipfs config Identity.PeerID)
peerid=$(ipfs config Identity.PeerID) &&
test_check_peerid "$peerid"
'

test_client() {
Expand Down
3 changes: 3 additions & 0 deletions test/sharness/t0100-name.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ test_init_ipfs

test_expect_success "'ipfs name publish' succeeds" '
PEERID=`ipfs id --format="<id>"` &&
test_check_peerid "${PEERID}" &&
ipfs name publish "/ipfs/$HASH_WELCOME_DOCS" >publish_out
'

Expand All @@ -35,6 +36,7 @@ test_expect_success "resolve output looks good" '

test_expect_success "'ipfs name publish' succeeds" '
PEERID=`ipfs id --format="<id>"` &&
test_check_peerid "${PEERID}" &&
ipfs name publish "/ipfs/$HASH_WELCOME_DOCS/help" >publish_out
'

Expand All @@ -56,6 +58,7 @@ test_expect_success "resolve output looks good" '

test_expect_success "'ipfs name publish <local-id> <hash>' succeeds" '
PEERID=`ipfs id --format="<id>"` &&
test_check_peerid "${PEERID}" &&
ipfs name publish "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish
'

Expand Down
5 changes: 3 additions & 2 deletions test/sharness/t0110-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ test_expect_success "GET IPFS non existent file returns code expected (404)" '

test_expect_failure "GET IPNS path succeeds" '
ipfs name publish "$HASH" &&
NAME=$(ipfs config Identity.PeerID) &&
curl -sfo actual "http://127.0.0.1:$port/ipns/$NAME"
PEERID=$(ipfs config Identity.PeerID) &&
test_check_peerid "$PEERID" &&
curl -sfo actual "http://127.0.0.1:$port/ipns/$PEERID"
'

test_expect_failure "GET IPNS path output looks good" '
Expand Down