From 5c118a20d70b10c8de3f0b6d711295bb2a33c205 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 12 Sep 2015 19:00:26 +0200 Subject: [PATCH 1/6] sharness: generalize test_check_peerid() License: MIT Signed-off-by: Christian Couder --- test/sharness/lib/test-lib.sh | 5 +++++ test/sharness/t0020-init.sh | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index 1d6866c48..d7e42a077 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -344,3 +344,8 @@ generic_stat() { esac $_STAT "$1" } + +test_check_peerid() { + test $(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") = "46" +} + diff --git a/test/sharness/t0020-init.sh b/test/sharness/t0020-init.sh index 2a930ea9e..8416502b3 100755 --- a/test/sharness/t0020-init.sh +++ b/test/sharness/t0020-init.sh @@ -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" From 0aa59368e46ca60eb0cdb7ab7aab149459fc8454 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 12 Sep 2015 19:06:50 +0200 Subject: [PATCH 2/6] t0060: simplify peerid check License: MIT Signed-off-by: Christian Couder --- test/sharness/t0060-daemon.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test/sharness/t0060-daemon.sh b/test/sharness/t0060-daemon.sh index db063d22d..44bb87515 100755 --- a/test/sharness/t0060-daemon.sh +++ b/test/sharness/t0060-daemon.sh @@ -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" From 9563cb29d9dee912b8c003ff608e81b5d309b5f1 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 12 Sep 2015 19:10:18 +0200 Subject: [PATCH 3/6] t0110: add peerid check License: MIT Signed-off-by: Christian Couder --- test/sharness/t0110-gateway.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/sharness/t0110-gateway.sh b/test/sharness/t0110-gateway.sh index 944137668..c15832088 100755 --- a/test/sharness/t0110-gateway.sh +++ b/test/sharness/t0110-gateway.sh @@ -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" ' From bec8224a0ee7cd56da6b612c3321bced9cac19bd Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 12 Sep 2015 19:14:34 +0200 Subject: [PATCH 4/6] t0062: add peerid check License: MIT Signed-off-by: Christian Couder --- test/sharness/t0062-daemon-api.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/sharness/t0062-daemon-api.sh b/test/sharness/t0062-daemon-api.sh index 9efba6302..db6ca1c27 100755 --- a/test/sharness/t0062-daemon-api.sh +++ b/test/sharness/t0062-daemon-api.sh @@ -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() { From e22cbcec27a053ab01e7a03f994cbce4ee186a09 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 12 Sep 2015 19:16:54 +0200 Subject: [PATCH 5/6] t0100: add peerid check License: MIT Signed-off-by: Christian Couder --- test/sharness/t0100-name.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/sharness/t0100-name.sh b/test/sharness/t0100-name.sh index b2ea8f4bc..d782729ca 100755 --- a/test/sharness/t0100-name.sh +++ b/test/sharness/t0100-name.sh @@ -14,6 +14,7 @@ test_init_ipfs test_expect_success "'ipfs name publish' succeeds" ' PEERID=`ipfs id --format=""` && + 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=""` && + 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 ' succeeds" ' PEERID=`ipfs id --format=""` && + test_check_peerid "${PEERID}" && ipfs name publish "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish ' From 6e59b39b74af0838141a952718cbc8a753ead32f Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 12 Sep 2015 19:27:55 +0200 Subject: [PATCH 6/6] test-lib: improve test_check_peerid License: MIT Signed-off-by: Christian Couder --- test/sharness/lib/test-lib.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index d7e42a077..b9a25ae87 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -346,6 +346,10 @@ generic_stat() { } test_check_peerid() { - test $(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") = "46" + peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") && + test "$peeridlen" = "46" || { + echo "Bad peerid '$1' with len '$peeridlen'" + return 1 + } }