1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-29 01:12:24 +08:00

Merge pull request #1692 from ipfs/generalize-peerid-check

Generalize peerid check
This commit is contained in:
Juan Benet
2015-09-13 00:42:53 -04:00
6 changed files with 19 additions and 14 deletions

View File

@ -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
}
}

View File

@ -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"

View File

@ -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"

View File

@ -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() {

View File

@ -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
'
@ -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
'
@ -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
'

View File

@ -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" '