diff --git a/test/sharness/lib/install-sharness.sh b/test/sharness/lib/install-sharness.sh index b7c9eddfe88..d2e93ece9ab 100755 --- a/test/sharness/lib/install-sharness.sh +++ b/test/sharness/lib/install-sharness.sh @@ -9,41 +9,41 @@ version=5eee9b51b5621cec95a64018f0cc779963b230d2 urlprefix=https://github.com/mlafeldt/sharness.git if test ! -n "$clonedir" ; then - clonedir=lib + clonedir=lib fi sharnessdir=sharness if test -f "$clonedir/$sharnessdir/SHARNESS_VERSION_$version" then - # There is the right version file. Great, we are done! - exit 0 + # There is the right version file. Great, we are done! + exit 0 fi die() { - echo >&2 "$@" - exit 1 + echo >&2 "$@" + exit 1 } checkout_version() { - git checkout "$version" || die "Could not checkout '$version'" - rm -f SHARNESS_VERSION_* || die "Could not remove 'SHARNESS_VERSION_*'" - touch "SHARNESS_VERSION_$version" || die "Could not create 'SHARNESS_VERSION_$version'" - echo "Sharness version $version is checked out!" + git checkout "$version" || die "Could not checkout '$version'" + rm -f SHARNESS_VERSION_* || die "Could not remove 'SHARNESS_VERSION_*'" + touch "SHARNESS_VERSION_$version" || die "Could not create 'SHARNESS_VERSION_$version'" + echo "Sharness version $version is checked out!" } if test -d "$clonedir/$sharnessdir/.git" then - # We need to update sharness! - cd "$clonedir/$sharnessdir" || die "Could not cd into '$clonedir/$sharnessdir' directory" - git fetch || die "Could not fetch to update sharness" - checkout_version + # We need to update sharness! + cd "$clonedir/$sharnessdir" || die "Could not cd into '$clonedir/$sharnessdir' directory" + git fetch || die "Could not fetch to update sharness" + checkout_version else - # We need to clone sharness! - mkdir -p "$clonedir" || die "Could not create '$clonedir' directory" - cd "$clonedir" || die "Could not cd into '$clonedir' directory" + # We need to clone sharness! + mkdir -p "$clonedir" || die "Could not create '$clonedir' directory" + cd "$clonedir" || die "Could not cd into '$clonedir' directory" - git clone "$urlprefix" || die "Could not clone '$urlprefix'" - cd "$sharnessdir" || die "Could not cd into '$sharnessdir' directory" - checkout_version + git clone "$urlprefix" || die "Could not clone '$urlprefix'" + cd "$sharnessdir" || die "Could not cd into '$sharnessdir' directory" + checkout_version fi exit 0 diff --git a/test/sharness/lib/iptb-lib.sh b/test/sharness/lib/iptb-lib.sh index 89ab77899d7..2bb54615035 100644 --- a/test/sharness/lib/iptb-lib.sh +++ b/test/sharness/lib/iptb-lib.sh @@ -6,42 +6,42 @@ export IPTB_ROOT="$(pwd)/.iptb" ipfsi() { - dir="$1" - shift - IPFS_PATH="$IPTB_ROOT/$dir" ipfs "$@" + dir="$1" + shift + IPFS_PATH="$IPTB_ROOT/$dir" ipfs "$@" } check_has_connection() { - node="$1" - ipfsi "$node" swarm peers >"swarm_peers_$node" && - grep "ipfs" "swarm_peers_$node" >/dev/null + node="$1" + ipfsi "$node" swarm peers >"swarm_peers_$node" && + grep "ipfs" "swarm_peers_$node" >/dev/null } startup_cluster() { - num_nodes="$1" - shift - other_args="$@" - bound=$(expr "$num_nodes" - 1) + num_nodes="$1" + shift + other_args="$@" + bound=$(expr "$num_nodes" - 1) - if test -n "$other_args"; then - test_expect_success "start up nodes with additional args" ' - iptb start --args $other_args - ' - else - test_expect_success "start up nodes" ' - iptb start - ' - fi + if test -n "$other_args"; then + test_expect_success "start up nodes with additional args" ' + iptb start --args $other_args + ' + else + test_expect_success "start up nodes" ' + iptb start + ' + fi - test_expect_success "connect nodes to eachother" ' - iptb connect [1-$bound] 0 - ' + test_expect_success "connect nodes to eachother" ' + iptb connect [1-$bound] 0 + ' - for i in $(test_seq 0 "$bound") - do - test_expect_success "node $i is connected" ' - check_has_connection "$i" || - test_fsh cat "swarm_peers_$i" - ' - done + for i in $(test_seq 0 "$bound") + do + test_expect_success "node $i is connected" ' + check_has_connection "$i" || + test_fsh cat "swarm_peers_$i" + ' + done } diff --git a/test/sharness/lib/test-aggregate-results.sh b/test/sharness/lib/test-aggregate-results.sh index c2ff76ca1d9..d0987e24b91 100755 --- a/test/sharness/lib/test-aggregate-results.sh +++ b/test/sharness/lib/test-aggregate-results.sh @@ -9,9 +9,9 @@ SHARNESS_AGGREGATE="lib/sharness/aggregate-results.sh" test -f "$SHARNESS_AGGREGATE" || { - echo >&2 "Cannot find: $SHARNESS_AGGREGATE" - echo >&2 "Please check Sharness installation." - exit 1 + echo >&2 "Cannot find: $SHARNESS_AGGREGATE" + echo >&2 "Please check Sharness installation." + exit 1 } ls test-results/t*-*.sh.*.counts | "$SHARNESS_AGGREGATE" diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index d443978fdc3..660f94e1bfb 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -10,16 +10,16 @@ # add current directory to path, for ipfs tool. if test "$MAKE_SKIP_PATH" != "1"; then - BIN=$(cd .. && echo `pwd`/bin) - BIN2=$(cd ../.. && echo `pwd`/cmd/ipfs) - PATH=${BIN2}:${BIN}:${PATH} - - # assert the `ipfs` we're using is the right one. - if test `which ipfs` != ${BIN2}/ipfs; then - echo >&2 "Cannot find the tests' local ipfs tool." - echo >&2 "Please check test and ipfs tool installation." - exit 1 - fi + BIN=$(cd .. && echo `pwd`/bin) + BIN2=$(cd ../.. && echo `pwd`/cmd/ipfs) + PATH=${BIN2}:${BIN}:${PATH} + + # assert the `ipfs` we're using is the right one. + if test `which ipfs` != ${BIN2}/ipfs; then + echo >&2 "Cannot find the tests' local ipfs tool." + echo >&2 "Please check test and ipfs tool installation." + exit 1 + fi fi # set sharness verbosity. we set the env var directly as @@ -33,9 +33,9 @@ test "$TEST_VERBOSE" = 1 && verbose=t SHARNESS_LIB="lib/sharness/sharness.sh" . "$SHARNESS_LIB" || { - echo >&2 "Cannot source: $SHARNESS_LIB" - echo >&2 "Please check Sharness installation." - exit 1 + echo >&2 "Cannot source: $SHARNESS_LIB" + echo >&2 "Please check Sharness installation." + exit 1 } # Please put go-ipfs specific shell functions below @@ -52,11 +52,11 @@ test "$TEST_NO_PLUGIN" != 1 && test "$TEST_OS" = "LINUX" && test_set_prereq PLUG expr "$TEST_OS" : "CYGWIN_NT" >/dev/null || test_set_prereq STD_ERR_MSG if test "$TEST_VERBOSE" = 1; then - echo '# TEST_VERBOSE='"$TEST_VERBOSE" - echo '# TEST_NO_FUSE='"$TEST_NO_FUSE" - echo '# TEST_NO_PLUGIN='"$TEST_NO_PLUGIN" - echo '# TEST_EXPENSIVE='"$TEST_EXPENSIVE" - echo '# TEST_OS='"$TEST_OS" + echo '# TEST_VERBOSE='"$TEST_VERBOSE" + echo '# TEST_NO_FUSE='"$TEST_NO_FUSE" + echo '# TEST_NO_PLUGIN='"$TEST_NO_PLUGIN" + echo '# TEST_EXPENSIVE='"$TEST_EXPENSIVE" + echo '# TEST_OS='"$TEST_OS" fi # source our generic test lib @@ -66,46 +66,46 @@ fi . ../lib/iptb-lib.sh test_cmp_repeat_10_sec() { - for i in $(test_seq 1 100) - do - test_cmp "$1" "$2" >/dev/null && return - go-sleep 100ms - done - test_cmp "$1" "$2" + for i in $(test_seq 1 100) + do + test_cmp "$1" "$2" >/dev/null && return + go-sleep 100ms + done + test_cmp "$1" "$2" } test_run_repeat_60_sec() { - for i in $(test_seq 1 600) - do - (test_eval_ "$1") && return - go-sleep 100ms - done - return 1 # failed + for i in $(test_seq 1 600) + do + (test_eval_ "$1") && return + go-sleep 100ms + done + return 1 # failed } test_wait_output_n_lines_60_sec() { - for i in $(test_seq 1 600) - do - test $(cat "$1" | wc -l | tr -d " ") -ge $2 && return - go-sleep 100ms - done - actual=$(cat "$1" | wc -l | tr -d " ") - test_fsh "expected $2 lines of output. got $actual" + for i in $(test_seq 1 600) + do + test $(cat "$1" | wc -l | tr -d " ") -ge $2 && return + go-sleep 100ms + done + actual=$(cat "$1" | wc -l | tr -d " ") + test_fsh "expected $2 lines of output. got $actual" } test_wait_open_tcp_port_10_sec() { - for i in $(test_seq 1 100) - do - # this is not a perfect check, but it's portable. - # cant count on ss. not installed everywhere. - # cant count on netstat using : or . as port delim. differ across platforms. - echo $(netstat -aln | egrep "^tcp.*LISTEN" | egrep "[.:]$1" | wc -l) -gt 0 - if [ $(netstat -aln | egrep "^tcp.*LISTEN" | egrep "[.:]$1" | wc -l) -gt 0 ]; then - return 0 - fi - go-sleep 100ms - done - return 1 + for i in $(test_seq 1 100) + do + # this is not a perfect check, but it's portable. + # cant count on ss. not installed everywhere. + # cant count on netstat using : or . as port delim. differ across platforms. + echo $(netstat -aln | egrep "^tcp.*LISTEN" | egrep "[.:]$1" | wc -l) -gt 0 + if [ $(netstat -aln | egrep "^tcp.*LISTEN" | egrep "[.:]$1" | wc -l) -gt 0 ]; then + return 0 + fi + go-sleep 100ms + done + return 1 } @@ -114,271 +114,271 @@ test_wait_open_tcp_port_10_sec() { # was setting really weird things and am not sure why. test_config_set() { - # grab flags (like --bool in "ipfs config --bool") - test_cfg_flags="" # unset in case. - test "$#" = 3 && { test_cfg_flags=$1; shift; } + # grab flags (like --bool in "ipfs config --bool") + test_cfg_flags="" # unset in case. + test "$#" = 3 && { test_cfg_flags=$1; shift; } - test_cfg_key=$1 - test_cfg_val=$2 + test_cfg_key=$1 + test_cfg_val=$2 - # when verbose, tell the user what config values are being set - test_cfg_cmd="ipfs config $test_cfg_flags \"$test_cfg_key\" \"$test_cfg_val\"" - test "$TEST_VERBOSE" = 1 && echo "$test_cfg_cmd" + # when verbose, tell the user what config values are being set + test_cfg_cmd="ipfs config $test_cfg_flags \"$test_cfg_key\" \"$test_cfg_val\"" + test "$TEST_VERBOSE" = 1 && echo "$test_cfg_cmd" - # ok try setting the config key/val pair. - ipfs config $test_cfg_flags "$test_cfg_key" "$test_cfg_val" - echo "$test_cfg_val" >cfg_set_expected - ipfs config "$test_cfg_key" >cfg_set_actual - test_cmp cfg_set_expected cfg_set_actual + # ok try setting the config key/val pair. + ipfs config $test_cfg_flags "$test_cfg_key" "$test_cfg_val" + echo "$test_cfg_val" >cfg_set_expected + ipfs config "$test_cfg_key" >cfg_set_actual + test_cmp cfg_set_expected cfg_set_actual } test_init_ipfs() { - # we set the Addresses.API config variable. - # the cli client knows to use it, so only need to set. - # todo: in the future, use env? + # we set the Addresses.API config variable. + # the cli client knows to use it, so only need to set. + # todo: in the future, use env? - test_expect_success "ipfs init succeeds" ' - export IPFS_PATH="$(pwd)/.ipfs" && - ipfs init --profile=test -b=1024 > /dev/null - ' + test_expect_success "ipfs init succeeds" ' + export IPFS_PATH="$(pwd)/.ipfs" && + ipfs init --profile=test -b=1024 > /dev/null + ' - test_expect_success "prepare config -- mounting" ' - mkdir mountdir ipfs ipns && - test_config_set Mounts.IPFS "$(pwd)/ipfs" && - test_config_set Mounts.IPNS "$(pwd)/ipns" || - test_fsh cat "\"$IPFS_PATH/config\"" - ' + test_expect_success "prepare config -- mounting" ' + mkdir mountdir ipfs ipns && + test_config_set Mounts.IPFS "$(pwd)/ipfs" && + test_config_set Mounts.IPNS "$(pwd)/ipns" || + test_fsh cat "\"$IPFS_PATH/config\"" + ' } test_config_ipfs_gateway_writable() { - test_expect_success "prepare config -- gateway writable" ' - test_config_set --bool Gateway.Writable true || - test_fsh cat "\"$IPFS_PATH/config\"" - ' + test_expect_success "prepare config -- gateway writable" ' + test_config_set --bool Gateway.Writable true || + test_fsh cat "\"$IPFS_PATH/config\"" + ' } test_wait_for_file() { - loops=$1 - delay=$2 - file=$3 - fwaitc=0 - while ! test -f "$file" - do - if test $fwaitc -ge $loops - then - echo "Error: timed out waiting for file: $file" - return 1 - fi - - go-sleep $delay - fwaitc=`expr $fwaitc + 1` - done + loops=$1 + delay=$2 + file=$3 + fwaitc=0 + while ! test -f "$file" + do + if test $fwaitc -ge $loops + then + echo "Error: timed out waiting for file: $file" + return 1 + fi + + go-sleep $delay + fwaitc=`expr $fwaitc + 1` + done } test_set_address_vars() { - daemon_output="$1" - - test_expect_success "set up address variables" ' - API_MADDR=$(cat "$IPFS_PATH/api") && - API_ADDR=$(convert_tcp_maddr $API_MADDR) && - API_PORT=$(port_from_maddr $API_MADDR) && - - GWAY_MADDR=$(sed -n "s/^Gateway (.*) server listening on //p" "$daemon_output") && - GWAY_ADDR=$(convert_tcp_maddr $GWAY_MADDR) && - GWAY_PORT=$(port_from_maddr $GWAY_MADDR) - ' - - if ipfs swarm addrs local >/dev/null 2>&1; then - test_expect_success "set swarm address vars" ' - ipfs swarm addrs local > addrs_out && - SWARM_MADDR=$(grep "127.0.0.1" addrs_out) && - SWARM_PORT=$(port_from_maddr $SWARM_MADDR) - ' - fi + daemon_output="$1" + + test_expect_success "set up address variables" ' + API_MADDR=$(cat "$IPFS_PATH/api") && + API_ADDR=$(convert_tcp_maddr $API_MADDR) && + API_PORT=$(port_from_maddr $API_MADDR) && + + GWAY_MADDR=$(sed -n "s/^Gateway (.*) server listening on //p" "$daemon_output") && + GWAY_ADDR=$(convert_tcp_maddr $GWAY_MADDR) && + GWAY_PORT=$(port_from_maddr $GWAY_MADDR) + ' + + if ipfs swarm addrs local >/dev/null 2>&1; then + test_expect_success "set swarm address vars" ' + ipfs swarm addrs local > addrs_out && + SWARM_MADDR=$(grep "127.0.0.1" addrs_out) && + SWARM_PORT=$(port_from_maddr $SWARM_MADDR) + ' + fi } test_launch_ipfs_daemon() { - args="$@" + args="$@" - test "$TEST_ULIMIT_PRESET" != 1 && ulimit -n 2048 + test "$TEST_ULIMIT_PRESET" != 1 && ulimit -n 2048 - test_expect_success "'ipfs daemon' succeeds" ' - ipfs daemon $args >actual_daemon 2>daemon_err & - ' + test_expect_success "'ipfs daemon' succeeds" ' + ipfs daemon $args >actual_daemon 2>daemon_err & + ' - # wait for api file to show up - test_expect_success "api file shows up" ' - test_wait_for_file 20 100ms "$IPFS_PATH/api" - ' + # wait for api file to show up + test_expect_success "api file shows up" ' + test_wait_for_file 20 100ms "$IPFS_PATH/api" + ' - test_set_address_vars actual_daemon + test_set_address_vars actual_daemon - # we say the daemon is ready when the API server is ready. - test_expect_success "'ipfs daemon' is ready" ' - IPFS_PID=$! && - pollEndpoint -ep=/version -host=$API_MADDR -v -tout=1s -tries=60 2>poll_apierr > poll_apiout || - test_fsh cat actual_daemon || test_fsh cat daemon_err || test_fsh cat poll_apierr || test_fsh cat poll_apiout - ' + # we say the daemon is ready when the API server is ready. + test_expect_success "'ipfs daemon' is ready" ' + IPFS_PID=$! && + pollEndpoint -ep=/version -host=$API_MADDR -v -tout=1s -tries=60 2>poll_apierr > poll_apiout || + test_fsh cat actual_daemon || test_fsh cat daemon_err || test_fsh cat poll_apierr || test_fsh cat poll_apiout + ' } do_umount() { - if [ "$(uname -s)" = "Linux" ]; then - fusermount -u "$1" - else - umount "$1" - fi + if [ "$(uname -s)" = "Linux" ]; then + fusermount -u "$1" + else + umount "$1" + fi } test_mount_ipfs() { - # make sure stuff is unmounted first. - test_expect_success FUSE "'ipfs mount' succeeds" ' - do_umount "$(pwd)/ipfs" || true && - do_umount "$(pwd)/ipns" || true && - ipfs mount >actual - ' + # make sure stuff is unmounted first. + test_expect_success FUSE "'ipfs mount' succeeds" ' + do_umount "$(pwd)/ipfs" || true && + do_umount "$(pwd)/ipns" || true && + ipfs mount >actual + ' - test_expect_success FUSE "'ipfs mount' output looks good" ' - echo "IPFS mounted at: $(pwd)/ipfs" >expected && - echo "IPNS mounted at: $(pwd)/ipns" >>expected && - test_cmp expected actual - ' + test_expect_success FUSE "'ipfs mount' output looks good" ' + echo "IPFS mounted at: $(pwd)/ipfs" >expected && + echo "IPNS mounted at: $(pwd)/ipns" >>expected && + test_cmp expected actual + ' } test_launch_ipfs_daemon_and_mount() { - test_init_ipfs - test_launch_ipfs_daemon - test_mount_ipfs + test_init_ipfs + test_launch_ipfs_daemon + test_mount_ipfs } test_kill_repeat_10_sec() { - # try to shut down once + wait for graceful exit - kill $1 - for i in $(test_seq 1 100) - do - go-sleep 100ms - ! kill -0 $1 2>/dev/null && return - done - - # if not, try once more, which will skip graceful exit - kill $1 - go-sleep 1s - ! kill -0 $1 2>/dev/null && return - - # ok, no hope. kill it to prevent it messing with other tests - kill -9 $1 2>/dev/null - return 1 + # try to shut down once + wait for graceful exit + kill $1 + for i in $(test_seq 1 100) + do + go-sleep 100ms + ! kill -0 $1 2>/dev/null && return + done + + # if not, try once more, which will skip graceful exit + kill $1 + go-sleep 1s + ! kill -0 $1 2>/dev/null && return + + # ok, no hope. kill it to prevent it messing with other tests + kill -9 $1 2>/dev/null + return 1 } test_kill_ipfs_daemon() { - test_expect_success "'ipfs daemon' is still running" ' - kill -0 $IPFS_PID - ' + test_expect_success "'ipfs daemon' is still running" ' + kill -0 $IPFS_PID + ' - test_expect_success "'ipfs daemon' can be killed" ' - test_kill_repeat_10_sec $IPFS_PID - ' + test_expect_success "'ipfs daemon' can be killed" ' + test_kill_repeat_10_sec $IPFS_PID + ' } test_curl_resp_http_code() { - curl -I "$1" >curl_output || { - echo "curl error with url: '$1'" - echo "curl output was:" - cat curl_output - return 1 - } - shift && - RESP=$(head -1 curl_output) && - while test "$#" -gt 0 - do - expr "$RESP" : "$1" >/dev/null && return - shift - done - echo "curl response didn't match!" - echo "curl response was: '$RESP'" - echo "curl output was:" - cat curl_output - return 1 + curl -I "$1" >curl_output || { + echo "curl error with url: '$1'" + echo "curl output was:" + cat curl_output + return 1 + } + shift && + RESP=$(head -1 curl_output) && + while test "$#" -gt 0 + do + expr "$RESP" : "$1" >/dev/null && return + shift + done + echo "curl response didn't match!" + echo "curl response was: '$RESP'" + echo "curl output was:" + cat curl_output + return 1 } test_must_be_empty() { - if test -s "$1" - then - echo "'$1' is not empty, it contains:" - cat "$1" - return 1 - fi + if test -s "$1" + then + echo "'$1' is not empty, it contains:" + cat "$1" + return 1 + fi } test_should_contain() { - test "$#" = 2 || error "bug in the test script: not 2 parameters to test_should_contain" - if ! grep -q "$1" "$2" - then - echo "'$2' does not contain '$1', it contains:" - cat "$2" - return 1 - fi + test "$#" = 2 || error "bug in the test script: not 2 parameters to test_should_contain" + if ! grep -q "$1" "$2" + then + echo "'$2' does not contain '$1', it contains:" + cat "$2" + return 1 + fi } test_str_contains() { - find=$1 - shift - echo "$@" | egrep "\b$find\b" >/dev/null + find=$1 + shift + echo "$@" | egrep "\b$find\b" >/dev/null } disk_usage() { - # normalize du across systems - case $(uname -s) in - Linux) - DU="du -sb" - M=1 - ;; - FreeBSD) - DU="du -s -A -B 1" - M=512 - ;; - Darwin | DragonFly | *) - DU="du -s" - M=512 - ;; - esac - expr $($DU "$1" | awk "{print \$1}") "*" "$M" + # normalize du across systems + case $(uname -s) in + Linux) + DU="du -sb" + M=1 + ;; + FreeBSD) + DU="du -s -A -B 1" + M=512 + ;; + Darwin | DragonFly | *) + DU="du -s" + M=512 + ;; + esac + expr $($DU "$1" | awk "{print \$1}") "*" "$M" } # output a file's permission in human readable format generic_stat() { - # normalize stat across systems - case $(uname -s) in - Linux) - _STAT="stat -c %A" - ;; - FreeBSD | Darwin | DragonFly) - _STAT="stat -f %Sp" - ;; - esac - $_STAT "$1" || echo "failed" # Avoid returning nothing. + # normalize stat across systems + case $(uname -s) in + Linux) + _STAT="stat -c %A" + ;; + FreeBSD | Darwin | DragonFly) + _STAT="stat -f %Sp" + ;; + esac + $_STAT "$1" || echo "failed" # Avoid returning nothing. } 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 - } + peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") && + test "$peeridlen" = "46" || { + echo "Bad peerid '$1' with len '$peeridlen'" + return 1 + } } convert_tcp_maddr() { - echo $1 | awk -F'/' '{ printf "%s:%s", $3, $5 }' + echo $1 | awk -F'/' '{ printf "%s:%s", $3, $5 }' } port_from_maddr() { - echo $1 | awk -F'/' '{ print $NF }' + echo $1 | awk -F'/' '{ print $NF }' } diff --git a/test/sharness/t0010-basic-commands.sh b/test/sharness/t0010-basic-commands.sh index cbc2dfc7453..63c482aba98 100755 --- a/test/sharness/t0010-basic-commands.sh +++ b/test/sharness/t0010-basic-commands.sh @@ -9,107 +9,107 @@ test_description="Test installation and some basic commands" . lib/test-lib.sh test_expect_success "current dir is writable" ' - echo "It works!" >test.txt + echo "It works!" >test.txt ' test_expect_success "ipfs version succeeds" ' - ipfs version >version.txt + ipfs version >version.txt ' test_expect_success "ipfs --version success" ' - ipfs --version + ipfs --version ' test_expect_success "ipfs version output looks good" ' - egrep "^ipfs version [0-9]+\.[0-9]+\.[0-9]" version.txt >/dev/null || - test_fsh cat version.txt + egrep "^ipfs version [0-9]+\.[0-9]+\.[0-9]" version.txt >/dev/null || + test_fsh cat version.txt ' test_expect_success "ipfs versions matches ipfs --version" ' - ipfs version > version.txt && - ipfs --version > version2.txt && - diff version2.txt version.txt || - test_fsh ipfs --version + ipfs version > version.txt && + ipfs --version > version2.txt && + diff version2.txt version.txt || + test_fsh ipfs --version ' test_expect_success "ipfs version --all has all required fields" ' - ipfs version --all > version_all.txt && - grep "go-ipfs version" version_all.txt && - grep "Repo version" version_all.txt && - grep "System version" version_all.txt && - grep "Golang version" version_all.txt + ipfs version --all > version_all.txt && + grep "go-ipfs version" version_all.txt && + grep "Repo version" version_all.txt && + grep "System version" version_all.txt && + grep "Golang version" version_all.txt ' test_expect_success "ipfs help succeeds" ' - ipfs help >help.txt + ipfs help >help.txt ' test_expect_success "ipfs help output looks good" ' - egrep -i "^Usage" help.txt >/dev/null && - egrep "ipfs " help.txt >/dev/null || - test_fsh cat help.txt + egrep -i "^Usage" help.txt >/dev/null && + egrep "ipfs " help.txt >/dev/null || + test_fsh cat help.txt ' test_expect_success "'ipfs commands' succeeds" ' - ipfs commands >commands.txt + ipfs commands >commands.txt ' test_expect_success "'ipfs commands' output looks good" ' - grep "ipfs add" commands.txt && - grep "ipfs daemon" commands.txt && - grep "ipfs update" commands.txt + grep "ipfs add" commands.txt && + grep "ipfs daemon" commands.txt && + grep "ipfs update" commands.txt ' test_expect_success "All commands accept --help" ' - echo 0 > fail - while read -r cmd - do - $cmd --help /dev/null || - { echo $cmd doesnt accept --help; echo 1 > fail; } - done fail + while read -r cmd + do + $cmd --help /dev/null || + { echo $cmd doesnt accept --help; echo 1 > fail; } + done fail - cut -d" " -f 2 commands.txt | grep -v ipfs | sort -u | \ - while read cmd - do - grep " $cmd" help.txt > /dev/null || - { echo missing $cmd from helptext; echo 1 > fail; } - done - - if [ $(cat fail) = 1 ]; then - return 1 - fi + echo 0 > fail + cut -d" " -f 2 commands.txt | grep -v ipfs | sort -u | \ + while read cmd + do + grep " $cmd" help.txt > /dev/null || + { echo missing $cmd from helptext; echo 1 > fail; } + done + + if [ $(cat fail) = 1 ]; then + return 1 + fi ' test_expect_failure "All ipfs commands docs are 80 columns or less" ' - echo 0 > fail - while read cmd - do - LENGTH="$($cmd --help | awk "{ print length }" | sort -nr | head -1)" - [ $LENGTH -gt 80 ] && - { echo "$cmd" help text is longer than 79 chars "($LENGTH)"; echo 1 > fail; } - done fail + while read cmd + do + LENGTH="$($cmd --help | awk "{ print length }" | sort -nr | head -1)" + [ $LENGTH -gt 80 ] && + { echo "$cmd" help text is longer than 79 chars "($LENGTH)"; echo 1 > fail; } + done commands.txt + ipfs commands --flags >commands.txt ' test_expect_success "'ipfs commands --flags' output looks good" ' - grep "ipfs pin add --recursive / ipfs pin add -r" commands.txt && - grep "ipfs id --format / ipfs id -f" commands.txt && - grep "ipfs repo gc --quiet / ipfs repo gc -q" commands.txt + grep "ipfs pin add --recursive / ipfs pin add -r" commands.txt && + grep "ipfs id --format / ipfs id -f" commands.txt && + grep "ipfs repo gc --quiet / ipfs repo gc -q" commands.txt ' diff --git a/test/sharness/t0015-basic-sh-functions.sh b/test/sharness/t0015-basic-sh-functions.sh index 202cfca58c9..2d4d40b3f67 100755 --- a/test/sharness/t0015-basic-sh-functions.sh +++ b/test/sharness/t0015-basic-sh-functions.sh @@ -9,12 +9,12 @@ test_description="Test some basic shell functions" . lib/test-lib.sh test_expect_success "shellquote works with simple stuff" ' - var=$(shellquote one two) + var=$(shellquote one two) ' test_expect_success "shellquote output looks good" ' - test "$var" = "'\''one'\'' '\''two'\''" || - test_fsh echo "var is \"$var\" instead of \"'\''one'\'' '\''two'\''\"" + test "$var" = "'\''one'\'' '\''two'\''" || + test_fsh echo "var is \"$var\" instead of \"'\''one'\'' '\''two'\''\"" ' # The following two printf statements are equivalent: @@ -24,24 +24,24 @@ test_expect_success "shellquote output looks good" ' # We use the second one to simplify quoting. test_expect_success "shellquote works with complex printf" ' - eval "$(shellquote printf "\047\042\146\157\157\134\012\142\141\162\012")" >actual + eval "$(shellquote printf "\047\042\146\157\157\134\012\142\141\162\012")" >actual ' test_expect_success "shellquote output looks good" ' - printf "\047\042\146\157\157\134\012\142\141\162\012" >expected && - test_cmp expected actual + printf "\047\042\146\157\157\134\012\142\141\162\012" >expected && + test_cmp expected actual ' test_expect_success "shellquote works with many different bytes" ' - bytes_sans_NUL=$( - printf "\001\002\003\004\005\006\007\010\011\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044%%\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377" - ) && - eval "$(shellquote printf "%s" "$bytes_sans_NUL")" >actual + bytes_sans_NUL=$( + printf "\001\002\003\004\005\006\007\010\011\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044%%\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377" + ) && + eval "$(shellquote printf "%s" "$bytes_sans_NUL")" >actual ' test_expect_success "shellquote output looks good" ' - printf "%s" "$bytes_sans_NUL" >expected && - test_cmp expected actual + printf "%s" "$bytes_sans_NUL" >expected && + test_cmp expected actual ' test_done diff --git a/test/sharness/t0018-indent.sh b/test/sharness/t0018-indent.sh index 6ba37d045e3..ae417c6f6e4 100755 --- a/test/sharness/t0018-indent.sh +++ b/test/sharness/t0018-indent.sh @@ -5,9 +5,9 @@ test_description="Test sharness test indent" . lib/test-lib.sh for file in $(find .. -name 't*.sh' -type f); do - test_expect_success "indent in $file is not using spaces" ' - test_must_fail grep -P "^\\t* " $file - ' + test_expect_success "indent in $file is not using tabs" ' + test_must_fail grep -P "^ *\t" $file + ' done test_done diff --git a/test/sharness/t0020-init.sh b/test/sharness/t0020-init.sh index c8f8fd6b795..697203a9f02 100755 --- a/test/sharness/t0020-init.sh +++ b/test/sharness/t0020-init.sh @@ -10,161 +10,161 @@ test_description="Test init command" # test that ipfs fails to init if IPFS_PATH isnt writeable test_expect_success "create dir and change perms succeeds" ' - export IPFS_PATH="$(pwd)/.badipfs" && - mkdir "$IPFS_PATH" && - chmod 000 "$IPFS_PATH" + export IPFS_PATH="$(pwd)/.badipfs" && + mkdir "$IPFS_PATH" && + chmod 000 "$IPFS_PATH" ' test_expect_success "ipfs init fails" ' - test_must_fail ipfs init 2> init_fail_out + test_must_fail ipfs init 2> init_fail_out ' # Under Windows/Cygwin the error message is different, # so we use the STD_ERR_MSG prereq. if test_have_prereq STD_ERR_MSG; then - init_err_msg="Error: failed to take lock at $IPFS_PATH: permission denied" + init_err_msg="Error: failed to take lock at $IPFS_PATH: permission denied" else - init_err_msg="Error: mkdir $IPFS_PATH: The system cannot find the path specified." + init_err_msg="Error: mkdir $IPFS_PATH: The system cannot find the path specified." fi test_expect_success "ipfs init output looks good" ' - echo "$init_err_msg" >init_fail_exp && - test_cmp init_fail_exp init_fail_out + echo "$init_err_msg" >init_fail_exp && + test_cmp init_fail_exp init_fail_out ' test_expect_success "cleanup dir with bad perms" ' - chmod 775 "$IPFS_PATH" && - rmdir "$IPFS_PATH" + chmod 775 "$IPFS_PATH" && + rmdir "$IPFS_PATH" ' # test no repo error message # this applies to `ipfs add sth`, `ipfs refs ` test_expect_success "ipfs cat fails" ' - export IPFS_PATH="$(pwd)/.ipfs" && - test_must_fail ipfs cat Qmaa4Rw81a3a1VEx4LxB7HADUAXvZFhCoRdBzsMZyZmqHD 2> cat_fail_out + export IPFS_PATH="$(pwd)/.ipfs" && + test_must_fail ipfs cat Qmaa4Rw81a3a1VEx4LxB7HADUAXvZFhCoRdBzsMZyZmqHD 2> cat_fail_out ' test_expect_success "ipfs cat no repo message looks good" ' - echo "Error: no IPFS repo found in $IPFS_PATH." > cat_fail_exp && - echo "please run: 'ipfs init'" >> cat_fail_exp && - test_path_cmp cat_fail_exp cat_fail_out + echo "Error: no IPFS repo found in $IPFS_PATH." > cat_fail_exp && + echo "please run: 'ipfs init'" >> cat_fail_exp && + test_path_cmp cat_fail_exp cat_fail_out ' # test that init succeeds test_expect_success "ipfs init succeeds" ' - export IPFS_PATH="$(pwd)/.ipfs" && - echo "IPFS_PATH: \"$IPFS_PATH\"" && - BITS="2048" && - ipfs init --bits="$BITS" >actual_init || - test_fsh cat actual_init + export IPFS_PATH="$(pwd)/.ipfs" && + echo "IPFS_PATH: \"$IPFS_PATH\"" && + BITS="2048" && + ipfs init --bits="$BITS" >actual_init || + test_fsh cat actual_init ' test_expect_success ".ipfs/ has been created" ' - test -d ".ipfs" && - test -f ".ipfs/config" && - test -d ".ipfs/datastore" && - test -d ".ipfs/blocks" && - test ! -f ._check_writeable || - test_fsh ls -al .ipfs + test -d ".ipfs" && + test -f ".ipfs/config" && + test -d ".ipfs/datastore" && + test -d ".ipfs/blocks" && + test ! -f ._check_writeable || + test_fsh ls -al .ipfs ' test_expect_success "ipfs config succeeds" ' - echo /ipfs >expected_config && - ipfs config Mounts.IPFS >actual_config && - test_cmp expected_config actual_config + echo /ipfs >expected_config && + ipfs config Mounts.IPFS >actual_config && + test_cmp expected_config actual_config ' test_expect_success "ipfs peer id looks good" ' - PEERID=$(ipfs config Identity.PeerID) && - test_check_peerid "$PEERID" + PEERID=$(ipfs config Identity.PeerID) && + test_check_peerid "$PEERID" ' test_expect_success "ipfs init output looks good" ' - STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" && - echo "initializing IPFS node at $IPFS_PATH" >expected && - echo "generating $BITS-bit RSA keypair...done" >>expected && - echo "peer identity: $PEERID" >>expected && - echo "to get started, enter:" >>expected && - printf "\\n\\t$STARTFILE\\n\\n" >>expected && - test_cmp expected actual_init + STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" && + echo "initializing IPFS node at $IPFS_PATH" >expected && + echo "generating $BITS-bit RSA keypair...done" >>expected && + echo "peer identity: $PEERID" >>expected && + echo "to get started, enter:" >>expected && + printf "\\n\\t$STARTFILE\\n\\n" >>expected && + test_cmp expected actual_init ' test_expect_success "Welcome readme exists" ' - ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme + ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme ' test_expect_success "clean up ipfs dir" ' - rm -rf "$IPFS_PATH" + rm -rf "$IPFS_PATH" ' test_expect_success "'ipfs init --empty-repo' succeeds" ' - BITS="1024" && - ipfs init --bits="$BITS" --empty-repo >actual_init + BITS="1024" && + ipfs init --bits="$BITS" --empty-repo >actual_init ' test_expect_success "ipfs peer id looks good" ' - PEERID=$(ipfs config Identity.PeerID) && - test_check_peerid "$PEERID" + PEERID=$(ipfs config Identity.PeerID) && + test_check_peerid "$PEERID" ' test_expect_success "'ipfs init --empty-repo' output looks good" ' - echo "initializing IPFS node at $IPFS_PATH" >expected && - echo "generating $BITS-bit RSA keypair...done" >>expected && - echo "peer identity: $PEERID" >>expected && - test_cmp expected actual_init + echo "initializing IPFS node at $IPFS_PATH" >expected && + echo "generating $BITS-bit RSA keypair...done" >>expected && + echo "peer identity: $PEERID" >>expected && + test_cmp expected actual_init ' test_expect_success "Welcome readme doesn't exists" ' - test_must_fail ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme + test_must_fail ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme ' test_expect_success "ipfs id agent string contains correct version" ' - ipfs id -f "" | grep $(ipfs version -n) + ipfs id -f "" | grep $(ipfs version -n) ' test_expect_success "clean up ipfs dir" ' - rm -rf "$IPFS_PATH" + rm -rf "$IPFS_PATH" ' # test init profiles test_expect_success "'ipfs init --profile' with invalid profile fails" ' - BITS="1024" && - test_must_fail ipfs init --bits="$BITS" --profile=nonexistent_profile 2> invalid_profile_out - EXPECT="Error: invalid configuration profile: nonexistent_profile" && - grep "$EXPECT" invalid_profile_out + BITS="1024" && + test_must_fail ipfs init --bits="$BITS" --profile=nonexistent_profile 2> invalid_profile_out + EXPECT="Error: invalid configuration profile: nonexistent_profile" && + grep "$EXPECT" invalid_profile_out ' test_expect_success "'ipfs init --profile' succeeds" ' - BITS="1024" && - ipfs init --bits="$BITS" --profile=server + BITS="1024" && + ipfs init --bits="$BITS" --profile=server ' test_expect_success "'ipfs config Swarm.AddrFilters' looks good" ' - ipfs config Swarm.AddrFilters > actual_config && - test $(cat actual_config | wc -l) = 17 + ipfs config Swarm.AddrFilters > actual_config && + test $(cat actual_config | wc -l) = 17 ' test_expect_success "clean up ipfs dir" ' - rm -rf "$IPFS_PATH" + rm -rf "$IPFS_PATH" ' test_expect_success "'ipfs init --profile=test' succeeds" ' - BITS="1024" && - ipfs init --bits="$BITS" --profile=test + BITS="1024" && + ipfs init --bits="$BITS" --profile=test ' test_expect_success "'ipfs config Bootstrap' looks good" ' - ipfs config Bootstrap > actual_config && - test $(cat actual_config) = "[]" + ipfs config Bootstrap > actual_config && + test $(cat actual_config) = "[]" ' test_expect_success "'ipfs config Addresses.API' looks good" ' - ipfs config Addresses.API > actual_config && - test $(cat actual_config) = "/ip4/127.0.0.1/tcp/0" + ipfs config Addresses.API > actual_config && + test $(cat actual_config) = "/ip4/127.0.0.1/tcp/0" ' test_expect_success "clean up ipfs dir" ' - rm -rf "$IPFS_PATH" + rm -rf "$IPFS_PATH" ' test_init_ipfs @@ -172,9 +172,9 @@ test_init_ipfs test_launch_ipfs_daemon test_expect_success "ipfs init should not run while daemon is running" ' - test_must_fail ipfs init 2> daemon_running_err && - EXPECT="Error: ipfs daemon is running. please stop it to run this command" && - grep "$EXPECT" daemon_running_err + test_must_fail ipfs init 2> daemon_running_err && + EXPECT="Error: ipfs daemon is running. please stop it to run this command" && + grep "$EXPECT" daemon_running_err ' test_kill_ipfs_daemon diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index c5adc5ba9f7..b7b985a8963 100755 --- a/test/sharness/t0021-config.sh +++ b/test/sharness/t0021-config.sh @@ -7,33 +7,33 @@ test_description="Test config command" # we use a function so that we can run it both offline + online test_config_cmd_set() { - # flags (like --bool in "ipfs config --bool") - cfg_flags="" # unset in case. - test "$#" = 3 && { cfg_flags=$1; shift; } - - cfg_key=$1 - cfg_val=$2 - test_expect_success "ipfs config succeeds" ' - ipfs config $cfg_flags "$cfg_key" "$cfg_val" - ' - - test_expect_success "ipfs config output looks good" ' - echo "$cfg_val" >expected && - ipfs config "$cfg_key" >actual && - test_cmp expected actual - ' - - # also test our lib function. it should work too. - cfg_key="Lib.$cfg_key" - test_expect_success "test_config_set succeeds" ' - test_config_set $cfg_flags "$cfg_key" "$cfg_val" - ' - - test_expect_success "test_config_set value looks good" ' - echo "$cfg_val" >expected && - ipfs config "$cfg_key" >actual && - test_cmp expected actual - ' + # flags (like --bool in "ipfs config --bool") + cfg_flags="" # unset in case. + test "$#" = 3 && { cfg_flags=$1; shift; } + + cfg_key=$1 + cfg_val=$2 + test_expect_success "ipfs config succeeds" ' + ipfs config $cfg_flags "$cfg_key" "$cfg_val" + ' + + test_expect_success "ipfs config output looks good" ' + echo "$cfg_val" >expected && + ipfs config "$cfg_key" >actual && + test_cmp expected actual + ' + + # also test our lib function. it should work too. + cfg_key="Lib.$cfg_key" + test_expect_success "test_config_set succeeds" ' + test_config_set $cfg_flags "$cfg_key" "$cfg_val" + ' + + test_expect_success "test_config_set value looks good" ' + echo "$cfg_val" >expected && + ipfs config "$cfg_key" >actual && + test_cmp expected actual + ' } # this is a bit brittle. the problem is we need to test @@ -41,116 +41,116 @@ test_config_cmd_set() { # (i.e. just setting 'ipfs config --json foo "[1, 2, 3]"') may # set it as astring instead of proper json. We leverage the # unmarshalling that has to happen. -CONFIG_SET_JSON_TEST=$(echo '{ - "MDNS": { - "Enabled": true, - "Interval": 10 - } -}' | sed 's/\t/ /g') +CONFIG_SET_JSON_TEST='{ + "MDNS": { + "Enabled": true, + "Interval": 10 + } +}' test_config_cmd() { - test_config_cmd_set "beep" "boop" - test_config_cmd_set "beep1" "boop2" - test_config_cmd_set "beep1" "boop2" - test_config_cmd_set "--bool" "beep2" "true" - test_config_cmd_set "--bool" "beep2" "false" - test_config_cmd_set "--json" "beep3" "true" - test_config_cmd_set "--json" "beep3" "false" - test_config_cmd_set "--json" "Discovery" "$CONFIG_SET_JSON_TEST" - test_config_cmd_set "--json" "deep-not-defined.prop" "true" - test_config_cmd_set "--json" "deep-null" "null" - test_config_cmd_set "--json" "deep-null.prop" "true" - - test_expect_success "'ipfs config show' works" ' - ipfs config show >actual - ' - - test_expect_success "'ipfs config show' output looks good" ' - grep "\"beep\": \"boop\"," actual && - grep "\"beep1\": \"boop2\"," actual && - grep "\"beep2\": false," actual && - grep "\"beep3\": false," actual - ' - - test_expect_success "setup for config replace test" ' - cp "$IPFS_PATH/config" newconfig.json && - sed -i"~" -e /PrivKey/d -e s/10GB/11GB/ newconfig.json && - sed -i"~" -e '"'"'/PeerID/ {'"'"' -e '"'"' s/,$// '"'"' -e '"'"' } '"'"' newconfig.json - ' - - test_expect_success "run 'ipfs config replace'" ' - ipfs config replace - < newconfig.json - ' - - test_expect_success "check resulting config after 'ipfs config replace'" ' - sed -e /PrivKey/d "$IPFS_PATH/config" > replconfig.json && - sed -i"~" -e '"'"'/PeerID/ {'"'"' -e '"'"' s/,$// '"'"' -e '"'"' } '"'"' replconfig.json && - test_cmp replconfig.json newconfig.json - ' - - # SECURITY - # Those tests are here to prevent exposing the PrivKey on the network - - test_expect_success "'ipfs config Identity' fails" ' - test_expect_code 1 ipfs config Identity 2> ident_out - ' - - test_expect_success "output looks good" ' - echo "Error: cannot show or change private key through API" > ident_exp && - test_cmp ident_exp ident_out - ' - - test_expect_success "'ipfs config Identity.PrivKey' fails" ' - test_expect_code 1 ipfs config Identity.PrivKey 2> ident_out - ' - - test_expect_success "output looks good" ' - test_cmp ident_exp ident_out - ' - - test_expect_success "lower cased PrivKey" ' - sed -i"~" -e '\''s/PrivKey/privkey/'\'' "$IPFS_PATH/config" && - test_expect_code 1 ipfs config Identity.privkey 2> ident_out - ' - - test_expect_success "output looks good" ' - test_cmp ident_exp ident_out - ' - - test_expect_success "fix it back" ' - sed -i"~" -e '\''s/privkey/PrivKey/'\'' "$IPFS_PATH/config" - ' - - test_expect_success "'ipfs config show' doesn't include privkey" ' - ipfs config show > show_config && - test_expect_code 1 grep PrivKey show_config - ' - - test_expect_success "'ipfs config replace' injects privkey back" ' - ipfs config replace show_config && - grep "\"PrivKey\":" "$IPFS_PATH/config" | grep -e ": \".\+\"" >/dev/null - ' - - test_expect_success "'ipfs config replace' with privkey errors out" ' - cp "$IPFS_PATH/config" real_config && - test_expect_code 1 ipfs config replace - < real_config 2> replace_out - ' - - test_expect_success "output looks good" ' - echo "Error: setting private key with API is not supported" > replace_expected - test_cmp replace_out replace_expected - ' - - test_expect_success "'ipfs config replace' with lower case privkey errors out" ' - cp "$IPFS_PATH/config" real_config && - sed -i -e '\''s/PrivKey/privkey/'\'' real_config && - test_expect_code 1 ipfs config replace - < real_config 2> replace_out - ' - - test_expect_success "output looks good" ' - echo "Error: setting private key with API is not supported" > replace_expected - test_cmp replace_out replace_expected - ' + test_config_cmd_set "beep" "boop" + test_config_cmd_set "beep1" "boop2" + test_config_cmd_set "beep1" "boop2" + test_config_cmd_set "--bool" "beep2" "true" + test_config_cmd_set "--bool" "beep2" "false" + test_config_cmd_set "--json" "beep3" "true" + test_config_cmd_set "--json" "beep3" "false" + test_config_cmd_set "--json" "Discovery" "$CONFIG_SET_JSON_TEST" + test_config_cmd_set "--json" "deep-not-defined.prop" "true" + test_config_cmd_set "--json" "deep-null" "null" + test_config_cmd_set "--json" "deep-null.prop" "true" + + test_expect_success "'ipfs config show' works" ' + ipfs config show >actual + ' + + test_expect_success "'ipfs config show' output looks good" ' + grep "\"beep\": \"boop\"," actual && + grep "\"beep1\": \"boop2\"," actual && + grep "\"beep2\": false," actual && + grep "\"beep3\": false," actual + ' + + test_expect_success "setup for config replace test" ' + cp "$IPFS_PATH/config" newconfig.json && + sed -i"~" -e /PrivKey/d -e s/10GB/11GB/ newconfig.json && + sed -i"~" -e '"'"'/PeerID/ {'"'"' -e '"'"' s/,$// '"'"' -e '"'"' } '"'"' newconfig.json + ' + + test_expect_success "run 'ipfs config replace'" ' + ipfs config replace - < newconfig.json + ' + + test_expect_success "check resulting config after 'ipfs config replace'" ' + sed -e /PrivKey/d "$IPFS_PATH/config" > replconfig.json && + sed -i"~" -e '"'"'/PeerID/ {'"'"' -e '"'"' s/,$// '"'"' -e '"'"' } '"'"' replconfig.json && + test_cmp replconfig.json newconfig.json + ' + + # SECURITY + # Those tests are here to prevent exposing the PrivKey on the network + + test_expect_success "'ipfs config Identity' fails" ' + test_expect_code 1 ipfs config Identity 2> ident_out + ' + + test_expect_success "output looks good" ' + echo "Error: cannot show or change private key through API" > ident_exp && + test_cmp ident_exp ident_out + ' + + test_expect_success "'ipfs config Identity.PrivKey' fails" ' + test_expect_code 1 ipfs config Identity.PrivKey 2> ident_out + ' + + test_expect_success "output looks good" ' + test_cmp ident_exp ident_out + ' + + test_expect_success "lower cased PrivKey" ' + sed -i"~" -e '\''s/PrivKey/privkey/'\'' "$IPFS_PATH/config" && + test_expect_code 1 ipfs config Identity.privkey 2> ident_out + ' + + test_expect_success "output looks good" ' + test_cmp ident_exp ident_out + ' + + test_expect_success "fix it back" ' + sed -i"~" -e '\''s/privkey/PrivKey/'\'' "$IPFS_PATH/config" + ' + + test_expect_success "'ipfs config show' doesn't include privkey" ' + ipfs config show > show_config && + test_expect_code 1 grep PrivKey show_config + ' + + test_expect_success "'ipfs config replace' injects privkey back" ' + ipfs config replace show_config && + grep "\"PrivKey\":" "$IPFS_PATH/config" | grep -e ": \".\+\"" >/dev/null + ' + + test_expect_success "'ipfs config replace' with privkey errors out" ' + cp "$IPFS_PATH/config" real_config && + test_expect_code 1 ipfs config replace - < real_config 2> replace_out + ' + + test_expect_success "output looks good" ' + echo "Error: setting private key with API is not supported" > replace_expected + test_cmp replace_out replace_expected + ' + + test_expect_success "'ipfs config replace' with lower case privkey errors out" ' + cp "$IPFS_PATH/config" real_config && + sed -i -e '\''s/PrivKey/privkey/'\'' real_config && + test_expect_code 1 ipfs config replace - < real_config 2> replace_out + ' + + test_expect_success "output looks good" ' + echo "Error: setting private key with API is not supported" > replace_expected + test_cmp replace_out replace_expected + ' } test_init_ipfs diff --git a/test/sharness/t0022-init-default.sh b/test/sharness/t0022-init-default.sh index 9b5039c81e0..2f23581ea31 100755 --- a/test/sharness/t0022-init-default.sh +++ b/test/sharness/t0022-init-default.sh @@ -13,39 +13,39 @@ cfg_val="/ip4/0.0.0.0/tcp/5001" # test that init succeeds test_expect_success "ipfs init succeeds" ' - export IPFS_PATH="$(pwd)/.ipfs" && - echo "IPFS_PATH: \"$IPFS_PATH\"" && - BITS="2048" && - ipfs init --bits="$BITS" >actual_init || - test_fsh cat actual_init + export IPFS_PATH="$(pwd)/.ipfs" && + echo "IPFS_PATH: \"$IPFS_PATH\"" && + BITS="2048" && + ipfs init --bits="$BITS" >actual_init || + test_fsh cat actual_init ' test_expect_success ".ipfs/config has been created" ' - test -f "$IPFS_PATH"/config || - test_fsh ls -al .ipfs + test -f "$IPFS_PATH"/config || + test_fsh ls -al .ipfs ' test_expect_success "ipfs config succeeds" ' - ipfs config $cfg_flags "$cfg_key" "$cfg_val" + ipfs config $cfg_flags "$cfg_key" "$cfg_val" ' test_expect_success "ipfs read config succeeds" ' - IPFS_DEFAULT_CONFIG=$(cat "$IPFS_PATH"/config) + IPFS_DEFAULT_CONFIG=$(cat "$IPFS_PATH"/config) ' test_expect_success "clean up ipfs dir" ' - rm -rf "$IPFS_PATH" + rm -rf "$IPFS_PATH" ' test_expect_success "ipfs init default config succeeds" ' - echo $IPFS_DEFAULT_CONFIG | ipfs init - >actual_init || - test_fsh cat actual_init + echo $IPFS_DEFAULT_CONFIG | ipfs init - >actual_init || + test_fsh cat actual_init ' test_expect_success "ipfs config output looks good" ' - echo "$cfg_val" >expected && - ipfs config "$cfg_key" >actual && - test_cmp expected actual + echo "$cfg_val" >expected && + ipfs config "$cfg_key" >actual && + test_cmp expected actual ' test_done diff --git a/test/sharness/t0023-shutdown.sh b/test/sharness/t0023-shutdown.sh index a50a2e43c04..5da66830640 100755 --- a/test/sharness/t0023-shutdown.sh +++ b/test/sharness/t0023-shutdown.sh @@ -13,28 +13,28 @@ test_init_ipfs test_launch_ipfs_daemon test_expect_success "shutdown succeeds" ' - ipfs shutdown + ipfs shutdown ' test_expect_success "daemon no longer running" ' - for i in $(test_seq 1 100) - do - go-sleep 100ms - ! kill -0 $IPFS_PID 2>/dev/null && return - done + for i in $(test_seq 1 100) + do + go-sleep 100ms + ! kill -0 $IPFS_PID 2>/dev/null && return + done ' test_launch_ipfs_daemon --offline test_expect_success "shutdown succeeds" ' - ipfs shutdown + ipfs shutdown ' test_expect_success "daemon no longer running" ' - for i in $(test_seq 1 100) - do - go-sleep 100ms - ! kill -0 $IPFS_PID 2>/dev/null && return - done + for i in $(test_seq 1 100) + do + go-sleep 100ms + ! kill -0 $IPFS_PID 2>/dev/null && return + done ' test_done diff --git a/test/sharness/t0024-datastore-config.sh b/test/sharness/t0024-datastore-config.sh index 20485f857a6..28c1b1e9d0c 100755 --- a/test/sharness/t0024-datastore-config.sh +++ b/test/sharness/t0024-datastore-config.sh @@ -14,18 +14,18 @@ SPEC_NOSYNC=$(cat ../t0024-files/spec-nosync) SPEC_NEWSHARDFUN=$(cat ../t0024-files/spec-newshardfun) test_expect_success "change runtime value in spec config" ' - ipfs config --json Datastore.Spec "$SPEC_NOSYNC" + ipfs config --json Datastore.Spec "$SPEC_NOSYNC" ' test_launch_ipfs_daemon test_kill_ipfs_daemon test_expect_success "change on-disk value in spec config" ' - ipfs config --json Datastore.Spec "$SPEC_NEWSHARDFUN" + ipfs config --json Datastore.Spec "$SPEC_NEWSHARDFUN" ' test_expect_success "can not launch daemon after on-disk value change" ' - test_must_fail ipfs daemon + test_must_fail ipfs daemon ' test_done diff --git a/test/sharness/t0030-mount.sh b/test/sharness/t0030-mount.sh index 72209d30259..1f456d619fb 100755 --- a/test/sharness/t0030-mount.sh +++ b/test/sharness/t0030-mount.sh @@ -10,64 +10,64 @@ test_description="Test mount command" # if in travis CI, dont test mount (no fuse) if ! test_have_prereq FUSE; then - skip_all='skipping mount tests, fuse not available' + skip_all='skipping mount tests, fuse not available' - test_done + test_done fi # start iptb + wait for peering NUM_NODES=5 test_expect_success 'init iptb' ' - iptb init -n $NUM_NODES --bootstrap=none --port=0 + iptb init -n $NUM_NODES --bootstrap=none --port=0 ' startup_cluster $NUM_NODES # test mount failure before mounting properly. test_expect_success "'ipfs mount' fails when there is no mount dir" ' - tmp_ipfs_mount() { ipfsi 0 mount -f=not_ipfs -n=not_ipns >output 2>output.err; } && - test_must_fail tmp_ipfs_mount + tmp_ipfs_mount() { ipfsi 0 mount -f=not_ipfs -n=not_ipns >output 2>output.err; } && + test_must_fail tmp_ipfs_mount ' test_expect_success "'ipfs mount' output looks good" ' - test_must_be_empty output && - test_should_contain "not_ipns\|not_ipfs" output.err + test_must_be_empty output && + test_should_contain "not_ipns\|not_ipfs" output.err ' test_expect_success "setup and publish default IPNS value" ' - mkdir "$(pwd)/ipfs" "$(pwd)/ipns" && - ipfsi 0 name publish QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn + mkdir "$(pwd)/ipfs" "$(pwd)/ipns" && + ipfsi 0 name publish QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn ' # make sure stuff is unmounted first # then mount properly test_expect_success FUSE "'ipfs mount' succeeds" ' - do_umount "$(pwd)/ipfs" || true && - do_umount "$(pwd)/ipns" || true && - ipfsi 0 mount -f "$(pwd)/ipfs" -n "$(pwd)/ipns" >actual + do_umount "$(pwd)/ipfs" || true && + do_umount "$(pwd)/ipns" || true && + ipfsi 0 mount -f "$(pwd)/ipfs" -n "$(pwd)/ipns" >actual ' test_expect_success FUSE "'ipfs mount' output looks good" ' - echo "IPFS mounted at: $(pwd)/ipfs" >expected && - echo "IPNS mounted at: $(pwd)/ipns" >>expected && - test_cmp expected actual + echo "IPFS mounted at: $(pwd)/ipfs" >expected && + echo "IPNS mounted at: $(pwd)/ipns" >>expected && + test_cmp expected actual ' test_expect_success "mount directories cannot be removed while active" ' - test_must_fail rmdir ipfs ipns 2>/dev/null + test_must_fail rmdir ipfs ipns 2>/dev/null ' test_expect_success "unmount directories" ' - do_umount "$(pwd)/ipfs" && - do_umount "$(pwd)/ipns" + do_umount "$(pwd)/ipfs" && + do_umount "$(pwd)/ipns" ' test_expect_success "mount directories can be removed after shutdown" ' - rmdir ipfs ipns + rmdir ipfs ipns ' test_expect_success 'stop iptb' ' - iptb stop + iptb stop ' test_done diff --git a/test/sharness/t0031-mount-publish.sh b/test/sharness/t0031-mount-publish.sh index 09287aa7725..1427dd6422c 100755 --- a/test/sharness/t0031-mount-publish.sh +++ b/test/sharness/t0031-mount-publish.sh @@ -7,9 +7,9 @@ test_description="Test mount command in conjunction with publishing" # if in travis CI, dont test mount (no fuse) if ! test_have_prereq FUSE; then - skip_all='skipping mount tests, fuse not available' + skip_all='skipping mount tests, fuse not available' - test_done + test_done fi test_init_ipfs @@ -17,45 +17,45 @@ test_init_ipfs # start iptb + wait for peering NUM_NODES=3 test_expect_success 'init iptb' ' - iptb init -n $NUM_NODES -f --bootstrap=none --port=0 && - startup_cluster $NUM_NODES + iptb init -n $NUM_NODES -f --bootstrap=none --port=0 && + startup_cluster $NUM_NODES ' # pre-mount publish HASH=$(echo 'hello warld' | ipfsi 0 add -q) test_expect_success "can publish before mounting /ipns" ' - ipfsi 0 name publish '$HASH' + ipfsi 0 name publish '$HASH' ' # mount IPFS_MOUNT_DIR="$PWD/ipfs" IPNS_MOUNT_DIR="$PWD/ipns" test_expect_success FUSE "'ipfs mount' succeeds" ' - ipfsi 0 mount -f "'"$IPFS_MOUNT_DIR"'" -n "'"$IPNS_MOUNT_DIR"'" >actual + ipfsi 0 mount -f "'"$IPFS_MOUNT_DIR"'" -n "'"$IPNS_MOUNT_DIR"'" >actual ' test_expect_success FUSE "'ipfs mount' output looks good" ' - echo "IPFS mounted at: $PWD/ipfs" >expected && - echo "IPNS mounted at: $PWD/ipns" >>expected && - test_cmp expected actual + echo "IPFS mounted at: $PWD/ipfs" >expected && + echo "IPNS mounted at: $PWD/ipns" >>expected && + test_cmp expected actual ' test_expect_success "cannot publish after mounting /ipns" ' - echo "Error: cannot manually publish while IPNS is mounted" >expected && - test_must_fail ipfsi 0 name publish '$HASH' 2>actual && - test_cmp expected actual + echo "Error: cannot manually publish while IPNS is mounted" >expected && + test_must_fail ipfsi 0 name publish '$HASH' 2>actual && + test_cmp expected actual ' test_expect_success "unmount /ipns out-of-band" ' - fusermount -u "'"$IPNS_MOUNT_DIR"'" + fusermount -u "'"$IPNS_MOUNT_DIR"'" ' test_expect_success "can publish after unmounting /ipns" ' - ipfsi 0 name publish '$HASH' + ipfsi 0 name publish '$HASH' ' # clean-up ipfs test_expect_success "unmount /ipfs" ' - fusermount -u "'"$IPFS_MOUNT_DIR"'" + fusermount -u "'"$IPFS_MOUNT_DIR"'" ' iptb stop diff --git a/test/sharness/t0040-add-and-cat.sh b/test/sharness/t0040-add-and-cat.sh index 90ea2f4bff1..a51247a8fb7 100755 --- a/test/sharness/t0040-add-and-cat.sh +++ b/test/sharness/t0040-add-and-cat.sh @@ -9,380 +9,380 @@ test_description="Test add and cat commands" . lib/test-lib.sh test_add_cat_file() { - test_expect_success "ipfs add --help works" ' - ipfs add --help 2> add_help_err > /dev/null - ' - - test_expect_success "stdin reading message doesnt show up" ' - test_expect_code 1 grep "ipfs: Reading from" add_help_err && - test_expect_code 1 grep "send Ctrl-d to stop." add_help_err - ' - - test_expect_success "ipfs add succeeds" ' - echo "Hello Worlds!" >mountdir/hello.txt && - ipfs add mountdir/hello.txt >actual - ' - - test_expect_success "ipfs add output looks good" ' - HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" && - echo "added $HASH hello.txt" >expected && - test_cmp expected actual - ' - - test_expect_success "ipfs add --only-hash succeeds" ' - ipfs add --only-hash mountdir/hello.txt > oh_actual - ' - - test_expect_success "ipfs add --only-hash output looks good" ' - test_cmp expected oh_actual - ' - - test_expect_success "ipfs cat succeeds" ' - ipfs cat "$HASH" >actual - ' - - test_expect_success "ipfs cat output looks good" ' - echo "Hello Worlds!" >expected && - test_cmp expected actual - ' - - test_expect_success "ipfs cat /ipfs/file succeeds" ' - ipfs cat /ipfs/$HASH >actual - ' - - test_expect_success "output looks good" ' - test_cmp expected actual - ' - - test_expect_success "ipfs add -t succeeds" ' - ipfs add -t mountdir/hello.txt >actual - ' - - test_expect_success "ipfs add -t output looks good" ' - HASH="QmUkUQgxXeggyaD5Ckv8ZqfW8wHBX6cYyeiyqvVZYzq5Bi" && - echo "added $HASH hello.txt" >expected && - test_cmp expected actual - ' - - test_expect_success "ipfs add --chunker size-32 succeeds" ' - ipfs add --chunker rabin mountdir/hello.txt >actual - ' - - test_expect_success "ipfs add --chunker size-32 output looks good" ' - HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" && - echo "added $HASH hello.txt" >expected && - test_cmp expected actual - ' - - test_expect_success "ipfs add on hidden file succeeds" ' - echo "Hello Worlds!" >mountdir/.hello.txt && - ipfs add mountdir/.hello.txt >actual - ' - - test_expect_success "ipfs add on hidden file output looks good" ' - HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" && - echo "added $HASH .hello.txt" >expected && - test_cmp expected actual - ' + test_expect_success "ipfs add --help works" ' + ipfs add --help 2> add_help_err > /dev/null + ' + + test_expect_success "stdin reading message doesnt show up" ' + test_expect_code 1 grep "ipfs: Reading from" add_help_err && + test_expect_code 1 grep "send Ctrl-d to stop." add_help_err + ' + + test_expect_success "ipfs add succeeds" ' + echo "Hello Worlds!" >mountdir/hello.txt && + ipfs add mountdir/hello.txt >actual + ' + + test_expect_success "ipfs add output looks good" ' + HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" && + echo "added $HASH hello.txt" >expected && + test_cmp expected actual + ' + + test_expect_success "ipfs add --only-hash succeeds" ' + ipfs add --only-hash mountdir/hello.txt > oh_actual + ' + + test_expect_success "ipfs add --only-hash output looks good" ' + test_cmp expected oh_actual + ' + + test_expect_success "ipfs cat succeeds" ' + ipfs cat "$HASH" >actual + ' + + test_expect_success "ipfs cat output looks good" ' + echo "Hello Worlds!" >expected && + test_cmp expected actual + ' + + test_expect_success "ipfs cat /ipfs/file succeeds" ' + ipfs cat /ipfs/$HASH >actual + ' + + test_expect_success "output looks good" ' + test_cmp expected actual + ' + + test_expect_success "ipfs add -t succeeds" ' + ipfs add -t mountdir/hello.txt >actual + ' + + test_expect_success "ipfs add -t output looks good" ' + HASH="QmUkUQgxXeggyaD5Ckv8ZqfW8wHBX6cYyeiyqvVZYzq5Bi" && + echo "added $HASH hello.txt" >expected && + test_cmp expected actual + ' + + test_expect_success "ipfs add --chunker size-32 succeeds" ' + ipfs add --chunker rabin mountdir/hello.txt >actual + ' + + test_expect_success "ipfs add --chunker size-32 output looks good" ' + HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" && + echo "added $HASH hello.txt" >expected && + test_cmp expected actual + ' + + test_expect_success "ipfs add on hidden file succeeds" ' + echo "Hello Worlds!" >mountdir/.hello.txt && + ipfs add mountdir/.hello.txt >actual + ' + + test_expect_success "ipfs add on hidden file output looks good" ' + HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" && + echo "added $HASH .hello.txt" >expected && + test_cmp expected actual + ' } test_add_cat_5MB() { - ADD_FLAGS="$1" - EXP_HASH="$2" - - test_expect_success "generate 5MB file using go-random" ' - random 5242880 41 >mountdir/bigfile - ' - - test_expect_success "sha1 of the file looks ok" ' - echo "11145620fb92eb5a49c9986b5c6844efda37e471660e" >sha1_expected && - multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual && - test_cmp sha1_expected sha1_actual - ' - - test_expect_success "'ipfs add $ADD_FLAGS bigfile' succeeds" ' - ipfs add $ADD_FLAGS mountdir/bigfile >actual || - test_fsh cat daemon_err - ' - - test_expect_success "'ipfs add bigfile' output looks good" ' - echo "added $EXP_HASH bigfile" >expected && - test_cmp expected actual - ' - test_expect_success "'ipfs cat' succeeds" ' - ipfs cat "$EXP_HASH" >actual - ' - - test_expect_success "'ipfs cat' output looks good" ' - test_cmp mountdir/bigfile actual - ' - - test_expect_success FUSE "cat ipfs/bigfile succeeds" ' - cat "ipfs/$EXP_HASH" >actual - ' - - test_expect_success FUSE "cat ipfs/bigfile looks good" ' - test_cmp mountdir/bigfile actual - ' + ADD_FLAGS="$1" + EXP_HASH="$2" + + test_expect_success "generate 5MB file using go-random" ' + random 5242880 41 >mountdir/bigfile + ' + + test_expect_success "sha1 of the file looks ok" ' + echo "11145620fb92eb5a49c9986b5c6844efda37e471660e" >sha1_expected && + multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual && + test_cmp sha1_expected sha1_actual + ' + + test_expect_success "'ipfs add $ADD_FLAGS bigfile' succeeds" ' + ipfs add $ADD_FLAGS mountdir/bigfile >actual || + test_fsh cat daemon_err + ' + + test_expect_success "'ipfs add bigfile' output looks good" ' + echo "added $EXP_HASH bigfile" >expected && + test_cmp expected actual + ' + test_expect_success "'ipfs cat' succeeds" ' + ipfs cat "$EXP_HASH" >actual + ' + + test_expect_success "'ipfs cat' output looks good" ' + test_cmp mountdir/bigfile actual + ' + + test_expect_success FUSE "cat ipfs/bigfile succeeds" ' + cat "ipfs/$EXP_HASH" >actual + ' + + test_expect_success FUSE "cat ipfs/bigfile looks good" ' + test_cmp mountdir/bigfile actual + ' } test_add_cat_raw() { - test_expect_success "add a small file with raw-leaves" ' - echo "foobar" > afile && - HASH=$(ipfs add -q --raw-leaves afile) - ' - - test_expect_success "cat that small file" ' - ipfs cat $HASH > afile_out - ' - - test_expect_success "make sure it looks good" ' - test_cmp afile afile_out - ' + test_expect_success "add a small file with raw-leaves" ' + echo "foobar" > afile && + HASH=$(ipfs add -q --raw-leaves afile) + ' + + test_expect_success "cat that small file" ' + ipfs cat $HASH > afile_out + ' + + test_expect_success "make sure it looks good" ' + test_cmp afile afile_out + ' } test_add_cat_expensive() { - ADD_FLAGS="$1" - HASH="$2" - - test_expect_success EXPENSIVE "generate 100MB file using go-random" ' - random 104857600 42 >mountdir/bigfile - ' - - test_expect_success EXPENSIVE "sha1 of the file looks ok" ' - echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected && - multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual && - test_cmp sha1_expected sha1_actual - ' - - test_expect_success EXPENSIVE "ipfs add $ADD_FLAGS bigfile succeeds" ' - ipfs add $ADD_FLAGS mountdir/bigfile >actual - ' - - test_expect_success EXPENSIVE "ipfs add bigfile output looks good" ' - echo "added $HASH bigfile" >expected && - test_cmp expected actual - ' - - test_expect_success EXPENSIVE "ipfs cat succeeds" ' - ipfs cat "$HASH" | multihash -a=sha1 -e=hex >sha1_actual - ' - - test_expect_success EXPENSIVE "ipfs cat output looks good" ' - ipfs cat "$HASH" >actual && - test_cmp mountdir/bigfile actual - ' - - test_expect_success EXPENSIVE "ipfs cat output hashed looks good" ' - echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected && - test_cmp sha1_expected sha1_actual - ' - - test_expect_success FUSE,EXPENSIVE "cat ipfs/bigfile succeeds" ' - cat "ipfs/$HASH" | multihash -a=sha1 -e=hex >sha1_actual - ' - - test_expect_success FUSE,EXPENSIVE "cat ipfs/bigfile looks good" ' - test_cmp sha1_expected sha1_actual - ' + ADD_FLAGS="$1" + HASH="$2" + + test_expect_success EXPENSIVE "generate 100MB file using go-random" ' + random 104857600 42 >mountdir/bigfile + ' + + test_expect_success EXPENSIVE "sha1 of the file looks ok" ' + echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected && + multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual && + test_cmp sha1_expected sha1_actual + ' + + test_expect_success EXPENSIVE "ipfs add $ADD_FLAGS bigfile succeeds" ' + ipfs add $ADD_FLAGS mountdir/bigfile >actual + ' + + test_expect_success EXPENSIVE "ipfs add bigfile output looks good" ' + echo "added $HASH bigfile" >expected && + test_cmp expected actual + ' + + test_expect_success EXPENSIVE "ipfs cat succeeds" ' + ipfs cat "$HASH" | multihash -a=sha1 -e=hex >sha1_actual + ' + + test_expect_success EXPENSIVE "ipfs cat output looks good" ' + ipfs cat "$HASH" >actual && + test_cmp mountdir/bigfile actual + ' + + test_expect_success EXPENSIVE "ipfs cat output hashed looks good" ' + echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected && + test_cmp sha1_expected sha1_actual + ' + + test_expect_success FUSE,EXPENSIVE "cat ipfs/bigfile succeeds" ' + cat "ipfs/$HASH" | multihash -a=sha1 -e=hex >sha1_actual + ' + + test_expect_success FUSE,EXPENSIVE "cat ipfs/bigfile looks good" ' + test_cmp sha1_expected sha1_actual + ' } test_add_named_pipe() { - err_prefix=$1 - test_expect_success "useful error message when adding a named pipe" ' - mkfifo named-pipe && - test_expect_code 1 ipfs add named-pipe 2>actual && - STAT=$(generic_stat named-pipe) && - rm named-pipe && - grep "Error: Unrecognized file type for named-pipe: $STAT" actual && - grep USAGE actual && - grep "ipfs add" actual - ' - - test_expect_success "useful error message when recursively adding a named pipe" ' - mkdir -p named-pipe-dir && - mkfifo named-pipe-dir/named-pipe && - STAT=$(generic_stat named-pipe-dir/named-pipe) && - test_expect_code 1 ipfs add -r named-pipe-dir 2>actual && - printf "Error:$err_prefix Unrecognized file type for named-pipe-dir/named-pipe: $STAT\n" >expected && - rm named-pipe-dir/named-pipe && - rmdir named-pipe-dir && - test_cmp expected actual - ' + err_prefix=$1 + test_expect_success "useful error message when adding a named pipe" ' + mkfifo named-pipe && + test_expect_code 1 ipfs add named-pipe 2>actual && + STAT=$(generic_stat named-pipe) && + rm named-pipe && + grep "Error: Unrecognized file type for named-pipe: $STAT" actual && + grep USAGE actual && + grep "ipfs add" actual + ' + + test_expect_success "useful error message when recursively adding a named pipe" ' + mkdir -p named-pipe-dir && + mkfifo named-pipe-dir/named-pipe && + STAT=$(generic_stat named-pipe-dir/named-pipe) && + test_expect_code 1 ipfs add -r named-pipe-dir 2>actual && + printf "Error:$err_prefix Unrecognized file type for named-pipe-dir/named-pipe: $STAT\n" >expected && + rm named-pipe-dir/named-pipe && + rmdir named-pipe-dir && + test_cmp expected actual + ' } test_add_pwd_is_symlink() { - test_expect_success "ipfs add -r adds directory content when ./ is symlink" ' - mkdir hellodir && - echo "World" > hellodir/world && - ln -s hellodir hellolink && - ( cd hellolink && - ipfs add -r . > ../actual ) && - grep "added Qma9CyFdG5ffrZCcYSin2uAETygB25cswVwEYYzwfQuhTe" actual && - rm -r hellodir - ' + test_expect_success "ipfs add -r adds directory content when ./ is symlink" ' + mkdir hellodir && + echo "World" > hellodir/world && + ln -s hellodir hellolink && + ( cd hellolink && + ipfs add -r . > ../actual ) && + grep "added Qma9CyFdG5ffrZCcYSin2uAETygB25cswVwEYYzwfQuhTe" actual && + rm -r hellodir + ' } test_launch_ipfs_daemon_and_mount test_expect_success "'ipfs add --help' succeeds" ' - ipfs add --help >actual + ipfs add --help >actual ' test_expect_success "'ipfs add --help' output looks good" ' - egrep "ipfs add.*" actual >/dev/null || - test_fsh cat actual + egrep "ipfs add.*" actual >/dev/null || + test_fsh cat actual ' test_expect_success "'ipfs cat --help' succeeds" ' - ipfs cat --help >actual + ipfs cat --help >actual ' test_expect_success "'ipfs cat --help' output looks good" ' - egrep "ipfs cat.*" actual >/dev/null || - test_fsh cat actual + egrep "ipfs cat.*" actual >/dev/null || + test_fsh cat actual ' test_add_cat_file test_expect_success "ipfs cat succeeds with stdin opened (issue #1141)" ' - cat mountdir/hello.txt | while read line; do ipfs cat "$HASH" >actual || exit; done + cat mountdir/hello.txt | while read line; do ipfs cat "$HASH" >actual || exit; done ' test_expect_success "ipfs cat output looks good" ' - cat mountdir/hello.txt >expected && - test_cmp expected actual + cat mountdir/hello.txt >expected && + test_cmp expected actual ' test_expect_success "ipfs cat accept hash from built input" ' - echo "$HASH" | ipfs cat >actual + echo "$HASH" | ipfs cat >actual ' test_expect_success "ipfs cat output looks good" ' - test_cmp expected actual + test_cmp expected actual ' test_expect_success FUSE "cat ipfs/stuff succeeds" ' - cat "ipfs/$HASH" >actual + cat "ipfs/$HASH" >actual ' test_expect_success FUSE "cat ipfs/stuff looks good" ' - test_cmp expected actual + test_cmp expected actual ' test_expect_success "'ipfs add -q' succeeds" ' - echo "Hello Venus!" >mountdir/venus.txt && - ipfs add -q mountdir/venus.txt >actual + echo "Hello Venus!" >mountdir/venus.txt && + ipfs add -q mountdir/venus.txt >actual ' test_expect_success "'ipfs add -q' output looks good" ' - HASH="QmU5kp3BH3B8tnWUU2Pikdb2maksBNkb92FHRr56hyghh4" && - echo "$HASH" >expected && - test_cmp expected actual + HASH="QmU5kp3BH3B8tnWUU2Pikdb2maksBNkb92FHRr56hyghh4" && + echo "$HASH" >expected && + test_cmp expected actual ' test_expect_success "'ipfs add -q' with stdin input succeeds" ' - echo "Hello Jupiter!" | ipfs add -q >actual + echo "Hello Jupiter!" | ipfs add -q >actual ' test_expect_success "'ipfs add -q' output looks good" ' - HASH="QmUnvPcBctVTAcJpigv6KMqDvmDewksPWrNVoy1E1WP5fh" && - echo "$HASH" >expected && - test_cmp expected actual + HASH="QmUnvPcBctVTAcJpigv6KMqDvmDewksPWrNVoy1E1WP5fh" && + echo "$HASH" >expected && + test_cmp expected actual ' test_expect_success "'ipfs cat' succeeds" ' - ipfs cat "$HASH" >actual + ipfs cat "$HASH" >actual ' test_expect_success "ipfs cat output looks good" ' - echo "Hello Jupiter!" >expected && - test_cmp expected actual + echo "Hello Jupiter!" >expected && + test_cmp expected actual ' test_expect_success "'ipfs add' with stdin input succeeds" ' - printf "Hello Neptune!\nHello Pluton!" | ipfs add >actual + printf "Hello Neptune!\nHello Pluton!" | ipfs add >actual ' test_expect_success "'ipfs add' output looks good" ' - HASH="QmZDhWpi8NvKrekaYYhxKCdNVGWsFFe1CREnAjP1QbPaB3" && - echo "added $HASH $HASH" >expected && - test_cmp expected actual + HASH="QmZDhWpi8NvKrekaYYhxKCdNVGWsFFe1CREnAjP1QbPaB3" && + echo "added $HASH $HASH" >expected && + test_cmp expected actual ' test_expect_success "'ipfs cat' with built input succeeds" ' - echo "$HASH" | ipfs cat >actual + echo "$HASH" | ipfs cat >actual ' test_expect_success "ipfs cat with built input output looks good" ' - printf "Hello Neptune!\nHello Pluton!" >expected && - test_cmp expected actual + printf "Hello Neptune!\nHello Pluton!" >expected && + test_cmp expected actual ' add_directory() { - EXTRA_ARGS=$1 - - test_expect_success "'ipfs add -r $EXTRA_ARGS' succeeds" ' - mkdir mountdir/planets && - echo "Hello Mars!" >mountdir/planets/mars.txt && - echo "Hello Venus!" >mountdir/planets/venus.txt && - ipfs add -r $EXTRA_ARGS mountdir/planets >actual - ' - - test_expect_success "'ipfs add -r $EXTRA_ARGS' output looks good" ' - echo "added $MARS planets/mars.txt" >expected && - echo "added $VENUS planets/venus.txt" >>expected && - echo "added $PLANETS planets" >>expected && - test_cmp expected actual - ' - - test_expect_success "ipfs cat accept many hashes from built input" ' - { echo "$MARS"; echo "$VENUS"; } | ipfs cat >actual - ' - - test_expect_success "ipfs cat output looks good" ' - cat mountdir/planets/mars.txt mountdir/planets/venus.txt >expected && - test_cmp expected actual - ' - - test_expect_success "ipfs cat accept many hashes as args" ' - ipfs cat "$MARS" "$VENUS" >actual - ' - - test_expect_success "ipfs cat output looks good" ' - test_cmp expected actual - ' - - test_expect_success "ipfs cat with both arg and stdin" ' - echo "$MARS" | ipfs cat "$VENUS" >actual - ' - - test_expect_success "ipfs cat output looks good" ' - cat mountdir/planets/venus.txt >expected && - test_cmp expected actual - ' - - test_expect_success "ipfs cat with two args and stdin" ' - echo "$MARS" | ipfs cat "$VENUS" "$VENUS" >actual - ' - - test_expect_success "ipfs cat output looks good" ' - cat mountdir/planets/venus.txt mountdir/planets/venus.txt >expected && - test_cmp expected actual - ' - - test_expect_success "ipfs add --quieter succeeds" ' - ipfs add -r -Q $EXTRA_ARGS mountdir/planets >actual - ' - - test_expect_success "ipfs add --quieter returns only one correct hash" ' - echo "$PLANETS" > expected && - test_cmp expected actual - ' - - test_expect_success "cleanup" ' - rm -r mountdir/planets - ' + EXTRA_ARGS=$1 + + test_expect_success "'ipfs add -r $EXTRA_ARGS' succeeds" ' + mkdir mountdir/planets && + echo "Hello Mars!" >mountdir/planets/mars.txt && + echo "Hello Venus!" >mountdir/planets/venus.txt && + ipfs add -r $EXTRA_ARGS mountdir/planets >actual + ' + + test_expect_success "'ipfs add -r $EXTRA_ARGS' output looks good" ' + echo "added $MARS planets/mars.txt" >expected && + echo "added $VENUS planets/venus.txt" >>expected && + echo "added $PLANETS planets" >>expected && + test_cmp expected actual + ' + + test_expect_success "ipfs cat accept many hashes from built input" ' + { echo "$MARS"; echo "$VENUS"; } | ipfs cat >actual + ' + + test_expect_success "ipfs cat output looks good" ' + cat mountdir/planets/mars.txt mountdir/planets/venus.txt >expected && + test_cmp expected actual + ' + + test_expect_success "ipfs cat accept many hashes as args" ' + ipfs cat "$MARS" "$VENUS" >actual + ' + + test_expect_success "ipfs cat output looks good" ' + test_cmp expected actual + ' + + test_expect_success "ipfs cat with both arg and stdin" ' + echo "$MARS" | ipfs cat "$VENUS" >actual + ' + + test_expect_success "ipfs cat output looks good" ' + cat mountdir/planets/venus.txt >expected && + test_cmp expected actual + ' + + test_expect_success "ipfs cat with two args and stdin" ' + echo "$MARS" | ipfs cat "$VENUS" "$VENUS" >actual + ' + + test_expect_success "ipfs cat output looks good" ' + cat mountdir/planets/venus.txt mountdir/planets/venus.txt >expected && + test_cmp expected actual + ' + + test_expect_success "ipfs add --quieter succeeds" ' + ipfs add -r -Q $EXTRA_ARGS mountdir/planets >actual + ' + + test_expect_success "ipfs add --quieter returns only one correct hash" ' + echo "$PLANETS" > expected && + test_cmp expected actual + ' + + test_expect_success "cleanup" ' + rm -r mountdir/planets + ' } PLANETS="QmWSgS32xQEcXMeqd3YPJLrNBLSdsfYCep2U7CFkyrjXwY" @@ -411,32 +411,32 @@ VENUS="zCT5htke5JcdoMM4WhmUKXWf2QC3TnQToqGZHH1WsZERv6kPhFPg" add_directory '--hash=blake2b-256' test_expect_success "'ipfs add -rn' succeeds" ' - mkdir -p mountdir/moons/jupiter && - mkdir -p mountdir/moons/saturn && - echo "Hello Europa!" >mountdir/moons/jupiter/europa.txt && - echo "Hello Titan!" >mountdir/moons/saturn/titan.txt && - echo "hey youre no moon!" >mountdir/moons/mercury.txt && - ipfs add -rn mountdir/moons >actual + mkdir -p mountdir/moons/jupiter && + mkdir -p mountdir/moons/saturn && + echo "Hello Europa!" >mountdir/moons/jupiter/europa.txt && + echo "Hello Titan!" >mountdir/moons/saturn/titan.txt && + echo "hey youre no moon!" >mountdir/moons/mercury.txt && + ipfs add -rn mountdir/moons >actual ' test_expect_success "'ipfs add -rn' output looks good" ' - MOONS="QmVKvomp91nMih5j6hYBA8KjbiaYvEetU2Q7KvtZkLe9nQ" && - EUROPA="Qmbjg7zWdqdMaK2BucPncJQDxiALExph5k3NkQv5RHpccu" && - JUPITER="QmS5mZddhFPLWFX3w6FzAy9QxyYkaxvUpsWCtZ3r7jub9J" && - SATURN="QmaMagZT4rTE7Nonw8KGSK4oe1bh533yhZrCo1HihSG8FK" && - TITAN="QmZzppb9WHn552rmRqpPfgU5FEiHH6gDwi3MrB9cTdPwdb" && - MERCURY="QmUJjVtnN8YEeYcS8VmUeWffTWhnMQAkk5DzZdKnPhqUdK" && - echo "added $EUROPA moons/jupiter/europa.txt" >expected && - echo "added $MERCURY moons/mercury.txt" >>expected && - echo "added $TITAN moons/saturn/titan.txt" >>expected && - echo "added $JUPITER moons/jupiter" >>expected && - echo "added $SATURN moons/saturn" >>expected && - echo "added $MOONS moons" >>expected && - test_cmp expected actual + MOONS="QmVKvomp91nMih5j6hYBA8KjbiaYvEetU2Q7KvtZkLe9nQ" && + EUROPA="Qmbjg7zWdqdMaK2BucPncJQDxiALExph5k3NkQv5RHpccu" && + JUPITER="QmS5mZddhFPLWFX3w6FzAy9QxyYkaxvUpsWCtZ3r7jub9J" && + SATURN="QmaMagZT4rTE7Nonw8KGSK4oe1bh533yhZrCo1HihSG8FK" && + TITAN="QmZzppb9WHn552rmRqpPfgU5FEiHH6gDwi3MrB9cTdPwdb" && + MERCURY="QmUJjVtnN8YEeYcS8VmUeWffTWhnMQAkk5DzZdKnPhqUdK" && + echo "added $EUROPA moons/jupiter/europa.txt" >expected && + echo "added $MERCURY moons/mercury.txt" >>expected && + echo "added $TITAN moons/saturn/titan.txt" >>expected && + echo "added $JUPITER moons/jupiter" >>expected && + echo "added $SATURN moons/saturn" >>expected && + echo "added $MOONS moons" >>expected && + test_cmp expected actual ' test_expect_success "go-random is installed" ' - type random + type random ' test_add_cat_5MB "" "QmSr7FqYkxYWGoSfy8ZiaMWQ5vosb18DQGCzjwEQnVHkTb" @@ -479,9 +479,9 @@ test_add_pwd_is_symlink test_add_cat_raw test_expect_success "ipfs add --cid-version=9 fails" ' - echo "context" > afile.txt && - test_must_fail ipfs add --cid-version=9 afile.txt 2>&1 | tee add_out && - grep -q "unknown CID version" add_out + echo "context" > afile.txt && + test_must_fail ipfs add --cid-version=9 afile.txt 2>&1 | tee add_out && + grep -q "unknown CID version" add_out ' test_kill_ipfs_daemon @@ -493,12 +493,12 @@ test_add_cat_file test_add_cat_raw test_expect_success "ipfs add --only-hash succeeds" ' - echo "unknown content for only-hash" | ipfs add --only-hash -q > oh_hash + echo "unknown content for only-hash" | ipfs add --only-hash -q > oh_hash ' #TODO: this doesn't work when online hence separated out from test_add_cat_file test_expect_success "ipfs cat file fails" ' - test_must_fail ipfs cat $(cat oh_hash) + test_must_fail ipfs cat $(cat oh_hash) ' test_add_named_pipe "" diff --git a/test/sharness/t0042-add-skip.sh b/test/sharness/t0042-add-skip.sh index 96f85298fb3..c6340ceefed 100755 --- a/test/sharness/t0042-add-skip.sh +++ b/test/sharness/t0042-add-skip.sh @@ -10,54 +10,54 @@ test_description="Test add and cat commands" test_add_skip() { - test_expect_success "'ipfs add -r' with hidden file succeeds" ' - mkdir -p mountdir/planets/.asteroids && - echo "Hello Mars" >mountdir/planets/mars.txt && - echo "Hello Venus" >mountdir/planets/venus.txt && - echo "Hello Pluto" >mountdir/planets/.pluto.txt && - echo "Hello Charon" >mountdir/planets/.charon.txt && - echo "Hello Ceres" >mountdir/planets/.asteroids/ceres.txt && - echo "Hello Pallas" >mountdir/planets/.asteroids/pallas.txt && - ipfs add -r mountdir/planets >actual - ' + test_expect_success "'ipfs add -r' with hidden file succeeds" ' + mkdir -p mountdir/planets/.asteroids && + echo "Hello Mars" >mountdir/planets/mars.txt && + echo "Hello Venus" >mountdir/planets/venus.txt && + echo "Hello Pluto" >mountdir/planets/.pluto.txt && + echo "Hello Charon" >mountdir/planets/.charon.txt && + echo "Hello Ceres" >mountdir/planets/.asteroids/ceres.txt && + echo "Hello Pallas" >mountdir/planets/.asteroids/pallas.txt && + ipfs add -r mountdir/planets >actual + ' - test_expect_success "'ipfs add -r' did not include . files" ' - cat >expected <<-\EOF && - added QmZy3khu7qf696i5HtkgL2NotsCZ8wzvNZJ1eUdA5n8KaV planets/mars.txt - added QmQnv4m3Q5512zgVtpbJ9z85osQrzZzGRn934AGh6iVEXz planets/venus.txt - added QmR8nD1Vzk5twWVC6oShTHvv7mMYkVh6dApCByBJyV2oj3 planets - EOF - test_cmp expected actual - ' + test_expect_success "'ipfs add -r' did not include . files" ' + cat >expected <<-\EOF && +added QmZy3khu7qf696i5HtkgL2NotsCZ8wzvNZJ1eUdA5n8KaV planets/mars.txt +added QmQnv4m3Q5512zgVtpbJ9z85osQrzZzGRn934AGh6iVEXz planets/venus.txt +added QmR8nD1Vzk5twWVC6oShTHvv7mMYkVh6dApCByBJyV2oj3 planets +EOF + test_cmp expected actual + ' - test_expect_success "'ipfs add -r --hidden' succeeds" ' - ipfs add -r --hidden mountdir/planets >actual - ' + test_expect_success "'ipfs add -r --hidden' succeeds" ' + ipfs add -r --hidden mountdir/planets >actual + ' - test_expect_success "'ipfs add -r --hidden' did include . files" ' - cat >expected <<-\EOF && - added QmcAREBcjgnUpKfyFmUGnfajA1NQS5ydqRp7WfqZ6JF8Dx planets/.asteroids/ceres.txt - added QmZ5eaLybJ5GUZBNwy24AA9EEDTDpA4B8qXnuN3cGxu2uF planets/.asteroids/pallas.txt - added QmaowqjedBkUrMUXgzt9c2ZnAJncM9jpJtkFfgdFstGr5a planets/.charon.txt - added QmU4zFD5eJtRBsWC63AvpozM9Atiadg9kPVTuTrnCYJiNF planets/.pluto.txt - added QmZy3khu7qf696i5HtkgL2NotsCZ8wzvNZJ1eUdA5n8KaV planets/mars.txt - added QmQnv4m3Q5512zgVtpbJ9z85osQrzZzGRn934AGh6iVEXz planets/venus.txt - added Qmf6rbs5GF85anDuoxpSAdtuZPM9D2Yt3HngzjUVSQ7kDV planets/.asteroids - added QmetajtFdmzhWYodAsZoVZSiqpeJDAiaw2NwbM3xcWcpDj planets - EOF - test_cmp expected actual - ' + test_expect_success "'ipfs add -r --hidden' did include . files" ' + cat >expected <<-\EOF && +added QmcAREBcjgnUpKfyFmUGnfajA1NQS5ydqRp7WfqZ6JF8Dx planets/.asteroids/ceres.txt +added QmZ5eaLybJ5GUZBNwy24AA9EEDTDpA4B8qXnuN3cGxu2uF planets/.asteroids/pallas.txt +added QmaowqjedBkUrMUXgzt9c2ZnAJncM9jpJtkFfgdFstGr5a planets/.charon.txt +added QmU4zFD5eJtRBsWC63AvpozM9Atiadg9kPVTuTrnCYJiNF planets/.pluto.txt +added QmZy3khu7qf696i5HtkgL2NotsCZ8wzvNZJ1eUdA5n8KaV planets/mars.txt +added QmQnv4m3Q5512zgVtpbJ9z85osQrzZzGRn934AGh6iVEXz planets/venus.txt +added Qmf6rbs5GF85anDuoxpSAdtuZPM9D2Yt3HngzjUVSQ7kDV planets/.asteroids +added QmetajtFdmzhWYodAsZoVZSiqpeJDAiaw2NwbM3xcWcpDj planets +EOF + test_cmp expected actual + ' - test_expect_success "'ipfs add' includes hidden files given explicitly even without --hidden" ' - mkdir -p mountdir/dotfiles && - echo "set nocompatible" > mountdir/dotfiles/.vimrc - cat >expected <<-\EOF && + test_expect_success "'ipfs add' includes hidden files given explicitly even without --hidden" ' + mkdir -p mountdir/dotfiles && + echo "set nocompatible" > mountdir/dotfiles/.vimrc + cat >expected <<-\EOF && added QmT4uMRDCN7EMpFeqwvKkboszbqeW1kWVGrBxBuCGqZcQc .vimrc - EOF - ipfs add mountdir/dotfiles/.vimrc >actual - cat actual - test_cmp expected actual - ' +EOF + ipfs add mountdir/dotfiles/.vimrc >actual + cat actual + test_cmp expected actual + ' } diff --git a/test/sharness/t0043-add-w.sh b/test/sharness/t0043-add-w.sh index 3b5a4a4d94b..cd4b5d1e539 100755 --- a/test/sharness/t0043-add-w.sh +++ b/test/sharness/t0043-add-w.sh @@ -57,98 +57,98 @@ add_w_r='QmcCksBMDuuyuyfAMMNzEAx6Z7jTrdRy9a23WpufAhG9ji' test_add_w() { - test_expect_success "go-random-files is installed" ' - type random-files - ' - - test_expect_success "random-files generates test files" ' - random-files --seed 7547632 --files 5 --dirs 2 --depth 3 m && - echo "$add_w_m" >expected && - ipfs add -q -r m | tail -n1 >actual && - test_sort_cmp expected actual - ' - - # test single file - test_expect_success "ipfs add -w (single file) succeeds" ' - ipfs add -w m/4r93 >actual - ' - - test_expect_success "ipfs add -w (single file) is correct" ' - echo "$add_w_1" >expected && - test_sort_cmp expected actual - ' - - # test two files together - test_expect_success "ipfs add -w (multiple) succeeds" ' - ipfs add -w m/4r93 m/4u6ead >actual - ' - - test_expect_success "ipfs add -w (multiple) is correct" ' - echo "$add_w_12" >expected && - test_sort_cmp expected actual - ' - - test_expect_success "ipfs add -w (multiple) succeeds" ' - ipfs add -w m/4u6ead m/4r93 >actual - ' - - test_expect_success "ipfs add -w (multiple) orders" ' - echo "$add_w_21" >expected && - test_sort_cmp expected actual - ' - - # test a directory - test_expect_success "ipfs add -w -r (dir) succeeds" ' - ipfs add -r -w m/t_1wp-8a2/_jo7 >actual - ' - - test_expect_success "ipfs add -w -r (dir) is correct" ' - echo "$add_w_d1" >expected && - test_sort_cmp expected actual - ' - - # test files and directory - test_expect_success "ipfs add -w -r succeeds" ' - ipfs add -w -r m/t_1wp-8a2/h3qpecj0 \ - m/ha6f0x7su6/gnz66h m/t_1wp-8a2/_jo7 m/4r93 >actual - ' - - test_expect_success "ipfs add -w -r is correct" ' - echo "$add_w_d2" >expected && - test_sort_cmp expected actual - ' - - # test -w -r m/* == -r m - test_expect_success "ipfs add -w -r m/* == add -r m succeeds" ' - ipfs add -q -w -r m/* | tail -n1 >actual - ' - - test_expect_success "ipfs add -w -r m/* == add -r m is correct" ' - echo "$add_w_m" >expected && - test_sort_cmp expected actual - ' - - # test repeats together - test_expect_success "ipfs add -w (repeats) succeeds" ' - ipfs add -q -w -r m/t_1wp-8a2/h3qpecj0 m/ha6f0x7su6/gnz66h \ - m/t_1wp-8a2/_jo7 m/4r93 m/t_1wp-8a2 m/t_1wp-8a2 m/4r93 \ - m/4r93 m/ha6f0x7su6/_rwujlf3qh_g08 \ - m/ha6f0x7su6/gnz66h/9cwudvacx | tail -n1 >actual - ' - - test_expect_success "ipfs add -w (repeats) is correct" ' - echo "$add_w_r" >expected && - test_sort_cmp expected actual - ' - - test_expect_success "ipfs add -w -r (dir) --cid-version=1 succeeds" ' - ipfs add -r -w --cid-version=1 m/t_1wp-8a2/_jo7 >actual - ' - - test_expect_success "ipfs add -w -r (dir) --cid-version=1 is correct" ' - echo "$add_w_d1_v1" >expected && - test_sort_cmp expected actual - ' + test_expect_success "go-random-files is installed" ' + type random-files + ' + + test_expect_success "random-files generates test files" ' + random-files --seed 7547632 --files 5 --dirs 2 --depth 3 m && + echo "$add_w_m" >expected && + ipfs add -q -r m | tail -n1 >actual && + test_sort_cmp expected actual + ' + + # test single file + test_expect_success "ipfs add -w (single file) succeeds" ' + ipfs add -w m/4r93 >actual + ' + + test_expect_success "ipfs add -w (single file) is correct" ' + echo "$add_w_1" >expected && + test_sort_cmp expected actual + ' + + # test two files together + test_expect_success "ipfs add -w (multiple) succeeds" ' + ipfs add -w m/4r93 m/4u6ead >actual + ' + + test_expect_success "ipfs add -w (multiple) is correct" ' + echo "$add_w_12" >expected && + test_sort_cmp expected actual + ' + + test_expect_success "ipfs add -w (multiple) succeeds" ' + ipfs add -w m/4u6ead m/4r93 >actual + ' + + test_expect_success "ipfs add -w (multiple) orders" ' + echo "$add_w_21" >expected && + test_sort_cmp expected actual + ' + + # test a directory + test_expect_success "ipfs add -w -r (dir) succeeds" ' + ipfs add -r -w m/t_1wp-8a2/_jo7 >actual + ' + + test_expect_success "ipfs add -w -r (dir) is correct" ' + echo "$add_w_d1" >expected && + test_sort_cmp expected actual + ' + + # test files and directory + test_expect_success "ipfs add -w -r succeeds" ' + ipfs add -w -r m/t_1wp-8a2/h3qpecj0 \ + m/ha6f0x7su6/gnz66h m/t_1wp-8a2/_jo7 m/4r93 >actual + ' + + test_expect_success "ipfs add -w -r is correct" ' + echo "$add_w_d2" >expected && + test_sort_cmp expected actual + ' + + # test -w -r m/* == -r m + test_expect_success "ipfs add -w -r m/* == add -r m succeeds" ' + ipfs add -q -w -r m/* | tail -n1 >actual + ' + + test_expect_success "ipfs add -w -r m/* == add -r m is correct" ' + echo "$add_w_m" >expected && + test_sort_cmp expected actual + ' + + # test repeats together + test_expect_success "ipfs add -w (repeats) succeeds" ' + ipfs add -q -w -r m/t_1wp-8a2/h3qpecj0 m/ha6f0x7su6/gnz66h \ + m/t_1wp-8a2/_jo7 m/4r93 m/t_1wp-8a2 m/t_1wp-8a2 m/4r93 \ + m/4r93 m/ha6f0x7su6/_rwujlf3qh_g08 \ + m/ha6f0x7su6/gnz66h/9cwudvacx | tail -n1 >actual + ' + + test_expect_success "ipfs add -w (repeats) is correct" ' + echo "$add_w_r" >expected && + test_sort_cmp expected actual + ' + + test_expect_success "ipfs add -w -r (dir) --cid-version=1 succeeds" ' + ipfs add -r -w --cid-version=1 m/t_1wp-8a2/_jo7 >actual + ' + + test_expect_success "ipfs add -w -r (dir) --cid-version=1 is correct" ' + echo "$add_w_d1_v1" >expected && + test_sort_cmp expected actual + ' } test_init_ipfs diff --git a/test/sharness/t0044-add-symlink.sh b/test/sharness/t0044-add-symlink.sh index e7ac106355d..533cbeddb2a 100755 --- a/test/sharness/t0044-add-symlink.sh +++ b/test/sharness/t0044-add-symlink.sh @@ -9,62 +9,62 @@ test_description="Test add -w" . lib/test-lib.sh test_expect_success "creating files succeeds" ' - mkdir -p files/foo && - mkdir -p files/bar && - echo "some text" > files/foo/baz && - ln -s files/foo/baz files/bar/baz && - ln -s files/does/not/exist files/bad + mkdir -p files/foo && + mkdir -p files/bar && + echo "some text" > files/foo/baz && + ln -s files/foo/baz files/bar/baz && + ln -s files/does/not/exist files/bad ' test_add_symlinks() { - test_expect_success "ipfs add files succeeds" ' - ipfs add -q -r files >filehash_all && - tail -n 1 filehash_all >filehash_out - ' - - test_expect_success "output looks good" ' - echo QmWdiHKoeSW8G1u7ATCgpx4yMoUhYaJBQGkyPLkS9goYZ8 > filehash_exp && - test_cmp filehash_exp filehash_out - ' - - test_expect_success "ipfs add --cid-version=1 files succeeds" ' - ipfs add -q -r --cid-version=1 files >filehash_all && - tail -n 1 filehash_all >filehash_out - ' - - test_expect_success "output looks good" ' - # note this hash implies all internal nodes are stored using CidV1 - echo zdj7WZDQ2xMmr4qn6aRZTsE9fCUs2KmvPigpHdpssqUobwcWK > filehash_exp && - test_cmp filehash_exp filehash_out - ' - - test_expect_success "adding a symlink adds the link itself" ' - ipfs add -q files/bar/baz > goodlink_out - ' - - test_expect_success "output looks good" ' - echo "QmdocmZeF7qwPT9Z8SiVhMSyKA2KKoA2J7jToW6z6WBmxR" > goodlink_exp && - test_cmp goodlink_exp goodlink_out - ' - - test_expect_success "adding a broken symlink works" ' - ipfs add -q files/bad > badlink_out - ' - - test_expect_success "output looks good" ' - echo "QmWYN8SEXCgNT2PSjB6BnxAx6NJQtazWoBkTRH9GRfPFFQ" > badlink_exp && - test_cmp badlink_exp badlink_out - ' - - test_expect_success "adding with symlink in middle of path is same as\ + test_expect_success "ipfs add files succeeds" ' + ipfs add -q -r files >filehash_all && + tail -n 1 filehash_all >filehash_out + ' + + test_expect_success "output looks good" ' + echo QmWdiHKoeSW8G1u7ATCgpx4yMoUhYaJBQGkyPLkS9goYZ8 > filehash_exp && + test_cmp filehash_exp filehash_out + ' + + test_expect_success "ipfs add --cid-version=1 files succeeds" ' + ipfs add -q -r --cid-version=1 files >filehash_all && + tail -n 1 filehash_all >filehash_out + ' + + test_expect_success "output looks good" ' + # note this hash implies all internal nodes are stored using CidV1 + echo zdj7WZDQ2xMmr4qn6aRZTsE9fCUs2KmvPigpHdpssqUobwcWK > filehash_exp && + test_cmp filehash_exp filehash_out + ' + + test_expect_success "adding a symlink adds the link itself" ' + ipfs add -q files/bar/baz > goodlink_out + ' + + test_expect_success "output looks good" ' + echo "QmdocmZeF7qwPT9Z8SiVhMSyKA2KKoA2J7jToW6z6WBmxR" > goodlink_exp && + test_cmp goodlink_exp goodlink_out + ' + + test_expect_success "adding a broken symlink works" ' + ipfs add -q files/bad > badlink_out + ' + + test_expect_success "output looks good" ' + echo "QmWYN8SEXCgNT2PSjB6BnxAx6NJQtazWoBkTRH9GRfPFFQ" > badlink_exp && + test_cmp badlink_exp badlink_out + ' + + test_expect_success "adding with symlink in middle of path is same as\ adding with no symlink" ' - mkdir -p files2/a/b/c && - echo "some other text" > files2/a/b/c/foo && - ln -s b files2/a/d - ipfs add -rq files2/a/b/c > no_sym && - ipfs add -rq files2/a/d/c > sym && - test_cmp no_sym sym - ' + mkdir -p files2/a/b/c && + echo "some other text" > files2/a/b/c/foo && + ln -s b files2/a/d + ipfs add -rq files2/a/b/c > no_sym && + ipfs add -rq files2/a/d/c > sym && + test_cmp no_sym sym + ' } test_init_ipfs diff --git a/test/sharness/t0045-ls.sh b/test/sharness/t0045-ls.sh index e5aa6bef4c5..9b8fb57f837 100755 --- a/test/sharness/t0045-ls.sh +++ b/test/sharness/t0045-ls.sh @@ -12,104 +12,104 @@ test_init_ipfs test_ls_cmd() { - test_expect_success "'ipfs add -r testData' succeeds" ' - mkdir -p testData testData/d1 testData/d2 && - echo "test" >testData/f1 && - echo "data" >testData/f2 && - echo "hello" >testData/d1/a && - random 128 42 >testData/d1/128 && - echo "world" >testData/d2/a && - random 1024 42 >testData/d2/1024 && - ipfs add -r testData >actual_add - ' - - test_expect_success "'ipfs add' output looks good" ' - cat <<-\EOF >expected_add && - added QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe testData/d1/128 - added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN testData/d1/a - added QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd testData/d2/1024 - added QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL testData/d2/a - added QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH testData/f1 - added QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M testData/f2 - added QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss testData/d1 - added QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy testData/d2 - added QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj testData - EOF - test_cmp expected_add actual_add - ' - - test_expect_success "'ipfs ls ' succeeds" ' - ipfs ls QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls - ' - - test_expect_success "'ipfs ls ' output looks good" ' - cat <<-\EOF >expected_ls && - QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj: - QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss 246 d1/ - QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy 1143 d2/ - QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH 13 f1 - QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M 13 f2 - - QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy: - QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd 1035 1024 - QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL 14 a - - QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss: - QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe 139 128 - QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN 14 a - - EOF - test_cmp expected_ls actual_ls - ' - - test_expect_success "'ipfs ls --headers ' succeeds" ' - ipfs ls --headers QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls_headers - ' - - test_expect_success "'ipfs ls --headers ' output looks good" ' - cat <<-\EOF >expected_ls_headers && - QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj: - Hash Size Name - QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss 246 d1/ - QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy 1143 d2/ - QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH 13 f1 - QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M 13 f2 - - QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy: - Hash Size Name - QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd 1035 1024 - QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL 14 a - - QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss: - Hash Size Name - QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe 139 128 - QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN 14 a - - EOF - test_cmp expected_ls_headers actual_ls_headers - ' + test_expect_success "'ipfs add -r testData' succeeds" ' + mkdir -p testData testData/d1 testData/d2 && + echo "test" >testData/f1 && + echo "data" >testData/f2 && + echo "hello" >testData/d1/a && + random 128 42 >testData/d1/128 && + echo "world" >testData/d2/a && + random 1024 42 >testData/d2/1024 && + ipfs add -r testData >actual_add + ' + + test_expect_success "'ipfs add' output looks good" ' + cat <<-\EOF >expected_add && +added QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe testData/d1/128 +added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN testData/d1/a +added QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd testData/d2/1024 +added QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL testData/d2/a +added QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH testData/f1 +added QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M testData/f2 +added QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss testData/d1 +added QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy testData/d2 +added QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj testData +EOF + test_cmp expected_add actual_add + ' + + test_expect_success "'ipfs ls ' succeeds" ' + ipfs ls QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls + ' + + test_expect_success "'ipfs ls ' output looks good" ' + cat <<-\EOF >expected_ls && +QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj: +QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss 246 d1/ +QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy 1143 d2/ +QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH 13 f1 +QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M 13 f2 + +QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy: +QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd 1035 1024 +QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL 14 a + +QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss: +QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe 139 128 +QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN 14 a + +EOF + test_cmp expected_ls actual_ls + ' + + test_expect_success "'ipfs ls --headers ' succeeds" ' + ipfs ls --headers QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls_headers + ' + + test_expect_success "'ipfs ls --headers ' output looks good" ' + cat <<-\EOF >expected_ls_headers && +QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj: +Hash Size Name +QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss 246 d1/ +QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy 1143 d2/ +QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH 13 f1 +QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M 13 f2 + +QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy: +Hash Size Name +QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd 1035 1024 +QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL 14 a + +QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss: +Hash Size Name +QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe 139 128 +QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN 14 a + +EOF + test_cmp expected_ls_headers actual_ls_headers + ' } test_ls_cmd_raw_leaves() { - test_expect_success "'ipfs add -r --raw-leaves' then 'ipfs ls' works as expected" ' - mkdir -p somedir && - echo bar > somedir/foo && - ipfs add --raw-leaves -r somedir/ > /dev/null && - ipfs ls QmThNTdtKaVoCVrYmM5EBS6U3S5vfKFue2TxbxxAxRcKKE > ls-actual - echo "zb2rhf6GzX4ckKZtjy8yy8iyq1KttCrRyqDedD6xubhY3sw2F 4 foo" > ls-expect - test_cmp ls-actual ls-expect - ' + test_expect_success "'ipfs add -r --raw-leaves' then 'ipfs ls' works as expected" ' + mkdir -p somedir && + echo bar > somedir/foo && + ipfs add --raw-leaves -r somedir/ > /dev/null && + ipfs ls QmThNTdtKaVoCVrYmM5EBS6U3S5vfKFue2TxbxxAxRcKKE > ls-actual + echo "zb2rhf6GzX4ckKZtjy8yy8iyq1KttCrRyqDedD6xubhY3sw2F 4 foo" > ls-expect + test_cmp ls-actual ls-expect + ' } test_ls_object() { - test_expect_success "ipfs add medium size file then 'ipfs ls' works as expected" ' - random 500000 2 > somefile && - HASH=$(ipfs add somefile -q) && - echo "QmPrM8S5T7Q3M8DQvQMS7m41m3Aq4jBjzAzvky5fH3xfr4 262158 " > ls-expect && - echo "QmdaAntAzQqqVMo4B8V69nkQd5d918YjHXUe2oF6hr72ri 237870 " >> ls-expect && - ipfs ls $HASH > ls-actual && - test_cmp ls-actual ls-expect - ' + test_expect_success "ipfs add medium size file then 'ipfs ls' works as expected" ' + random 500000 2 > somefile && + HASH=$(ipfs add somefile -q) && + echo "QmPrM8S5T7Q3M8DQvQMS7m41m3Aq4jBjzAzvky5fH3xfr4 262158 " > ls-expect && + echo "QmdaAntAzQqqVMo4B8V69nkQd5d918YjHXUe2oF6hr72ri 237870 " >> ls-expect && + ipfs ls $HASH > ls-actual && + test_cmp ls-actual ls-expect + ' } # should work offline @@ -129,39 +129,39 @@ test_ls_object # test_expect_success "'ipfs add -r' succeeds" ' - mkdir adir && - # note: not using a seed as the files need to have truly random content - random 1000 > adir/file1 && - random 1000 > adir/file2 && - ipfs add --pin=false -q -r adir > adir-hashes + mkdir adir && + # note: not using a seed as the files need to have truly random content + random 1000 > adir/file1 && + random 1000 > adir/file2 && + ipfs add --pin=false -q -r adir > adir-hashes ' test_expect_success "get hashes from add output" ' - FILE=`head -1 adir-hashes` && - DIR=`tail -1 adir-hashes` && - test "$FILE" -a "$DIR" + FILE=`head -1 adir-hashes` && + DIR=`tail -1 adir-hashes` && + test "$FILE" -a "$DIR" ' test_expect_success "remove a file in dir" ' - ipfs block rm $FILE + ipfs block rm $FILE ' test_expect_success "'ipfs ls --resolve-type=false ' ok" ' - ipfs ls --resolve-type=false $DIR > /dev/null + ipfs ls --resolve-type=false $DIR > /dev/null ' test_expect_success "'ipfs ls' fails" ' - test_must_fail ipfs ls $DIR + test_must_fail ipfs ls $DIR ' test_launch_ipfs_daemon --offline test_expect_success "'ipfs ls --resolve-type=false' ok" ' - ipfs ls --resolve-type=false $DIR > /dev/null + ipfs ls --resolve-type=false $DIR > /dev/null ' test_expect_success "'ipfs ls' fails" ' - test_must_fail ipfs ls $DIR + test_must_fail ipfs ls $DIR ' test_kill_ipfs_daemon @@ -174,7 +174,7 @@ test_launch_ipfs_daemon # should not exist on the network, but we don't want to wait for a # timeout so we will kill the request after a few seconds test_expect_success "'ipfs ls --resolve-type=false' ok and does not hang" ' - go-timeout 2 ipfs ls --resolve-type=false $DIR + go-timeout 2 ipfs ls --resolve-type=false $DIR ' test_kill_ipfs_daemon diff --git a/test/sharness/t0050-block.sh b/test/sharness/t0050-block.sh index cc41fdb2c16..285d8ad94b5 100755 --- a/test/sharness/t0050-block.sh +++ b/test/sharness/t0050-block.sh @@ -17,13 +17,13 @@ HASH="QmRKqGMAM6EZngbpjSqrvYzq5Qd8b1bSWymjSUY9zQSNDk" # test_expect_success "'ipfs block put' succeeds" ' - echo "Hello Mars!" >expected_in && - ipfs block put actual_out + echo "Hello Mars!" >expected_in && + ipfs block put actual_out ' test_expect_success "'ipfs block put' output looks good" ' - echo "$HASH" >expected_out && - test_cmp expected_out actual_out + echo "$HASH" >expected_out && + test_cmp expected_out actual_out ' # @@ -31,11 +31,11 @@ test_expect_success "'ipfs block put' output looks good" ' # test_expect_success "'ipfs block get' succeeds" ' - ipfs block get $HASH >actual_in + ipfs block get $HASH >actual_in ' test_expect_success "'ipfs block get' output looks good" ' - test_cmp expected_in actual_in + test_cmp expected_in actual_in ' # @@ -43,13 +43,13 @@ test_expect_success "'ipfs block get' output looks good" ' # test_expect_success "'ipfs block stat' succeeds" ' - ipfs block stat $HASH >actual_stat + ipfs block stat $HASH >actual_stat ' test_expect_success "'ipfs block stat' output looks good" ' - echo "Key: $HASH" >expected_stat && - echo "Size: 12" >>expected_stat && - test_cmp expected_stat actual_stat + echo "Key: $HASH" >expected_stat && + echo "Size: 12" >>expected_stat && + test_cmp expected_stat actual_stat ' # @@ -57,16 +57,16 @@ test_expect_success "'ipfs block stat' output looks good" ' # test_expect_success "'ipfs block rm' succeeds" ' - ipfs block rm $HASH >actual_rm + ipfs block rm $HASH >actual_rm ' test_expect_success "'ipfs block rm' output looks good" ' - echo "removed $HASH" > expected_rm && - test_cmp expected_rm actual_rm + echo "removed $HASH" > expected_rm && + test_cmp expected_rm actual_rm ' test_expect_success "'ipfs block rm' block actually removed" ' - test_must_fail ipfs block stat $HASH + test_must_fail ipfs block stat $HASH ' DIRHASH=QmdWmVmM6W2abTgkEfpbtA1CJyTWS2rhuUB9uP1xV8Uwtf @@ -75,52 +75,52 @@ FILE2HASH=QmUtkGLvPf63NwVzLPKPUYgwhn8ZYPWF6vKWN3fZ2amfJF FILE3HASH=Qmesmmf1EEG1orJb6XdK6DabxexsseJnCfw8pqWgonbkoj test_expect_success "add and pin directory" ' - mkdir adir && - echo "file1" > adir/file1 && - echo "file2" > adir/file2 && - echo "file3" > adir/file3 && - ipfs add -r adir - ipfs pin add -r $DIRHASH + mkdir adir && + echo "file1" > adir/file1 && + echo "file2" > adir/file2 && + echo "file3" > adir/file3 && + ipfs add -r adir + ipfs pin add -r $DIRHASH ' test_expect_success "can't remove pinned block" ' - test_must_fail ipfs block rm $DIRHASH 2> block_rm_err + test_must_fail ipfs block rm $DIRHASH 2> block_rm_err ' test_expect_success "can't remove pinned block: output looks good" ' - grep -q "$DIRHASH: pinned: recursive" block_rm_err + grep -q "$DIRHASH: pinned: recursive" block_rm_err ' test_expect_success "can't remove indirectly pinned block" ' - test_must_fail ipfs block rm $FILE1HASH 2> block_rm_err + test_must_fail ipfs block rm $FILE1HASH 2> block_rm_err ' test_expect_success "can't remove indirectly pinned block: output looks good" ' - grep -q "$FILE1HASH: pinned via $DIRHASH" block_rm_err + grep -q "$FILE1HASH: pinned via $DIRHASH" block_rm_err ' test_expect_success "remove pin" ' - ipfs pin rm -r $DIRHASH + ipfs pin rm -r $DIRHASH ' test_expect_success "multi-block 'ipfs block rm' succeeds" ' - ipfs block rm $FILE1HASH $FILE2HASH $FILE3HASH > actual_rm + ipfs block rm $FILE1HASH $FILE2HASH $FILE3HASH > actual_rm ' test_expect_success "multi-block 'ipfs block rm' output looks good" ' - grep -F -q "removed $FILE1HASH" actual_rm && - grep -F -q "removed $FILE2HASH" actual_rm && - grep -F -q "removed $FILE3HASH" actual_rm + grep -F -q "removed $FILE1HASH" actual_rm && + grep -F -q "removed $FILE2HASH" actual_rm && + grep -F -q "removed $FILE3HASH" actual_rm ' test_expect_success "'add some blocks' succeeds" ' - echo "Hello Mars!" | ipfs block put && - echo "Hello Venus!" | ipfs block put + echo "Hello Mars!" | ipfs block put && + echo "Hello Venus!" | ipfs block put ' test_expect_success "add and pin directory" ' - ipfs add -r adir - ipfs pin add -r $DIRHASH + ipfs add -r adir + ipfs pin add -r $DIRHASH ' HASH=QmRKqGMAM6EZngbpjSqrvYzq5Qd8b1bSWymjSUY9zQSNDk @@ -128,85 +128,85 @@ HASH2=QmdnpnsaEj69isdw5sNzp3h3HkaDz7xKq7BmvFFBzNr5e7 RANDOMHASH=QmRKqGMAM6EbngbZjSqrvYzq5Qd8b1bSWymjSUY9zQSNDq test_expect_success "multi-block 'ipfs block rm' mixed" ' - test_must_fail ipfs block rm $FILE1HASH $DIRHASH $HASH $FILE3HASH $RANDOMHASH $HASH2 2> block_rm_err + test_must_fail ipfs block rm $FILE1HASH $DIRHASH $HASH $FILE3HASH $RANDOMHASH $HASH2 2> block_rm_err ' test_expect_success "pinned block not removed" ' - ipfs block stat $FILE1HASH && - ipfs block stat $FILE3HASH + ipfs block stat $FILE1HASH && + ipfs block stat $FILE3HASH ' test_expect_success "non-pinned blocks removed" ' - test_must_fail ipfs block stat $HASH && - test_must_fail ipfs block stat $HASH2 + test_must_fail ipfs block stat $HASH && + test_must_fail ipfs block stat $HASH2 ' test_expect_success "error reported on removing non-existent block" ' - grep -q "cannot remove $RANDOMHASH" block_rm_err + grep -q "cannot remove $RANDOMHASH" block_rm_err ' test_expect_success "'add some blocks' succeeds" ' - echo "Hello Mars!" | ipfs block put && - echo "Hello Venus!" | ipfs block put + echo "Hello Mars!" | ipfs block put && + echo "Hello Venus!" | ipfs block put ' test_expect_success "multi-block 'ipfs block rm -f' with non existent blocks succeed" ' - ipfs block rm -f $HASH $RANDOMHASH $HASH2 + ipfs block rm -f $HASH $RANDOMHASH $HASH2 ' test_expect_success "existent blocks removed" ' - test_must_fail ipfs block stat $HASH && - test_must_fail ipfs block stat $HASH2 + test_must_fail ipfs block stat $HASH && + test_must_fail ipfs block stat $HASH2 ' test_expect_success "'add some blocks' succeeds" ' - echo "Hello Mars!" | ipfs block put && - echo "Hello Venus!" | ipfs block put + echo "Hello Mars!" | ipfs block put && + echo "Hello Venus!" | ipfs block put ' test_expect_success "multi-block 'ipfs block rm -q' produces no output" ' - ipfs block rm -q $HASH $HASH2 > block_rm_out && - test ! -s block_rm_out + ipfs block rm -q $HASH $HASH2 > block_rm_out && + test ! -s block_rm_out ' test_expect_success "can set cid format on block put" ' - HASH=$(ipfs block put --format=protobuf ../t0051-object-data/testPut.pb) + HASH=$(ipfs block put --format=protobuf ../t0051-object-data/testPut.pb) ' test_expect_success "created an object correctly!" ' - ipfs object get $HASH > obj_out && - echo "{\"Links\":[],\"Data\":\"test json for sharness test\"}" > obj_exp && - test_cmp obj_out obj_exp + ipfs object get $HASH > obj_out && + echo "{\"Links\":[],\"Data\":\"test json for sharness test\"}" > obj_exp && + test_cmp obj_out obj_exp ' test_expect_success "block get output looks right" ' - ipfs block get $HASH > pb_block_out && - test_cmp pb_block_out ../t0051-object-data/testPut.pb + ipfs block get $HASH > pb_block_out && + test_cmp pb_block_out ../t0051-object-data/testPut.pb ' test_expect_success "can set multihash type and length on block put" ' - HASH=$(echo "foooo" | ipfs block put --format=raw --mhtype=sha3 --mhlen=16) + HASH=$(echo "foooo" | ipfs block put --format=raw --mhtype=sha3 --mhlen=16) ' test_expect_success "output looks good" ' - test "z25ScPysKoxJBcPxczn9NvuHiZU5" = "$HASH" + test "z25ScPysKoxJBcPxczn9NvuHiZU5" = "$HASH" ' test_expect_success "can read block with different hash" ' - ipfs block get $HASH > blk_get_out && - echo "foooo" > blk_get_exp && - test_cmp blk_get_exp blk_get_out + ipfs block get $HASH > blk_get_out && + echo "foooo" > blk_get_exp && + test_cmp blk_get_exp blk_get_out ' # # Misc tests # test_expect_success "'ipfs block stat' with nothing from stdin doesnt crash" ' - test_expect_code 1 ipfs block stat < /dev/null 2> stat_out + test_expect_code 1 ipfs block stat < /dev/null 2> stat_out ' test_expect_success "no panic in output" ' - test_expect_code 1 grep "panic" stat_out + test_expect_code 1 grep "panic" stat_out ' test_done diff --git a/test/sharness/t0051-object.sh b/test/sharness/t0051-object.sh index daec670f74b..39c17fc0c04 100755 --- a/test/sharness/t0051-object.sh +++ b/test/sharness/t0051-object.sh @@ -11,317 +11,317 @@ test_description="Test object command" test_init_ipfs test_patch_create_path() { - root=$1 - name=$2 - target=$3 - - test_expect_success "object patch --create works" ' - PCOUT=$(ipfs object patch $root add-link --create $name $target) - ' - - test_expect_success "output looks good" ' - ipfs cat "$PCOUT/$name" >tpcp_out && - ipfs cat "$target" >tpcp_exp && - test_cmp tpcp_exp tpcp_out - ' + root=$1 + name=$2 + target=$3 + + test_expect_success "object patch --create works" ' + PCOUT=$(ipfs object patch $root add-link --create $name $target) + ' + + test_expect_success "output looks good" ' + ipfs cat "$PCOUT/$name" >tpcp_out && + ipfs cat "$target" >tpcp_exp && + test_cmp tpcp_exp tpcp_out + ' } test_object_cmd() { - test_expect_success "'ipfs add testData' succeeds" ' - printf "Hello Mars" >expected_in && - ipfs add expected_in >actual_Addout - ' - - test_expect_success "'ipfs add testData' output looks good" ' - HASH="QmWkHFpYBZ9mpPRreRbMhhYWXfUhBAue3JkbbpFqwowSRb" && - echo "added $HASH expected_in" >expected_Addout && - test_cmp expected_Addout actual_Addout - ' - - test_expect_success "'ipfs object get' succeeds" ' - ipfs object get $HASH >actual_getOut - ' - - test_expect_success "'ipfs object get' output looks good" ' - test_cmp ../t0051-object-data/expected_getOut actual_getOut - ' - - test_expect_success "'ipfs object stat' succeeds" ' - ipfs object stat $HASH >actual_stat - ' - - test_expect_success "'ipfs object get' output looks good" ' - echo "NumLinks: 0" > expected_stat && - echo "BlockSize: 18" >> expected_stat && - echo "LinksSize: 2" >> expected_stat && - echo "DataSize: 16" >> expected_stat && - echo "CumulativeSize: 18" >> expected_stat && - test_cmp expected_stat actual_stat - ' - - test_expect_success "'ipfs object put file.json' succeeds" ' - ipfs object put ../t0051-object-data/testPut.json > actual_putOut - ' - - test_expect_success "'ipfs object put file.json' output looks good" ' - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && - printf "added $HASH\n" > expected_putOut && - test_cmp expected_putOut actual_putOut - ' - - test_expect_success "'ipfs object put file.xml' succeeds" ' - ipfs object put ../t0051-object-data/testPut.xml --inputenc=xml > actual_putOut - ' - - test_expect_success "'ipfs object put file.xml' output looks good" ' - HASH="QmQzNKUHy4HyEUGkqKe3q3t796ffPLQXYCkHCcXUNT5JNK" && - printf "added $HASH\n" > expected_putOut && - test_cmp expected_putOut actual_putOut - ' - - test_expect_success "'ipfs object put' from stdin succeeds" ' - cat ../t0051-object-data/testPut.xml | ipfs object put --inputenc=xml > actual_putStdinOut - ' - - test_expect_success "'ipfs object put broken.xml' should fail" ' - test_expect_code 1 ipfs object put ../t0051-object-data/brokenPut.xml --inputenc=xml 2>actual_putBrokenErr >actual_putBroken - ' - - test_expect_success "'ipfs object put broken.hxml' output looks good" ' - touch expected_putBroken && - printf "Error: no data or links in this node\n" > expected_putBrokenErr && - test_cmp expected_putBroken actual_putBroken && - test_cmp expected_putBrokenErr actual_putBrokenErr - ' - test_expect_success "'ipfs object get --enc=xml' succeeds" ' - ipfs object get --enc=xml $HASH >utf8_xml - ' - - test_expect_success "'ipfs object put --inputenc=xml' succeeds" ' - ipfs object put --inputenc=xml actual - ' - - test_expect_failure "'ipfs object put --inputenc=xml' output looks good" ' - echo "added $HASH\n" >expected && - test_cmp expected actual - ' - - test_expect_success "'ipfs object put file.pb' succeeds" ' - ipfs object put --inputenc=protobuf ../t0051-object-data/testPut.pb > actual_putOut - ' - - test_expect_success "'ipfs object put file.pb' output looks good" ' - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && - printf "added $HASH\n" > expected_putOut && - test_cmp expected_putOut actual_putOut - ' - - test_expect_success "'ipfs object put' from stdin succeeds" ' - cat ../t0051-object-data/testPut.json | ipfs object put > actual_putStdinOut - ' - - test_expect_success "'ipfs object put' from stdin output looks good" ' - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && - printf "added $HASH\n" > expected_putStdinOut && - test_cmp expected_putStdinOut actual_putStdinOut - ' - - test_expect_success "'ipfs object put' from stdin (pb) succeeds" ' - cat ../t0051-object-data/testPut.pb | ipfs object put --inputenc=protobuf > actual_putPbStdinOut - ' - - test_expect_success "'ipfs object put' from stdin (pb) output looks good" ' - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && - printf "added $HASH\n" > expected_putStdinOut && - test_cmp expected_putStdinOut actual_putPbStdinOut - ' - - test_expect_success "'ipfs object put broken.json' should fail" ' - test_expect_code 1 ipfs object put ../t0051-object-data/brokenPut.json 2>actual_putBrokenErr >actual_putBroken - ' - - test_expect_success "'ipfs object put broken.hjson' output looks good" ' - touch expected_putBroken && - printf "Error: no data or links in this node\n" > expected_putBrokenErr && - test_cmp expected_putBroken actual_putBroken && - test_cmp expected_putBrokenErr actual_putBrokenErr - ' - - test_expect_success "setup: add UTF-8 test file" ' - HASH="QmNY5sQeH9ttVCg24sizH71dNbcZTpGd7Yb3YwsKZ4jiFP" && - ipfs add ../t0051-object-data/UTF-8-test.txt >actual && - echo "added $HASH UTF-8-test.txt" >expected && - test_cmp expected actual - ' - - test_expect_success "'ipfs object get --enc=json' succeeds" ' - ipfs object get --enc=json $HASH >utf8_json - ' - - test_expect_success "'ipfs object put --inputenc=json' succeeds" ' - ipfs object put --inputenc=json actual - ' - - test_expect_failure "'ipfs object put --inputenc=json' output looks good" ' - echo "added $HASH" >expected && - test_cmp expected actual - ' - - test_expect_success "'ipfs object put --pin' succeeds" ' - HASH="QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V" && - echo "added $HASH" >expected && - echo "{ \"Data\": \"abc\" }" | ipfs object put --pin >actual - ' - - test_expect_success "'ipfs object put --pin' output looks good" ' - echo "added $HASH" >expected && - test_cmp expected actual - ' - - test_expect_success "after gc, objects still acessible" ' - ipfs repo gc > /dev/null && - ipfs refs -r --timeout=2s $HASH > /dev/null - ' - - test_expect_success "'ipfs object patch' should work (no unixfs-dir)" ' - EMPTY_DIR=$(ipfs object new) && - OUTPUT=$(ipfs object patch $EMPTY_DIR add-link foo $EMPTY_DIR) && - ipfs object stat $OUTPUT - ' - - test_expect_success "'ipfs object patch' should work" ' - EMPTY_DIR=$(ipfs object new unixfs-dir) && - OUTPUT=$(ipfs object patch $EMPTY_DIR add-link foo $EMPTY_DIR) && - ipfs object stat $OUTPUT - ' - - test_expect_success "'ipfs object patch add-link' should work with paths" ' - EMPTY_DIR=$(ipfs object new unixfs-dir) && - N1=$(ipfs object patch $EMPTY_DIR add-link baz $EMPTY_DIR) && - N2=$(ipfs object patch $EMPTY_DIR add-link bar $N1) && - N3=$(ipfs object patch $EMPTY_DIR add-link foo /ipfs/$N2/bar) && - ipfs object stat /ipfs/$N3 > /dev/null && - ipfs object stat $N3/foo > /dev/null && - ipfs object stat /ipfs/$N3/foo/baz > /dev/null - ' - - test_expect_success "object patch creation looks right" ' - echo "QmPc73aWK9dgFBXe86P4PvQizHo9e5Qt7n7DAMXWuigFuG" > hash_exp && - echo $N3 > hash_actual && - test_cmp hash_exp hash_actual - ' - - test_expect_success "multilayer ipfs patch works" ' - echo "hello world" > hwfile && - FILE=$(ipfs add -q hwfile) && - EMPTY=$(ipfs object new unixfs-dir) && - ONE=$(ipfs object patch $EMPTY add-link b $EMPTY) && - TWO=$(ipfs object patch $EMPTY add-link a $ONE) && - ipfs object patch $TWO add-link a/b/c $FILE > multi_patch - ' - - test_expect_success "output looks good" ' - ipfs cat $(cat multi_patch)/a/b/c > hwfile_out && - test_cmp hwfile hwfile_out - ' - - test_expect_success "ipfs object stat path succeeds" ' - ipfs object stat $(cat multi_patch)/a > obj_stat_out - ' - - test_expect_success "ipfs object stat output looks good" ' - echo NumLinks: 1 > obj_stat_exp && - echo BlockSize: 47 >> obj_stat_exp && - echo LinksSize: 45 >> obj_stat_exp && - echo DataSize: 2 >> obj_stat_exp && - echo CumulativeSize: 114 >> obj_stat_exp && - - test_cmp obj_stat_exp obj_stat_out - ' - - test_expect_success "should have created dir within a dir" ' - ipfs ls $OUTPUT > patched_output - ' - - test_expect_success "output looks good" ' - echo "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn 4 foo/" > patched_exp && - test_cmp patched_exp patched_output - ' - - test_expect_success "can remove the directory" ' - ipfs object patch $OUTPUT rm-link foo > rmlink_output - ' - - test_expect_success "output should be empty" ' - echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn > rmlink_exp && - test_cmp rmlink_exp rmlink_output - ' - - test_expect_success "multilayer rm-link should work" ' - ipfs object patch $(cat multi_patch) rm-link a/b/c > multi_link_rm_out - ' - - test_expect_success "output looks good" ' - echo "QmZD3r9cZjzU8huNY2JS9TC6n8daDfT8TmE8zBSqG31Wvq" > multi_link_rm_exp && - test_cmp multi_link_rm_exp multi_link_rm_out - ' - - test_patch_create_path $EMPTY a/b/c $FILE - - test_patch_create_path $EMPTY a $FILE - - test_patch_create_path $EMPTY a/b/b/b/b $FILE - - test_expect_success "can create blank object" ' - BLANK=$(ipfs object new) - ' - - test_patch_create_path $BLANK a $FILE - - test_expect_success "create bad path fails" ' - test_must_fail ipfs object patch $EMPTY add-link --create / $FILE - ' - - test_expect_success "patch set-data works" ' - EMPTY=$(ipfs object new) && - HASH=$(printf "foo" | ipfs object patch $EMPTY set-data) - ' - - test_expect_success "output looks good" ' - echo "{\"Links\":[],\"Data\":\"foo\"}" > exp_data_set && - ipfs object get $HASH > actual_data_set && - test_cmp exp_data_set actual_data_set - ' - - test_expect_success "patch append-data works" ' - HASH=$(printf "bar" | ipfs object patch $HASH append-data) - ' - - test_expect_success "output looks good" ' - echo "{\"Links\":[],\"Data\":\"foobar\"}" > exp_data_append && - ipfs object get $HASH > actual_data_append && - test_cmp exp_data_append actual_data_append - ' + test_expect_success "'ipfs add testData' succeeds" ' + printf "Hello Mars" >expected_in && + ipfs add expected_in >actual_Addout + ' + + test_expect_success "'ipfs add testData' output looks good" ' + HASH="QmWkHFpYBZ9mpPRreRbMhhYWXfUhBAue3JkbbpFqwowSRb" && + echo "added $HASH expected_in" >expected_Addout && + test_cmp expected_Addout actual_Addout + ' + + test_expect_success "'ipfs object get' succeeds" ' + ipfs object get $HASH >actual_getOut + ' + + test_expect_success "'ipfs object get' output looks good" ' + test_cmp ../t0051-object-data/expected_getOut actual_getOut + ' + + test_expect_success "'ipfs object stat' succeeds" ' + ipfs object stat $HASH >actual_stat + ' + + test_expect_success "'ipfs object get' output looks good" ' + echo "NumLinks: 0" > expected_stat && + echo "BlockSize: 18" >> expected_stat && + echo "LinksSize: 2" >> expected_stat && + echo "DataSize: 16" >> expected_stat && + echo "CumulativeSize: 18" >> expected_stat && + test_cmp expected_stat actual_stat + ' + + test_expect_success "'ipfs object put file.json' succeeds" ' + ipfs object put ../t0051-object-data/testPut.json > actual_putOut + ' + + test_expect_success "'ipfs object put file.json' output looks good" ' + HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && + printf "added $HASH\n" > expected_putOut && + test_cmp expected_putOut actual_putOut + ' + + test_expect_success "'ipfs object put file.xml' succeeds" ' + ipfs object put ../t0051-object-data/testPut.xml --inputenc=xml > actual_putOut + ' + + test_expect_success "'ipfs object put file.xml' output looks good" ' + HASH="QmQzNKUHy4HyEUGkqKe3q3t796ffPLQXYCkHCcXUNT5JNK" && + printf "added $HASH\n" > expected_putOut && + test_cmp expected_putOut actual_putOut + ' + + test_expect_success "'ipfs object put' from stdin succeeds" ' + cat ../t0051-object-data/testPut.xml | ipfs object put --inputenc=xml > actual_putStdinOut + ' + + test_expect_success "'ipfs object put broken.xml' should fail" ' + test_expect_code 1 ipfs object put ../t0051-object-data/brokenPut.xml --inputenc=xml 2>actual_putBrokenErr >actual_putBroken + ' + + test_expect_success "'ipfs object put broken.hxml' output looks good" ' + touch expected_putBroken && + printf "Error: no data or links in this node\n" > expected_putBrokenErr && + test_cmp expected_putBroken actual_putBroken && + test_cmp expected_putBrokenErr actual_putBrokenErr + ' + test_expect_success "'ipfs object get --enc=xml' succeeds" ' + ipfs object get --enc=xml $HASH >utf8_xml + ' + + test_expect_success "'ipfs object put --inputenc=xml' succeeds" ' + ipfs object put --inputenc=xml actual + ' + + test_expect_failure "'ipfs object put --inputenc=xml' output looks good" ' + echo "added $HASH\n" >expected && + test_cmp expected actual + ' + + test_expect_success "'ipfs object put file.pb' succeeds" ' + ipfs object put --inputenc=protobuf ../t0051-object-data/testPut.pb > actual_putOut + ' + + test_expect_success "'ipfs object put file.pb' output looks good" ' + HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && + printf "added $HASH\n" > expected_putOut && + test_cmp expected_putOut actual_putOut + ' + + test_expect_success "'ipfs object put' from stdin succeeds" ' + cat ../t0051-object-data/testPut.json | ipfs object put > actual_putStdinOut + ' + + test_expect_success "'ipfs object put' from stdin output looks good" ' + HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && + printf "added $HASH\n" > expected_putStdinOut && + test_cmp expected_putStdinOut actual_putStdinOut + ' + + test_expect_success "'ipfs object put' from stdin (pb) succeeds" ' + cat ../t0051-object-data/testPut.pb | ipfs object put --inputenc=protobuf > actual_putPbStdinOut + ' + + test_expect_success "'ipfs object put' from stdin (pb) output looks good" ' + HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && + printf "added $HASH\n" > expected_putStdinOut && + test_cmp expected_putStdinOut actual_putPbStdinOut + ' + + test_expect_success "'ipfs object put broken.json' should fail" ' + test_expect_code 1 ipfs object put ../t0051-object-data/brokenPut.json 2>actual_putBrokenErr >actual_putBroken + ' + + test_expect_success "'ipfs object put broken.hjson' output looks good" ' + touch expected_putBroken && + printf "Error: no data or links in this node\n" > expected_putBrokenErr && + test_cmp expected_putBroken actual_putBroken && + test_cmp expected_putBrokenErr actual_putBrokenErr + ' + + test_expect_success "setup: add UTF-8 test file" ' + HASH="QmNY5sQeH9ttVCg24sizH71dNbcZTpGd7Yb3YwsKZ4jiFP" && + ipfs add ../t0051-object-data/UTF-8-test.txt >actual && + echo "added $HASH UTF-8-test.txt" >expected && + test_cmp expected actual + ' + + test_expect_success "'ipfs object get --enc=json' succeeds" ' + ipfs object get --enc=json $HASH >utf8_json + ' + + test_expect_success "'ipfs object put --inputenc=json' succeeds" ' + ipfs object put --inputenc=json actual + ' + + test_expect_failure "'ipfs object put --inputenc=json' output looks good" ' + echo "added $HASH" >expected && + test_cmp expected actual + ' + + test_expect_success "'ipfs object put --pin' succeeds" ' + HASH="QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V" && + echo "added $HASH" >expected && + echo "{ \"Data\": \"abc\" }" | ipfs object put --pin >actual + ' + + test_expect_success "'ipfs object put --pin' output looks good" ' + echo "added $HASH" >expected && + test_cmp expected actual + ' + + test_expect_success "after gc, objects still acessible" ' + ipfs repo gc > /dev/null && + ipfs refs -r --timeout=2s $HASH > /dev/null + ' + + test_expect_success "'ipfs object patch' should work (no unixfs-dir)" ' + EMPTY_DIR=$(ipfs object new) && + OUTPUT=$(ipfs object patch $EMPTY_DIR add-link foo $EMPTY_DIR) && + ipfs object stat $OUTPUT + ' + + test_expect_success "'ipfs object patch' should work" ' + EMPTY_DIR=$(ipfs object new unixfs-dir) && + OUTPUT=$(ipfs object patch $EMPTY_DIR add-link foo $EMPTY_DIR) && + ipfs object stat $OUTPUT + ' + + test_expect_success "'ipfs object patch add-link' should work with paths" ' + EMPTY_DIR=$(ipfs object new unixfs-dir) && + N1=$(ipfs object patch $EMPTY_DIR add-link baz $EMPTY_DIR) && + N2=$(ipfs object patch $EMPTY_DIR add-link bar $N1) && + N3=$(ipfs object patch $EMPTY_DIR add-link foo /ipfs/$N2/bar) && + ipfs object stat /ipfs/$N3 > /dev/null && + ipfs object stat $N3/foo > /dev/null && + ipfs object stat /ipfs/$N3/foo/baz > /dev/null + ' + + test_expect_success "object patch creation looks right" ' + echo "QmPc73aWK9dgFBXe86P4PvQizHo9e5Qt7n7DAMXWuigFuG" > hash_exp && + echo $N3 > hash_actual && + test_cmp hash_exp hash_actual + ' + + test_expect_success "multilayer ipfs patch works" ' + echo "hello world" > hwfile && + FILE=$(ipfs add -q hwfile) && + EMPTY=$(ipfs object new unixfs-dir) && + ONE=$(ipfs object patch $EMPTY add-link b $EMPTY) && + TWO=$(ipfs object patch $EMPTY add-link a $ONE) && + ipfs object patch $TWO add-link a/b/c $FILE > multi_patch + ' + + test_expect_success "output looks good" ' + ipfs cat $(cat multi_patch)/a/b/c > hwfile_out && + test_cmp hwfile hwfile_out + ' + + test_expect_success "ipfs object stat path succeeds" ' + ipfs object stat $(cat multi_patch)/a > obj_stat_out + ' + + test_expect_success "ipfs object stat output looks good" ' + echo NumLinks: 1 > obj_stat_exp && + echo BlockSize: 47 >> obj_stat_exp && + echo LinksSize: 45 >> obj_stat_exp && + echo DataSize: 2 >> obj_stat_exp && + echo CumulativeSize: 114 >> obj_stat_exp && + + test_cmp obj_stat_exp obj_stat_out + ' + + test_expect_success "should have created dir within a dir" ' + ipfs ls $OUTPUT > patched_output + ' + + test_expect_success "output looks good" ' + echo "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn 4 foo/" > patched_exp && + test_cmp patched_exp patched_output + ' + + test_expect_success "can remove the directory" ' + ipfs object patch $OUTPUT rm-link foo > rmlink_output + ' + + test_expect_success "output should be empty" ' + echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn > rmlink_exp && + test_cmp rmlink_exp rmlink_output + ' + + test_expect_success "multilayer rm-link should work" ' + ipfs object patch $(cat multi_patch) rm-link a/b/c > multi_link_rm_out + ' + + test_expect_success "output looks good" ' + echo "QmZD3r9cZjzU8huNY2JS9TC6n8daDfT8TmE8zBSqG31Wvq" > multi_link_rm_exp && + test_cmp multi_link_rm_exp multi_link_rm_out + ' + + test_patch_create_path $EMPTY a/b/c $FILE + + test_patch_create_path $EMPTY a $FILE + + test_patch_create_path $EMPTY a/b/b/b/b $FILE + + test_expect_success "can create blank object" ' + BLANK=$(ipfs object new) + ' + + test_patch_create_path $BLANK a $FILE + + test_expect_success "create bad path fails" ' + test_must_fail ipfs object patch $EMPTY add-link --create / $FILE + ' + + test_expect_success "patch set-data works" ' + EMPTY=$(ipfs object new) && + HASH=$(printf "foo" | ipfs object patch $EMPTY set-data) + ' + + test_expect_success "output looks good" ' + echo "{\"Links\":[],\"Data\":\"foo\"}" > exp_data_set && + ipfs object get $HASH > actual_data_set && + test_cmp exp_data_set actual_data_set + ' + + test_expect_success "patch append-data works" ' + HASH=$(printf "bar" | ipfs object patch $HASH append-data) + ' + + test_expect_success "output looks good" ' + echo "{\"Links\":[],\"Data\":\"foobar\"}" > exp_data_append && + ipfs object get $HASH > actual_data_append && + test_cmp exp_data_append actual_data_append + ' } test_object_content_type() { - test_expect_success "'ipfs object get --encoding=protobuf' returns the correct content type" ' - curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=protobuf" | grep -q "^Content-Type: application/protobuf" - ' + test_expect_success "'ipfs object get --encoding=protobuf' returns the correct content type" ' + curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=protobuf" | grep -q "^Content-Type: application/protobuf" + ' - test_expect_success "'ipfs object get --encoding=json' returns the correct content type" ' - curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=json" | grep -q "^Content-Type: application/json" - ' + test_expect_success "'ipfs object get --encoding=json' returns the correct content type" ' + curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=json" | grep -q "^Content-Type: application/json" + ' - test_expect_success "'ipfs object get --encoding=text' returns the correct content type" ' - curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=text" | grep -q "^Content-Type: text/plain" - ' + test_expect_success "'ipfs object get --encoding=text' returns the correct content type" ' + curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=text" | grep -q "^Content-Type: text/plain" + ' - test_expect_success "'ipfs object get --encoding=xml' returns the correct content type" ' - curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=xml" | grep -q "^Content-Type: application/xml" - ' + test_expect_success "'ipfs object get --encoding=xml' returns the correct content type" ' + curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=xml" | grep -q "^Content-Type: application/xml" + ' } # should work offline diff --git a/test/sharness/t0052-object-diff.sh b/test/sharness/t0052-object-diff.sh index 9fe357ae4aa..1c0443d2163 100755 --- a/test/sharness/t0052-object-diff.sh +++ b/test/sharness/t0052-object-diff.sh @@ -11,70 +11,70 @@ test_description="Test object diff command" test_init_ipfs test_expect_success "create some objects for testing diffs" ' - mkdir foo && - echo "stuff" > foo/bar && - mkdir foo/baz && - A=$(ipfs add -r -q foo | tail -n1) && - echo "more things" > foo/cat && - B=$(ipfs add -r -q foo | tail -n1) && - echo "nested" > foo/baz/dog && - C=$(ipfs add -r -q foo | tail -n1) - echo "changed" > foo/bar && - D=$(ipfs add -r -q foo | tail -n1) + mkdir foo && + echo "stuff" > foo/bar && + mkdir foo/baz && + A=$(ipfs add -r -q foo | tail -n1) && + echo "more things" > foo/cat && + B=$(ipfs add -r -q foo | tail -n1) && + echo "nested" > foo/baz/dog && + C=$(ipfs add -r -q foo | tail -n1) + echo "changed" > foo/bar && + D=$(ipfs add -r -q foo | tail -n1) ' test_expect_success "diff against self is empty" ' - ipfs object diff $A $A > diff_out + ipfs object diff $A $A > diff_out ' test_expect_success "identity diff output looks good" ' - printf "" > diff_exp && - test_cmp diff_exp diff_out + printf "" > diff_exp && + test_cmp diff_exp diff_out ' test_expect_success "diff added link works" ' - ipfs object diff $A $B > diff_out + ipfs object diff $A $B > diff_out ' test_expect_success "diff added link looks right" ' - echo + QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A \"cat\" > diff_exp && - test_cmp diff_exp diff_out + echo + QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A \"cat\" > diff_exp && + test_cmp diff_exp diff_out ' test_expect_success "verbose diff added link works" ' - ipfs object diff -v $A $B > diff_out + ipfs object diff -v $A $B > diff_out ' test_expect_success "verbose diff added link looks right" ' - echo Added new link \"cat\" pointing to QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A. > diff_exp && - test_cmp diff_exp diff_out + echo Added new link \"cat\" pointing to QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A. > diff_exp && + test_cmp diff_exp diff_out ' test_expect_success "diff removed link works" ' - ipfs object diff -v $B $A > diff_out + ipfs object diff -v $B $A > diff_out ' test_expect_success "diff removed link looks right" ' - echo Removed link \"cat\" \(was QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A\). > diff_exp && - test_cmp diff_exp diff_out + echo Removed link \"cat\" \(was QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A\). > diff_exp && + test_cmp diff_exp diff_out ' test_expect_success "diff nested add works" ' - ipfs object diff -v $B $C > diff_out + ipfs object diff -v $B $C > diff_out ' test_expect_success "diff looks right" ' - echo Added new link \"baz/dog\" pointing to QmdNJQUTZuDpsUcec7YDuCfRfvw1w4J13DCm7YcU4VMZdS. > diff_exp && - test_cmp diff_exp diff_out + echo Added new link \"baz/dog\" pointing to QmdNJQUTZuDpsUcec7YDuCfRfvw1w4J13DCm7YcU4VMZdS. > diff_exp && + test_cmp diff_exp diff_out ' test_expect_success "diff changed link works" ' - ipfs object diff -v $C $D > diff_out + ipfs object diff -v $C $D > diff_out ' test_expect_success "diff looks right" ' - echo Changed \"bar\" from QmNgd5cz2jNftnAHBhcRUGdtiaMzb5Rhjqd4etondHHST8 to QmRfFVsjSXkhFxrfWnLpMae2M4GBVsry6VAuYYcji5MiZb. > diff_exp && - test_cmp diff_exp diff_out + echo Changed \"bar\" from QmNgd5cz2jNftnAHBhcRUGdtiaMzb5Rhjqd4etondHHST8 to QmRfFVsjSXkhFxrfWnLpMae2M4GBVsry6VAuYYcji5MiZb. > diff_exp && + test_cmp diff_exp diff_out ' test_done diff --git a/test/sharness/t0053-dag.sh b/test/sharness/t0053-dag.sh index 5df5cc41832..968c2430dc5 100755 --- a/test/sharness/t0053-dag.sh +++ b/test/sharness/t0053-dag.sh @@ -11,182 +11,182 @@ test_description="Test dag command" test_init_ipfs test_expect_success "make a few test files" ' - echo "foo" > file1 && - echo "bar" > file2 && - echo "baz" > file3 && - echo "qux" > file4 && - HASH1=$(ipfs add --pin=false -q file1) && - HASH2=$(ipfs add --pin=false -q file2) && - HASH3=$(ipfs add --pin=false -q file3) && - HASH4=$(ipfs add --pin=false -q file4) + echo "foo" > file1 && + echo "bar" > file2 && + echo "baz" > file3 && + echo "qux" > file4 && + HASH1=$(ipfs add --pin=false -q file1) && + HASH2=$(ipfs add --pin=false -q file2) && + HASH3=$(ipfs add --pin=false -q file3) && + HASH4=$(ipfs add --pin=false -q file4) ' test_expect_success "make an ipld object in json" ' - printf "{\"hello\":\"world\",\"cats\":[{\"/\":\"%s\"},{\"water\":{\"/\":\"%s\"}}],\"magic\":{\"/\":\"%s\"},\"sub\":{\"dict\":\"ionary\",\"beep\":[0,\"bop\"]}}" $HASH1 $HASH2 $HASH3 > ipld_object + printf "{\"hello\":\"world\",\"cats\":[{\"/\":\"%s\"},{\"water\":{\"/\":\"%s\"}}],\"magic\":{\"/\":\"%s\"},\"sub\":{\"dict\":\"ionary\",\"beep\":[0,\"bop\"]}}" $HASH1 $HASH2 $HASH3 > ipld_object ' test_dag_cmd() { - test_expect_success "can add an ipld object" ' - IPLDHASH=$(cat ipld_object | ipfs dag put) - ' - - test_expect_success "output looks correct" ' - EXPHASH="zdpuAsXfkHapxohc8LtsCzYiAsy84ESqKRD8eWuY64tt9r2CE" - test $EXPHASH = $IPLDHASH - ' - - test_expect_success "various path traversals work" ' - ipfs cat $IPLDHASH/cats/0 > out1 && - ipfs cat $IPLDHASH/cats/1/water > out2 && - ipfs cat $IPLDHASH/magic > out3 - ' - - test_expect_success "outputs look correct" ' - test_cmp file1 out1 && - test_cmp file2 out2 && - test_cmp file3 out3 - ' - - test_expect_success "resolving sub-objects works" ' - ipfs dag get $IPLDHASH/hello > sub1 && - ipfs dag get $IPLDHASH/sub > sub2 && - ipfs dag get $IPLDHASH/sub/beep > sub3 && - ipfs dag get $IPLDHASH/sub/beep/0 > sub4 && - ipfs dag get $IPLDHASH/sub/beep/1 > sub5 - ' - - test_expect_success "sub-objects look right" ' - echo "\"world\"" > sub1_exp && - test_cmp sub1_exp sub1 && - echo "{\"beep\":[0,\"bop\"],\"dict\":\"ionary\"}" > sub2_exp && - test_cmp sub2_exp sub2 && - echo "[0,\"bop\"]" > sub3_exp && - test_cmp sub3_exp sub3 && - echo "0" > sub4_exp && - test_cmp sub4_exp sub4 && - echo "\"bop\"" > sub5_exp && - test_cmp sub5_exp sub5 - ' - - test_expect_success "can pin cbor object" ' - ipfs pin add $EXPHASH - ' - - test_expect_success "after gc, objects still acessible" ' - ipfs repo gc > /dev/null && - ipfs refs -r --timeout=2s $EXPHASH > /dev/null - ' - - test_expect_success "can get object" ' - ipfs dag get $IPLDHASH > ipld_obj_out - ' - - test_expect_success "object links look right" ' - grep "{\"/\":\"" ipld_obj_out > /dev/null - ' - - test_expect_success "retreived object hashes back correctly" ' - IPLDHASH2=$(cat ipld_obj_out | ipfs dag put) && - test "$IPLDHASH" = "$IPLDHASH2" - ' - - test_expect_success "add a normal file" ' - HASH=$(echo "foobar" | ipfs add -q) - ' - - test_expect_success "can view protobuf object with dag get" ' - ipfs dag get $HASH > dag_get_pb_out - ' - - test_expect_success "output looks correct" ' - echo "{\"data\":\"CAISB2Zvb2JhcgoYBw==\",\"links\":[]}" > dag_get_pb_exp && - test_cmp dag_get_pb_exp dag_get_pb_out - ' - - test_expect_success "can call dag get with a path" ' - ipfs dag get $IPLDHASH/cats/0 > cat_out - ' - - test_expect_success "output looks correct" ' - echo "{\"data\":\"CAISBGZvbwoYBA==\",\"links\":[]}" > cat_exp && - test_cmp cat_exp cat_out - ' - - test_expect_success "non-canonical cbor input is normalized" ' - HASH=$(cat ../t0053-dag-data/non-canon.cbor | ipfs dag put --format=cbor --input-enc=raw) && - test $HASH = "zdpuAmxF8q6iTUtkB3xtEYzmc5Sw762qwQJftt5iW8NTWLtjC" || - test_fsh echo $HASH - ' - - test_expect_success "non-canonical cbor input is normalized with input-enc cbor" ' - HASH=$(cat ../t0053-dag-data/non-canon.cbor | ipfs dag put --format=cbor --input-enc=cbor) && - test $HASH = "zdpuAmxF8q6iTUtkB3xtEYzmc5Sw762qwQJftt5iW8NTWLtjC" || - test_fsh echo $HASH - ' - - test_expect_success "add an ipld with pin" ' - PINHASH=$(printf {\"foo\":\"bar\"} | ipfs dag put --pin=true) - ' - - test_expect_success "after gc, objects still acessible" ' - ipfs repo gc > /dev/null && - ipfs refs -r --timeout=2s $PINHASH > /dev/null - ' - - test_expect_success "can add an ipld object with sha3 hash" ' - IPLDHASH=$(cat ipld_object | ipfs dag put --hash sha3) - ' - - test_expect_success "output looks correct" ' - EXPHASH="zBwWX8u9LYZdCWqaryJW8QsBstghHSPy41nfhhFLY9qw1Vu2BWqnMFtk1jL3qCtEdGd7Kqw1HNPZv5z8LxP2eHGGDCdRE" - test $EXPHASH = $IPLDHASH - ' - - test_expect_success "prepare dag-pb object" ' - echo foo > test_file && - HASH=$(ipfs add -wq test_file | tail -n1) - ' - - test_expect_success "dag put with json dag-pb works" ' - ipfs dag get $HASH > pbjson && - cat pbjson | ipfs dag put --format=dag-pb --input-enc=json > dag_put_out - ' - - test_expect_success "dag put with dag-pb works output looks good" ' - printf $HASH > dag_put_exp && - test_cmp dag_put_exp dag_put_out - ' - - test_expect_success "dag put with raw dag-pb works" ' - ipfs block get $HASH > pbraw && - cat pbraw | ipfs dag put --format=dag-pb --input-enc=raw > dag_put_out - ' - - test_expect_success "dag put with dag-pb works output looks good" ' - printf $HASH > dag_put_exp && - test_cmp dag_put_exp dag_put_out - ' - - test_expect_success "prepare data for dag resolve" ' - NESTED_HASH=$(echo "{\"data\":123}" | ipfs dag put) && - HASH=$(echo "{\"obj\":{\"/\":\"${NESTED_HASH}\"}}" | ipfs dag put) - ' - - test_expect_success "dag resolve some things" ' - ipfs dag resolve $HASH > resolve_hash && - ipfs dag resolve ${HASH}/obj > resolve_obj && - ipfs dag resolve ${HASH}/obj/data > resolve_data - ' - - test_expect_success "dag resolve output looks good" ' - printf $HASH > resolve_hash_exp && - printf $NESTED_HASH > resolve_obj_exp && - printf $NESTED_HASH/data > resolve_data_exp && - - test_cmp resolve_hash_exp resolve_hash && - test_cmp resolve_obj_exp resolve_obj && - test_cmp resolve_data_exp resolve_data - ' + test_expect_success "can add an ipld object" ' + IPLDHASH=$(cat ipld_object | ipfs dag put) + ' + + test_expect_success "output looks correct" ' + EXPHASH="zdpuAsXfkHapxohc8LtsCzYiAsy84ESqKRD8eWuY64tt9r2CE" + test $EXPHASH = $IPLDHASH + ' + + test_expect_success "various path traversals work" ' + ipfs cat $IPLDHASH/cats/0 > out1 && + ipfs cat $IPLDHASH/cats/1/water > out2 && + ipfs cat $IPLDHASH/magic > out3 + ' + + test_expect_success "outputs look correct" ' + test_cmp file1 out1 && + test_cmp file2 out2 && + test_cmp file3 out3 + ' + + test_expect_success "resolving sub-objects works" ' + ipfs dag get $IPLDHASH/hello > sub1 && + ipfs dag get $IPLDHASH/sub > sub2 && + ipfs dag get $IPLDHASH/sub/beep > sub3 && + ipfs dag get $IPLDHASH/sub/beep/0 > sub4 && + ipfs dag get $IPLDHASH/sub/beep/1 > sub5 + ' + + test_expect_success "sub-objects look right" ' + echo "\"world\"" > sub1_exp && + test_cmp sub1_exp sub1 && + echo "{\"beep\":[0,\"bop\"],\"dict\":\"ionary\"}" > sub2_exp && + test_cmp sub2_exp sub2 && + echo "[0,\"bop\"]" > sub3_exp && + test_cmp sub3_exp sub3 && + echo "0" > sub4_exp && + test_cmp sub4_exp sub4 && + echo "\"bop\"" > sub5_exp && + test_cmp sub5_exp sub5 + ' + + test_expect_success "can pin cbor object" ' + ipfs pin add $EXPHASH + ' + + test_expect_success "after gc, objects still acessible" ' + ipfs repo gc > /dev/null && + ipfs refs -r --timeout=2s $EXPHASH > /dev/null + ' + + test_expect_success "can get object" ' + ipfs dag get $IPLDHASH > ipld_obj_out + ' + + test_expect_success "object links look right" ' + grep "{\"/\":\"" ipld_obj_out > /dev/null + ' + + test_expect_success "retreived object hashes back correctly" ' + IPLDHASH2=$(cat ipld_obj_out | ipfs dag put) && + test "$IPLDHASH" = "$IPLDHASH2" + ' + + test_expect_success "add a normal file" ' + HASH=$(echo "foobar" | ipfs add -q) + ' + + test_expect_success "can view protobuf object with dag get" ' + ipfs dag get $HASH > dag_get_pb_out + ' + + test_expect_success "output looks correct" ' + echo "{\"data\":\"CAISB2Zvb2JhcgoYBw==\",\"links\":[]}" > dag_get_pb_exp && + test_cmp dag_get_pb_exp dag_get_pb_out + ' + + test_expect_success "can call dag get with a path" ' + ipfs dag get $IPLDHASH/cats/0 > cat_out + ' + + test_expect_success "output looks correct" ' + echo "{\"data\":\"CAISBGZvbwoYBA==\",\"links\":[]}" > cat_exp && + test_cmp cat_exp cat_out + ' + + test_expect_success "non-canonical cbor input is normalized" ' + HASH=$(cat ../t0053-dag-data/non-canon.cbor | ipfs dag put --format=cbor --input-enc=raw) && + test $HASH = "zdpuAmxF8q6iTUtkB3xtEYzmc5Sw762qwQJftt5iW8NTWLtjC" || + test_fsh echo $HASH + ' + + test_expect_success "non-canonical cbor input is normalized with input-enc cbor" ' + HASH=$(cat ../t0053-dag-data/non-canon.cbor | ipfs dag put --format=cbor --input-enc=cbor) && + test $HASH = "zdpuAmxF8q6iTUtkB3xtEYzmc5Sw762qwQJftt5iW8NTWLtjC" || + test_fsh echo $HASH + ' + + test_expect_success "add an ipld with pin" ' + PINHASH=$(printf {\"foo\":\"bar\"} | ipfs dag put --pin=true) + ' + + test_expect_success "after gc, objects still acessible" ' + ipfs repo gc > /dev/null && + ipfs refs -r --timeout=2s $PINHASH > /dev/null + ' + + test_expect_success "can add an ipld object with sha3 hash" ' + IPLDHASH=$(cat ipld_object | ipfs dag put --hash sha3) + ' + + test_expect_success "output looks correct" ' + EXPHASH="zBwWX8u9LYZdCWqaryJW8QsBstghHSPy41nfhhFLY9qw1Vu2BWqnMFtk1jL3qCtEdGd7Kqw1HNPZv5z8LxP2eHGGDCdRE" + test $EXPHASH = $IPLDHASH + ' + + test_expect_success "prepare dag-pb object" ' + echo foo > test_file && + HASH=$(ipfs add -wq test_file | tail -n1) + ' + + test_expect_success "dag put with json dag-pb works" ' + ipfs dag get $HASH > pbjson && + cat pbjson | ipfs dag put --format=dag-pb --input-enc=json > dag_put_out + ' + + test_expect_success "dag put with dag-pb works output looks good" ' + printf $HASH > dag_put_exp && + test_cmp dag_put_exp dag_put_out + ' + + test_expect_success "dag put with raw dag-pb works" ' + ipfs block get $HASH > pbraw && + cat pbraw | ipfs dag put --format=dag-pb --input-enc=raw > dag_put_out + ' + + test_expect_success "dag put with dag-pb works output looks good" ' + printf $HASH > dag_put_exp && + test_cmp dag_put_exp dag_put_out + ' + + test_expect_success "prepare data for dag resolve" ' + NESTED_HASH=$(echo "{\"data\":123}" | ipfs dag put) && + HASH=$(echo "{\"obj\":{\"/\":\"${NESTED_HASH}\"}}" | ipfs dag put) + ' + + test_expect_success "dag resolve some things" ' + ipfs dag resolve $HASH > resolve_hash && + ipfs dag resolve ${HASH}/obj > resolve_obj && + ipfs dag resolve ${HASH}/obj/data > resolve_data + ' + + test_expect_success "dag resolve output looks good" ' + printf $HASH > resolve_hash_exp && + printf $NESTED_HASH > resolve_obj_exp && + printf $NESTED_HASH/data > resolve_data_exp && + + test_cmp resolve_hash_exp resolve_hash && + test_cmp resolve_obj_exp resolve_obj && + test_cmp resolve_data_exp resolve_data + ' } # should work offline diff --git a/test/sharness/t0060-daemon.sh b/test/sharness/t0060-daemon.sh index 5a6e2e17ea7..e5cbb6e003a 100755 --- a/test/sharness/t0060-daemon.sh +++ b/test/sharness/t0060-daemon.sh @@ -14,116 +14,116 @@ test_launch_ipfs_daemon # this errors if we didn't --init $IPFS_PATH correctly test_expect_success "'ipfs config Identity.PeerID' works" ' - PEERID=$(ipfs config Identity.PeerID) + PEERID=$(ipfs config Identity.PeerID) ' test_expect_success "'ipfs swarm addrs local' works" ' - ipfs swarm addrs local >local_addrs + ipfs swarm addrs local >local_addrs ' test_expect_success "ipfs swarm addrs listen; works" ' - ipfs swarm addrs listen >listen_addrs + ipfs swarm addrs listen >listen_addrs ' test_expect_success "ipfs peer id looks good" ' - test_check_peerid "$PEERID" + test_check_peerid "$PEERID" ' # this is for checking SetAllowedOrigins race condition for the api and gateway # See https://github.com/ipfs/go-ipfs/pull/1966 test_expect_success "ipfs API works with the correct allowed origin port" ' - curl -s -X GET -H "Origin:http://localhost:$API_PORT" -I "http://$API_ADDR/api/v0/version" + curl -s -X GET -H "Origin:http://localhost:$API_PORT" -I "http://$API_ADDR/api/v0/version" ' test_expect_success "ipfs gateway works with the correct allowed origin port" ' - curl -s -X GET -H "Origin:http://localhost:$GWAY_PORT" -I "http://$GWAY_ADDR/api/v0/version" + curl -s -X GET -H "Origin:http://localhost:$GWAY_PORT" -I "http://$GWAY_ADDR/api/v0/version" ' test_expect_success "ipfs daemon output looks good" ' - STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" && - echo "Initializing daemon..." >expected_daemon && - sed "s/^/Swarm listening on /" listen_addrs >>expected_daemon && - sed "s/^/Swarm announcing /" local_addrs >>expected_daemon && - echo "API server listening on '$API_MADDR'" >>expected_daemon && - echo "Gateway (readonly) server listening on '$GWAY_MADDR'" >>expected_daemon && - echo "Daemon is ready" >>expected_daemon && - test_cmp expected_daemon actual_daemon + STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" && + echo "Initializing daemon..." >expected_daemon && + sed "s/^/Swarm listening on /" listen_addrs >>expected_daemon && + sed "s/^/Swarm announcing /" local_addrs >>expected_daemon && + echo "API server listening on '$API_MADDR'" >>expected_daemon && + echo "Gateway (readonly) server listening on '$GWAY_MADDR'" >>expected_daemon && + echo "Daemon is ready" >>expected_daemon && + test_cmp expected_daemon actual_daemon ' test_expect_success ".ipfs/ has been created" ' - test -d ".ipfs" && - test -f ".ipfs/config" && - test -d ".ipfs/datastore" && - test -d ".ipfs/blocks" || - test_fsh ls -al .ipfs + test -d ".ipfs" && + test -f ".ipfs/config" && + test -d ".ipfs/datastore" && + test -d ".ipfs/blocks" || + test_fsh ls -al .ipfs ' # begin same as in t0010 test_expect_success "ipfs version succeeds" ' - ipfs version >version.txt + ipfs version >version.txt ' test_expect_success "ipfs version output looks good" ' - egrep "^ipfs version [0-9]+\.[0-9]+\.[0-9]" version.txt >/dev/null || - test_fsh cat version.txt + egrep "^ipfs version [0-9]+\.[0-9]+\.[0-9]" version.txt >/dev/null || + test_fsh cat version.txt ' test_expect_success "ipfs help succeeds" ' - ipfs help >help.txt + ipfs help >help.txt ' test_expect_success "ipfs help output looks good" ' - egrep -i "^Usage" help.txt >/dev/null && - egrep "ipfs .* " help.txt >/dev/null || - test_fsh cat help.txt + egrep -i "^Usage" help.txt >/dev/null && + egrep "ipfs .* " help.txt >/dev/null || + test_fsh cat help.txt ' # netcat (nc) is needed for the following test test_expect_success "nc is available" ' - type nc >/dev/null + type nc >/dev/null ' # check transport is encrypted test_expect_success "transport should be encrypted" ' - nc -w 1 localhost $SWARM_PORT > swarmnc < ../t0060-data/mss-ls && - grep -q "/secio" swarmnc && - test_must_fail grep -q "/plaintext/1.0.0" swarmnc || - test_fsh cat swarmnc + nc -w 1 localhost $SWARM_PORT > swarmnc < ../t0060-data/mss-ls && + grep -q "/secio" swarmnc && + test_must_fail grep -q "/plaintext/1.0.0" swarmnc || + test_fsh cat swarmnc ' test_expect_success "output from streaming commands works" ' - test_expect_code 28 curl -m 5 http://localhost:$API_PORT/api/v0/stats/bw\?poll=true > statsout + test_expect_code 28 curl -m 5 http://localhost:$API_PORT/api/v0/stats/bw\?poll=true > statsout ' test_expect_success "output looks good" ' - grep TotalIn statsout > /dev/null && - grep TotalOut statsout > /dev/null && - grep RateIn statsout > /dev/null && - grep RateOut statsout >/dev/null + grep TotalIn statsout > /dev/null && + grep TotalOut statsout > /dev/null && + grep RateIn statsout > /dev/null && + grep RateOut statsout >/dev/null ' # end same as in t0010 test_expect_success "daemon is still running" ' - kill -0 $IPFS_PID + kill -0 $IPFS_PID ' test_expect_success "'ipfs daemon' can be killed" ' - test_kill_repeat_10_sec $IPFS_PID + test_kill_repeat_10_sec $IPFS_PID ' test_expect_success "'ipfs daemon' should be able to run with a pipe attached to stdin (issue #861)" ' - yes | ipfs daemon >stdin_daemon_out 2>stdin_daemon_err & - DAEMON_PID=$! - test_wait_for_file 20 100ms "$IPFS_PATH/api" && - test_set_address_vars stdin_daemon_out + yes | ipfs daemon >stdin_daemon_out 2>stdin_daemon_err & + DAEMON_PID=$! + test_wait_for_file 20 100ms "$IPFS_PATH/api" && + test_set_address_vars stdin_daemon_out ' test_expect_success "daemon with pipe eventually becomes live" ' - pollEndpoint -host='$API_MADDR' -ep=/version -v -tout=1s -tries=10 >stdin_poll_apiout 2>stdin_poll_apierr && - test_kill_repeat_10_sec $DAEMON_PID || - test_fsh cat stdin_daemon_out || test_fsh cat stdin_daemon_err || test_fsh cat stdin_poll_apiout || test_fsh cat stdin_poll_apierr + pollEndpoint -host='$API_MADDR' -ep=/version -v -tout=1s -tries=10 >stdin_poll_apiout 2>stdin_poll_apierr && + test_kill_repeat_10_sec $DAEMON_PID || + test_fsh cat stdin_daemon_out || test_fsh cat stdin_daemon_err || test_fsh cat stdin_poll_apiout || test_fsh cat stdin_poll_apierr ' ulimit -S -n 512 @@ -131,15 +131,15 @@ TEST_ULIMIT_PRESET=1 test_launch_ipfs_daemon test_expect_success "daemon raised its fd limit" ' - grep "raised file descriptor limit to 2048." actual_daemon > /dev/null + grep "raised file descriptor limit to 2048." actual_daemon > /dev/null ' test_expect_success "daemon actually can handle 2048 file descriptors" ' - hang-fds -hold=2s 2000 '$API_MADDR' > /dev/null + hang-fds -hold=2s 2000 '$API_MADDR' > /dev/null ' test_expect_success "daemon didnt throw any errors" ' - test_expect_code 1 grep "too many open files" daemon_err + test_expect_code 1 grep "too many open files" daemon_err ' test_kill_ipfs_daemon diff --git a/test/sharness/t0061-daemon-opts.sh b/test/sharness/t0061-daemon-opts.sh index 8b9c1f09b78..131a425f584 100755 --- a/test/sharness/t0061-daemon-opts.sh +++ b/test/sharness/t0061-daemon-opts.sh @@ -18,10 +18,10 @@ apiaddr=$API_ADDR # Odd. this fails here, but the inverse works on t0060-daemon. test_expect_success 'transport should be unencrypted' ' - nc -w 1 localhost $SWARM_PORT > swarmnc < ../t0060-data/mss-ls && - test_must_fail grep -q "/secio" swarmnc && - grep -q "/plaintext" swarmnc || - test_fsh cat swarmnc + nc -w 1 localhost $SWARM_PORT > swarmnc < ../t0060-data/mss-ls && + test_must_fail grep -q "/secio" swarmnc && + grep -q "/plaintext" swarmnc || + test_fsh cat swarmnc ' test_kill_ipfs_daemon @@ -32,21 +32,21 @@ gwyaddr=$GWAY_ADDR apiaddr=$API_ADDR test_expect_success 'gateway should work in offline mode' ' - echo "hello mars :$gwyaddr :$apiaddr" >expected && - HASH=$(ipfs add -q expected) && - curl -sfo actual1 "http://$gwyaddr/ipfs/$HASH" && - test_cmp expected actual1 + echo "hello mars :$gwyaddr :$apiaddr" >expected && + HASH=$(ipfs add -q expected) && + curl -sfo actual1 "http://$gwyaddr/ipfs/$HASH" && + test_cmp expected actual1 ' test_kill_ipfs_daemon test_expect_success 'daemon should not start with bad dht opt' ' - test_must_fail ipfs daemon --routing=fdsfdsfds > daemon_output 2>&1 + test_must_fail ipfs daemon --routing=fdsfdsfds > daemon_output 2>&1 ' test_expect_success 'output contains info about dht option' ' - grep "unrecognized routing option:" daemon_output || - test_fsh cat daemon_output + grep "unrecognized routing option:" daemon_output || + test_fsh cat daemon_output ' test_done diff --git a/test/sharness/t0062-daemon-api.sh b/test/sharness/t0062-daemon-api.sh index 1a4bbc54e82..6f476f87c76 100755 --- a/test/sharness/t0062-daemon-api.sh +++ b/test/sharness/t0062-daemon-api.sh @@ -14,54 +14,54 @@ api_other="/ip4/127.0.0.1/tcp/$differentport" api_unreachable="/ip4/127.0.0.1/tcp/1" test_expect_success "config setup" ' - peerid=$(ipfs config Identity.PeerID) && - test_check_peerid "$peerid" + peerid=$(ipfs config Identity.PeerID) && + test_check_peerid "$peerid" ' test_client() { - opts="$@" - echo "OPTS = " $opts - test_expect_success "client must work properly $state" ' - printf "$peerid" >expected && - ipfs id -f="" $opts >actual && - test_cmp expected actual - ' + opts="$@" + echo "OPTS = " $opts + test_expect_success "client must work properly $state" ' + printf "$peerid" >expected && + ipfs id -f="" $opts >actual && + test_cmp expected actual + ' } test_client_must_fail() { - opts="$@" - echo "OPTS = " $opts - test_expect_success "client should fail $state" ' - echo "Error: api not running" >expected_err && - test_must_fail ipfs id -f="" $opts >actual 2>actual_err && - test_cmp expected_err actual_err - ' + opts="$@" + echo "OPTS = " $opts + test_expect_success "client should fail $state" ' + echo "Error: api not running" >expected_err && + test_must_fail ipfs id -f="" $opts >actual 2>actual_err && + test_cmp expected_err actual_err + ' } test_client_suite() { - state="$1" - cfg_success="$2" - diff_success="$3" - api_fromcfg="$4" - api_different="$5" - - # must always work - test_client - - # must always err - test_client_must_fail --api "$api_unreachable" - - if [ "$cfg_success" = true ]; then - test_client --api "$api_fromcfg" - else - test_client_must_fail --api "$api_fromcfg" - fi - - if [ "$diff_success" = true ]; then - test_client --api "$api_different" - else - test_client_must_fail --api "$api_different" - fi + state="$1" + cfg_success="$2" + diff_success="$3" + api_fromcfg="$4" + api_different="$5" + + # must always work + test_client + + # must always err + test_client_must_fail --api "$api_unreachable" + + if [ "$cfg_success" = true ]; then + test_client --api "$api_fromcfg" + else + test_client_must_fail --api "$api_fromcfg" + fi + + if [ "$diff_success" = true ]; then + test_client --api "$api_different" + else + test_client_must_fail --api "$api_different" + fi } # first, test things without daemon, without /api file @@ -75,7 +75,7 @@ test_client_suite "(daemon off, no --api, no /api file)" false false "$api_unrea test_launch_ipfs_daemon test_expect_success "'ipfs daemon' creates api file" ' - test -f ".ipfs/api" + test -f ".ipfs/api" ' test_client_suite "(daemon on, no --api, /api file from cfg)" true false "$API_MADDR" "$api_other" diff --git a/test/sharness/t0063-daemon-init.sh b/test/sharness/t0063-daemon-init.sh index acb850a7827..ef79cf818cc 100755 --- a/test/sharness/t0063-daemon-init.sh +++ b/test/sharness/t0063-daemon-init.sh @@ -14,37 +14,37 @@ export IPFS_PATH="$(pwd)/.ipfs" # safety check since we will be removing the directory if [ -e "$IPFS_PATH" ]; then - echo "$IPFS_PATH exists" - exit 1 + echo "$IPFS_PATH exists" + exit 1 fi test_ipfs_daemon_init() { - # Doing it manually since we want to launch the daemon with an - # empty or non-existent repo; the normal - # test_launch_ipfs_daemon does not work since it assumes the - # repo was created a particular way with regard to the API - # server. - - test_expect_success "'ipfs daemon --init' succeeds" ' - ipfs daemon --init >actual_daemon 2>daemon_err & - IPFS_PID=$! - sleep 2 && - if ! kill -0 $IPFS_PID; then cat daemon_err; return 1; fi - ' - - test_expect_success "'ipfs daemon' can be killed" ' - test_kill_repeat_10_sec $IPFS_PID - ' + # Doing it manually since we want to launch the daemon with an + # empty or non-existent repo; the normal + # test_launch_ipfs_daemon does not work since it assumes the + # repo was created a particular way with regard to the API + # server. + + test_expect_success "'ipfs daemon --init' succeeds" ' + ipfs daemon --init >actual_daemon 2>daemon_err & + IPFS_PID=$! + sleep 2 && + if ! kill -0 $IPFS_PID; then cat daemon_err; return 1; fi + ' + + test_expect_success "'ipfs daemon' can be killed" ' + test_kill_repeat_10_sec $IPFS_PID + ' } test_expect_success "remove \$IPFS_PATH dir" ' - rm -rf "$IPFS_PATH" + rm -rf "$IPFS_PATH" ' test_ipfs_daemon_init test_expect_success "create empty \$IPFS_PATH dir" ' - rm -rf "$IPFS_PATH" && - mkdir "$IPFS_PATH" + rm -rf "$IPFS_PATH" && + mkdir "$IPFS_PATH" ' test_ipfs_daemon_init diff --git a/test/sharness/t0063-external.sh b/test/sharness/t0063-external.sh index 5d1f440e483..d17fd2f7ece 100755 --- a/test/sharness/t0063-external.sh +++ b/test/sharness/t0063-external.sh @@ -17,20 +17,20 @@ test_init_ipfs test_launch_ipfs_daemon test_expect_success "create fake ipfs-update bin" ' - mkdir bin && - echo "#!/bin/sh" > bin/ipfs-update && - echo "pwd" >> bin/ipfs-update && - chmod +x bin/ipfs-update + mkdir bin && + echo "#!/bin/sh" > bin/ipfs-update && + echo "pwd" >> bin/ipfs-update && + chmod +x bin/ipfs-update ' test_expect_success "external command runs from current user directory" ' - mkdir just_for_test && - (cd just_for_test && ipfs update) > actual + mkdir just_for_test && + (cd just_for_test && ipfs update) > actual ' test_expect_success "output looks good" ' - echo `pwd`/just_for_test > exp && - test_cmp exp actual + echo `pwd`/just_for_test > exp && + test_cmp exp actual ' test_kill_ipfs_daemon diff --git a/test/sharness/t0065-active-requests.sh b/test/sharness/t0065-active-requests.sh index 14b350798d2..a35e9d1254d 100755 --- a/test/sharness/t0065-active-requests.sh +++ b/test/sharness/t0065-active-requests.sh @@ -12,41 +12,41 @@ test_init_ipfs test_launch_ipfs_daemon test_expect_success "command works" ' - ipfs diag cmds > cmd_out + ipfs diag cmds > cmd_out ' test_expect_success "invoc shows up in output" ' - grep "diag/cmds" cmd_out > /dev/null + grep "diag/cmds" cmd_out > /dev/null ' test_expect_success "start longer running command" ' - ipfs log tail & - LOGPID=$! - go-sleep 100ms + ipfs log tail & + LOGPID=$! + go-sleep 100ms ' test_expect_success "long running command shows up" ' - ipfs diag cmds > cmd_out2 + ipfs diag cmds > cmd_out2 ' test_expect_success "output looks good" ' - grep "log/tail" cmd_out2 | grep "true" > /dev/null + grep "log/tail" cmd_out2 | grep "true" > /dev/null ' test_expect_success "kill log cmd" ' - kill $LOGPID - go-sleep 0.5s - kill $LOGPID + kill $LOGPID + go-sleep 0.5s + kill $LOGPID - wait $LOGPID || true + wait $LOGPID || true ' test_expect_success "long running command inactive" ' - ipfs diag cmds > cmd_out3 + ipfs diag cmds > cmd_out3 ' test_expect_success "command shows up as inactive" ' - grep "log/tail" cmd_out3 | grep "false" + grep "log/tail" cmd_out3 | grep "false" ' test_kill_ipfs_daemon diff --git a/test/sharness/t0066-migration.sh b/test/sharness/t0066-migration.sh index 8b4ea645f76..c234286827c 100755 --- a/test/sharness/t0066-migration.sh +++ b/test/sharness/t0066-migration.sh @@ -11,42 +11,42 @@ test_description="Test migrations auto update prompt" test_init_ipfs test_expect_success "setup mock migrations" ' - mkdir bin && - echo "#!/bin/bash" > bin/fs-repo-migrations && - echo "echo 5" >> bin/fs-repo-migrations && - chmod +x bin/fs-repo-migrations && - export PATH="$(pwd)/bin":$PATH + mkdir bin && + echo "#!/bin/bash" > bin/fs-repo-migrations && + echo "echo 5" >> bin/fs-repo-migrations && + chmod +x bin/fs-repo-migrations && + export PATH="$(pwd)/bin":$PATH ' test_expect_success "manually reset repo version to 3" ' - echo "3" > "$IPFS_PATH"/version + echo "3" > "$IPFS_PATH"/version ' test_expect_success "ipfs daemon --migrate=false fails" ' - test_expect_code 1 ipfs daemon --migrate=false > false_out + test_expect_code 1 ipfs daemon --migrate=false > false_out ' test_expect_success "output looks good" ' - grep "Please get fs-repo-migrations from https://dist.ipfs.io" false_out + grep "Please get fs-repo-migrations from https://dist.ipfs.io" false_out ' test_expect_success "ipfs daemon --migrate=true runs migration" ' - test_expect_code 1 ipfs daemon --migrate=true > true_out + test_expect_code 1 ipfs daemon --migrate=true > true_out ' test_expect_failure "output looks good" ' - grep "Running: " true_out > /dev/null && - grep "Success: fs-repo has been migrated to version 5." true_out > /dev/null + grep "Running: " true_out > /dev/null && + grep "Success: fs-repo has been migrated to version 5." true_out > /dev/null ' test_expect_success "'ipfs daemon' prompts to auto migrate" ' - test_expect_code 1 ipfs daemon > daemon_out 2> daemon_err + test_expect_code 1 ipfs daemon > daemon_out 2> daemon_err ' test_expect_success "output looks good" ' - grep "Found outdated fs-repo" daemon_out > /dev/null && - grep "Run migrations now?" daemon_out > /dev/null && - grep "Please get fs-repo-migrations from https://dist.ipfs.io" daemon_out > /dev/null + grep "Found outdated fs-repo" daemon_out > /dev/null && + grep "Run migrations now?" daemon_out > /dev/null && + grep "Please get fs-repo-migrations from https://dist.ipfs.io" daemon_out > /dev/null ' test_done diff --git a/test/sharness/t0070-user-config.sh b/test/sharness/t0070-user-config.sh index c088443b384..f238397e7f9 100755 --- a/test/sharness/t0070-user-config.sh +++ b/test/sharness/t0070-user-config.sh @@ -11,11 +11,11 @@ test_description="Test user-provided config values" test_init_ipfs test_expect_success "bootstrap doesn't overwrite user-provided config keys (top-level)" ' - ipfs config Foo.Bar baz && - ipfs bootstrap rm --all && - echo "baz" >expected && - ipfs config Foo.Bar >actual && - test_cmp expected actual + ipfs config Foo.Bar baz && + ipfs bootstrap rm --all && + echo "baz" >expected && + ipfs config Foo.Bar >actual && + test_cmp expected actual ' test_done diff --git a/test/sharness/t0080-repo.sh b/test/sharness/t0080-repo.sh index 20409c064d2..69087f05a45 100755 --- a/test/sharness/t0080-repo.sh +++ b/test/sharness/t0080-repo.sh @@ -12,253 +12,253 @@ test_init_ipfs test_launch_ipfs_daemon --offline test_expect_success "'ipfs repo gc' succeeds" ' - ipfs repo gc >gc_out_actual + ipfs repo gc >gc_out_actual ' test_expect_success "'ipfs add afile' succeeds" ' - echo "some text" >afile && - HASH=`ipfs add -q afile` + echo "some text" >afile && + HASH=`ipfs add -q afile` ' test_expect_success "added file was pinned" ' - ipfs pin ls --type=recursive >actual && - grep "$HASH" actual + ipfs pin ls --type=recursive >actual && + grep "$HASH" actual ' test_expect_success "'ipfs repo gc' succeeds" ' - ipfs repo gc >gc_out_actual + ipfs repo gc >gc_out_actual ' test_expect_success "'ipfs repo gc' looks good (patch root)" ' - PATCH_ROOT=QmQXirSbubiySKnqaFyfs5YzziXRB5JEVQVjU6xsd7innr && - grep "removed $PATCH_ROOT" gc_out_actual + PATCH_ROOT=QmQXirSbubiySKnqaFyfs5YzziXRB5JEVQVjU6xsd7innr && + grep "removed $PATCH_ROOT" gc_out_actual ' test_expect_success "'ipfs repo gc' doesnt remove file" ' - ipfs cat "$HASH" >out && - test_cmp out afile + ipfs cat "$HASH" >out && + test_cmp out afile ' test_expect_success "'ipfs pin rm' succeeds" ' - ipfs pin rm -r "$HASH" >actual1 + ipfs pin rm -r "$HASH" >actual1 ' test_expect_success "'ipfs pin rm' output looks good" ' - echo "unpinned $HASH" >expected1 && - test_cmp expected1 actual1 + echo "unpinned $HASH" >expected1 && + test_cmp expected1 actual1 ' test_expect_failure "ipfs repo gc fully reverse ipfs add" ' - ipfs repo gc && - random 100000 41 >gcfile && - disk_usage "$IPFS_PATH/blocks" >expected && - hash=`ipfs add -q gcfile` && - ipfs pin rm -r $hash && - ipfs repo gc && - disk_usage "$IPFS_PATH/blocks" >actual && - test_cmp expected actual + ipfs repo gc && + random 100000 41 >gcfile && + disk_usage "$IPFS_PATH/blocks" >expected && + hash=`ipfs add -q gcfile` && + ipfs pin rm -r $hash && + ipfs repo gc && + disk_usage "$IPFS_PATH/blocks" >actual && + test_cmp expected actual ' test_expect_success "file no longer pinned" ' - ipfs pin ls --type=recursive --quiet >actual2 && - test_expect_code 1 grep $HASH actual2 + ipfs pin ls --type=recursive --quiet >actual2 && + test_expect_code 1 grep $HASH actual2 ' test_expect_success "recursively pin afile(default action)" ' - HASH=`ipfs add -q afile` && - ipfs pin add "$HASH" + HASH=`ipfs add -q afile` && + ipfs pin add "$HASH" ' test_expect_success "recursively pin rm afile (default action)" ' - ipfs pin rm "$HASH" + ipfs pin rm "$HASH" ' test_expect_success "recursively pin afile" ' - ipfs pin add -r "$HASH" + ipfs pin add -r "$HASH" ' test_expect_success "pinning directly should fail now" ' - echo "Error: pin: $HASH already pinned recursively" >expected3 && - test_must_fail ipfs pin add -r=false "$HASH" 2>actual3 && - test_cmp expected3 actual3 + echo "Error: pin: $HASH already pinned recursively" >expected3 && + test_must_fail ipfs pin add -r=false "$HASH" 2>actual3 && + test_cmp expected3 actual3 ' test_expect_success "'ipfs pin rm -r=false ' should fail" ' - echo "Error: $HASH is pinned recursively" >expected4 && - test_must_fail ipfs pin rm -r=false "$HASH" 2>actual4 && - test_cmp expected4 actual4 + echo "Error: $HASH is pinned recursively" >expected4 && + test_must_fail ipfs pin rm -r=false "$HASH" 2>actual4 && + test_cmp expected4 actual4 ' test_expect_success "remove recursive pin, add direct" ' - echo "unpinned $HASH" >expected5 && - ipfs pin rm -r "$HASH" >actual5 && - test_cmp expected5 actual5 && - ipfs pin add -r=false "$HASH" + echo "unpinned $HASH" >expected5 && + ipfs pin rm -r "$HASH" >actual5 && + test_cmp expected5 actual5 && + ipfs pin add -r=false "$HASH" ' test_expect_success "remove direct pin" ' - echo "unpinned $HASH" >expected6 && - ipfs pin rm "$HASH" >actual6 && - test_cmp expected6 actual6 + echo "unpinned $HASH" >expected6 && + ipfs pin rm "$HASH" >actual6 && + test_cmp expected6 actual6 ' test_expect_success "'ipfs repo gc' removes file" ' - ipfs repo gc >actual7 && - grep "removed $HASH" actual7 && - grep "removed $PATCH_ROOT" actual7 + ipfs repo gc >actual7 && + grep "removed $HASH" actual7 && + grep "removed $PATCH_ROOT" actual7 ' test_expect_success "'ipfs refs local' no longer shows file" ' - EMPTY_DIR=QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn && - ipfs refs local >actual8 && - grep "QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y" actual8 && - grep "$EMPTY_DIR" actual8 && - grep "$HASH_WELCOME_DOCS" actual8 && - test_must_fail grep "$HASH" actual8 && - test_must_fail grep "$PATCH_ROOT" actual8 + EMPTY_DIR=QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn && + ipfs refs local >actual8 && + grep "QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y" actual8 && + grep "$EMPTY_DIR" actual8 && + grep "$HASH_WELCOME_DOCS" actual8 && + test_must_fail grep "$HASH" actual8 && + test_must_fail grep "$PATCH_ROOT" actual8 ' test_expect_success "adding multiblock random file succeeds" ' - random 1000000 >multiblock && - MBLOCKHASH=`ipfs add -q multiblock` + random 1000000 >multiblock && + MBLOCKHASH=`ipfs add -q multiblock` ' test_expect_success "'ipfs pin ls --type=indirect' is correct" ' - ipfs refs "$MBLOCKHASH" >refsout && - ipfs refs -r "$HASH_WELCOME_DOCS" >>refsout && - sed -i"~" "s/\(.*\)/\1 indirect/g" refsout && - ipfs pin ls --type=indirect >indirectpins && - test_sort_cmp refsout indirectpins + ipfs refs "$MBLOCKHASH" >refsout && + ipfs refs -r "$HASH_WELCOME_DOCS" >>refsout && + sed -i"~" "s/\(.*\)/\1 indirect/g" refsout && + ipfs pin ls --type=indirect >indirectpins && + test_sort_cmp refsout indirectpins ' test_expect_success "pin something directly" ' - echo "ipfs is so awesome" >awesome && - DIRECTPIN=`ipfs add -q awesome` && - echo "unpinned $DIRECTPIN" >expected9 && - ipfs pin rm -r "$DIRECTPIN" >actual9 && - test_cmp expected9 actual9 && + echo "ipfs is so awesome" >awesome && + DIRECTPIN=`ipfs add -q awesome` && + echo "unpinned $DIRECTPIN" >expected9 && + ipfs pin rm -r "$DIRECTPIN" >actual9 && + test_cmp expected9 actual9 && - echo "pinned $DIRECTPIN directly" >expected10 && - ipfs pin add -r=false "$DIRECTPIN" >actual10 && - test_cmp expected10 actual10 + echo "pinned $DIRECTPIN directly" >expected10 && + ipfs pin add -r=false "$DIRECTPIN" >actual10 && + test_cmp expected10 actual10 ' test_expect_success "'ipfs pin ls --type=direct' is correct" ' - echo "$DIRECTPIN direct" >directpinexpected && - ipfs pin ls --type=direct >directpinout && - test_sort_cmp directpinexpected directpinout + echo "$DIRECTPIN direct" >directpinexpected && + ipfs pin ls --type=direct >directpinout && + test_sort_cmp directpinexpected directpinout ' test_expect_success "'ipfs pin ls --type=recursive' is correct" ' - echo "$MBLOCKHASH" >rp_expected && - echo "$HASH_WELCOME_DOCS" >>rp_expected && - echo "$EMPTY_DIR" >>rp_expected && - sed -i"~" "s/\(.*\)/\1 recursive/g" rp_expected && - ipfs pin ls --type=recursive >rp_actual && - test_sort_cmp rp_expected rp_actual + echo "$MBLOCKHASH" >rp_expected && + echo "$HASH_WELCOME_DOCS" >>rp_expected && + echo "$EMPTY_DIR" >>rp_expected && + sed -i"~" "s/\(.*\)/\1 recursive/g" rp_expected && + ipfs pin ls --type=recursive >rp_actual && + test_sort_cmp rp_expected rp_actual ' test_expect_success "'ipfs pin ls --type=all --quiet' is correct" ' - cat directpinout >allpins && - cat rp_actual >>allpins && - cat indirectpins >>allpins && - cut -f1 -d " " allpins | sort | uniq >> allpins_uniq_hashes && - ipfs pin ls --type=all --quiet >actual_allpins && - test_sort_cmp allpins_uniq_hashes actual_allpins + cat directpinout >allpins && + cat rp_actual >>allpins && + cat indirectpins >>allpins && + cut -f1 -d " " allpins | sort | uniq >> allpins_uniq_hashes && + ipfs pin ls --type=all --quiet >actual_allpins && + test_sort_cmp allpins_uniq_hashes actual_allpins ' test_expect_success "'ipfs refs --unique' is correct" ' - mkdir -p uniques && - cd uniques && - echo "content1" > file1 && - echo "content1" > file2 && - ipfs add -r -q . > ../add_output && - ROOT=$(tail -n1 ../add_output) && - ipfs refs --unique $ROOT >expected && - ipfs add -q file1 >unique_hash && - test_cmp expected unique_hash || test_fsh cat ../add_output + mkdir -p uniques && + cd uniques && + echo "content1" > file1 && + echo "content1" > file2 && + ipfs add -r -q . > ../add_output && + ROOT=$(tail -n1 ../add_output) && + ipfs refs --unique $ROOT >expected && + ipfs add -q file1 >unique_hash && + test_cmp expected unique_hash || test_fsh cat ../add_output ' test_expect_success "'ipfs refs --unique --recursive' is correct" ' - mkdir -p a/b/c && - echo "c1" > a/f1 && - echo "c1" > a/b/f1 && - echo "c1" > a/b/c/f1 && - echo "c2" > a/b/c/f2 && - ipfs add -r -q a >add_output && - ROOT=$(tail -n1 add_output) && - ipfs refs --unique --recursive $ROOT >refs_output && - wc -l refs_output | sed "s/^ *//g" >line_count && - echo "4 refs_output" >expected && - test_cmp expected line_count || test_fsh cat add_output || test_fsh cat refs_output + mkdir -p a/b/c && + echo "c1" > a/f1 && + echo "c1" > a/b/f1 && + echo "c1" > a/b/c/f1 && + echo "c2" > a/b/c/f2 && + ipfs add -r -q a >add_output && + ROOT=$(tail -n1 add_output) && + ipfs refs --unique --recursive $ROOT >refs_output && + wc -l refs_output | sed "s/^ *//g" >line_count && + echo "4 refs_output" >expected && + test_cmp expected line_count || test_fsh cat add_output || test_fsh cat refs_output ' test_expect_success "'ipfs refs --recursive (bigger)'" ' - mkdir -p b/c/d/e && - echo "content1" >b/f && - echo "content1" >b/c/f1 && - echo "content1" >b/c/d/f2 && - echo "content2" >b/c/f2 && - echo "content2" >b/c/d/f1 && - echo "content2" >b/c/d/e/f && - cp -r b b2 && mv b2 b/b2 && - cp -r b b3 && mv b3 b/b3 && - cp -r b b4 && mv b4 b/b4 && - ipfs add -r -q b >add_output && - hash=$(tail -n1 add_output) && - ipfs refs -r "$hash" >refs_output && - wc -l refs_output | sed "s/^ *//g" >actual && - echo "79 refs_output" >expected && - test_cmp expected actual || test_fsh cat add_output || test_fsh cat refs_output + mkdir -p b/c/d/e && + echo "content1" >b/f && + echo "content1" >b/c/f1 && + echo "content1" >b/c/d/f2 && + echo "content2" >b/c/f2 && + echo "content2" >b/c/d/f1 && + echo "content2" >b/c/d/e/f && + cp -r b b2 && mv b2 b/b2 && + cp -r b b3 && mv b3 b/b3 && + cp -r b b4 && mv b4 b/b4 && + ipfs add -r -q b >add_output && + hash=$(tail -n1 add_output) && + ipfs refs -r "$hash" >refs_output && + wc -l refs_output | sed "s/^ *//g" >actual && + echo "79 refs_output" >expected && + test_cmp expected actual || test_fsh cat add_output || test_fsh cat refs_output ' test_expect_success "'ipfs refs --unique --recursive (bigger)'" ' - ipfs refs -r "$hash" >refs_output && - sort refs_output | uniq >expected && - ipfs refs -r -u "$hash" >actual && - test_sort_cmp expected actual || test_fsh cat refs_output + ipfs refs -r "$hash" >refs_output && + sort refs_output | uniq >expected && + ipfs refs -r -u "$hash" >actual && + test_sort_cmp expected actual || test_fsh cat refs_output ' get_field_num() { - field=$1 - file=$2 - num=$(grep "$field" "$file" | awk '{ print $2 }') - echo $num + field=$1 + file=$2 + num=$(grep "$field" "$file" | awk '{ print $2 }') + echo $num } test_expect_success "'ipfs repo stat' succeeds" ' - ipfs repo stat > repo-stats + ipfs repo stat > repo-stats ' test_expect_success "repo stats came out correct" ' - grep "RepoPath" repo-stats && - grep "RepoSize" repo-stats && - grep "NumObjects" repo-stats && - grep "Version" repo-stats && - grep "StorageMax" repo-stats + grep "RepoPath" repo-stats && + grep "RepoSize" repo-stats && + grep "NumObjects" repo-stats && + grep "Version" repo-stats && + grep "StorageMax" repo-stats ' test_expect_success "'ipfs repo stat' after adding a file" ' - ipfs add repo-stats && - ipfs repo stat > repo-stats-2 + ipfs add repo-stats && + ipfs repo stat > repo-stats-2 ' test_expect_success "repo stats are updated correctly" ' - test $(get_field_num "RepoSize" repo-stats-2) -ge $(get_field_num "RepoSize" repo-stats) + test $(get_field_num "RepoSize" repo-stats-2) -ge $(get_field_num "RepoSize" repo-stats) ' test_expect_success "'ipfs repo version' succeeds" ' - ipfs repo version > repo-version + ipfs repo version > repo-version ' test_expect_success "repo version came out correct" ' - egrep "^ipfs repo version fs-repo@[0-9]+" repo-version >/dev/null + egrep "^ipfs repo version fs-repo@[0-9]+" repo-version >/dev/null ' test_expect_success "'ipfs repo version -q' succeeds" ' - ipfs repo version -q > repo-version-q + ipfs repo version -q > repo-version-q ' test_expect_success "repo version came out correct" ' - egrep "^fs-repo@[0-9]+" repo-version-q >/dev/null + egrep "^fs-repo@[0-9]+" repo-version-q >/dev/null ' test_kill_ipfs_daemon diff --git a/test/sharness/t0081-repo-pinning.sh b/test/sharness/t0081-repo-pinning.sh index fae9e6143ab..92294a96f3c 100755 --- a/test/sharness/t0081-repo-pinning.sh +++ b/test/sharness/t0081-repo-pinning.sh @@ -9,41 +9,41 @@ test_description="Test ipfs repo pinning" . lib/test-lib.sh test_pin_flag() { - object=$1 - ptype=$2 - expect=$3 - - echo "test_pin_flag" "$@" - - if ipfs pin ls --type="$ptype" "$object" >actual - then - test "$expect" = "true" && return - test_fsh cat actual - return - else - test "$expect" = "false" && return - test_fsh cat actual - return - fi + object=$1 + ptype=$2 + expect=$3 + + echo "test_pin_flag" "$@" + + if ipfs pin ls --type="$ptype" "$object" >actual + then + test "$expect" = "true" && return + test_fsh cat actual + return + else + test "$expect" = "false" && return + test_fsh cat actual + return + fi } test_pin() { - object=$1 - shift + object=$1 + shift - test_str_contains "recursive" $@ - [ "$?" = "0" ] && r="true" || r="false" + test_str_contains "recursive" $@ + [ "$?" = "0" ] && r="true" || r="false" - test_str_contains "indirect" $@ - [ "$?" = "0" ] && i="true" || i="false" + test_str_contains "indirect" $@ + [ "$?" = "0" ] && i="true" || i="false" - test_str_contains "direct" $@ - [ "$?" = "0" ] && d="true" || d="false" + test_str_contains "direct" $@ + [ "$?" = "0" ] && d="true" || d="false" - test_pin_flag "$object" "recursive" $r || return 1 - test_pin_flag "$object" "indirect" $i || return 1 - test_pin_flag "$object" "direct" $d || return 1 - return 0 + test_pin_flag "$object" "recursive" $r || return 1 + test_pin_flag "$object" "indirect" $i || return 1 + test_pin_flag "$object" "direct" $d || return 1 + return 0 } @@ -80,204 +80,204 @@ FILE6="dir1/dir2/dir4/file6" FILE5="dir1/dir3/file5" test_expect_success "'ipfs add dir' succeeds" ' - mkdir dir1 && - mkdir dir1/dir2 && - mkdir dir1/dir2/dir4 && - mkdir dir1/dir3 && - echo "some text 1" >dir1/file1 && - echo "some text 2" >dir1/file2 && - echo "some text 3" >dir1/file3 && - echo "some text 1" >dir1/dir2/file1 && - echo "some text 4" >dir1/dir2/file4 && - echo "some text 1" >dir1/dir2/dir4/file1 && - echo "some text 2" >dir1/dir2/dir4/file2 && - echo "some text 6" >dir1/dir2/dir4/file6 && - echo "some text 2" >dir1/dir3/file2 && - echo "some text 5" >dir1/dir3/file5 && - ipfs add -q -r dir1 >actualall && - tail -n1 actualall >actual1 && - echo "$HASH_DIR1" >expected1 && - ipfs repo gc && # remove the patch chaff - test_cmp expected1 actual1 + mkdir dir1 && + mkdir dir1/dir2 && + mkdir dir1/dir2/dir4 && + mkdir dir1/dir3 && + echo "some text 1" >dir1/file1 && + echo "some text 2" >dir1/file2 && + echo "some text 3" >dir1/file3 && + echo "some text 1" >dir1/dir2/file1 && + echo "some text 4" >dir1/dir2/file4 && + echo "some text 1" >dir1/dir2/dir4/file1 && + echo "some text 2" >dir1/dir2/dir4/file2 && + echo "some text 6" >dir1/dir2/dir4/file6 && + echo "some text 2" >dir1/dir3/file2 && + echo "some text 5" >dir1/dir3/file5 && + ipfs add -q -r dir1 >actualall && + tail -n1 actualall >actual1 && + echo "$HASH_DIR1" >expected1 && + ipfs repo gc && # remove the patch chaff + test_cmp expected1 actual1 ' test_expect_success "objects are there" ' - ipfs cat "$HASH_FILE6" >FILE6_a && - ipfs cat "$HASH_FILE5" >FILE5_a && - ipfs cat "$HASH_FILE4" >FILE4_a && - ipfs cat "$HASH_FILE3" >FILE3_a && - ipfs cat "$HASH_FILE2" >FILE2_a && - ipfs cat "$HASH_FILE1" >FILE1_a && - ipfs ls "$HASH_DIR3" >DIR3_a && - ipfs ls "$HASH_DIR4" >DIR4_a && - ipfs ls "$HASH_DIR2" >DIR2_a && - ipfs ls "$HASH_DIR1" >DIR1_a + ipfs cat "$HASH_FILE6" >FILE6_a && + ipfs cat "$HASH_FILE5" >FILE5_a && + ipfs cat "$HASH_FILE4" >FILE4_a && + ipfs cat "$HASH_FILE3" >FILE3_a && + ipfs cat "$HASH_FILE2" >FILE2_a && + ipfs cat "$HASH_FILE1" >FILE1_a && + ipfs ls "$HASH_DIR3" >DIR3_a && + ipfs ls "$HASH_DIR4" >DIR4_a && + ipfs ls "$HASH_DIR2" >DIR2_a && + ipfs ls "$HASH_DIR1" >DIR1_a ' # saving this output for later test_expect_success "ipfs object links $HASH_DIR1 works" ' - ipfs object links $HASH_DIR1 > DIR1_objlink + ipfs object links $HASH_DIR1 > DIR1_objlink ' test_expect_success "added dir was pinned recursively" ' - test_pin_flag $HASH_DIR1 recursive true + test_pin_flag $HASH_DIR1 recursive true ' test_expect_success "rest were pinned indirectly" ' - test_pin_flag "$HASH_FILE6" indirect true - test_pin_flag "$HASH_FILE5" indirect true - test_pin_flag "$HASH_FILE4" indirect true - test_pin_flag "$HASH_FILE3" indirect true - test_pin_flag "$HASH_FILE2" indirect true - test_pin_flag "$HASH_FILE1" indirect true - test_pin_flag "$HASH_DIR3" indirect true - test_pin_flag "$HASH_DIR4" indirect true - test_pin_flag "$HASH_DIR2" indirect true + test_pin_flag "$HASH_FILE6" indirect true + test_pin_flag "$HASH_FILE5" indirect true + test_pin_flag "$HASH_FILE4" indirect true + test_pin_flag "$HASH_FILE3" indirect true + test_pin_flag "$HASH_FILE2" indirect true + test_pin_flag "$HASH_FILE1" indirect true + test_pin_flag "$HASH_DIR3" indirect true + test_pin_flag "$HASH_DIR4" indirect true + test_pin_flag "$HASH_DIR2" indirect true ' test_expect_success "added dir was NOT pinned indirectly" ' - test_pin_flag "$HASH_DIR1" indirect false + test_pin_flag "$HASH_DIR1" indirect false ' test_expect_success "nothing is pinned directly" ' - ipfs pin ls --type=direct >actual4 && - test_must_be_empty actual4 + ipfs pin ls --type=direct >actual4 && + test_must_be_empty actual4 ' test_expect_success "'ipfs repo gc' succeeds" ' - ipfs repo gc >gc_out_actual + ipfs repo gc >gc_out_actual ' test_expect_success "objects are still there" ' - cat FILE6_a FILE5_a FILE4_a FILE3_a FILE2_a FILE1_a >expected45 && - cat DIR3_a DIR4_a DIR2_a DIR1_a >>expected45 && - ipfs cat "$HASH_FILE6" >actual45 && - ipfs cat "$HASH_FILE5" >>actual45 && - ipfs cat "$HASH_FILE4" >>actual45 && - ipfs cat "$HASH_FILE3" >>actual45 && - ipfs cat "$HASH_FILE2" >>actual45 && - ipfs cat "$HASH_FILE1" >>actual45 && - ipfs ls "$HASH_DIR3" >>actual45 && - ipfs ls "$HASH_DIR4" >>actual45 && - ipfs ls "$HASH_DIR2" >>actual45 && - ipfs ls "$HASH_DIR1" >>actual45 && - test_cmp expected45 actual45 + cat FILE6_a FILE5_a FILE4_a FILE3_a FILE2_a FILE1_a >expected45 && + cat DIR3_a DIR4_a DIR2_a DIR1_a >>expected45 && + ipfs cat "$HASH_FILE6" >actual45 && + ipfs cat "$HASH_FILE5" >>actual45 && + ipfs cat "$HASH_FILE4" >>actual45 && + ipfs cat "$HASH_FILE3" >>actual45 && + ipfs cat "$HASH_FILE2" >>actual45 && + ipfs cat "$HASH_FILE1" >>actual45 && + ipfs ls "$HASH_DIR3" >>actual45 && + ipfs ls "$HASH_DIR4" >>actual45 && + ipfs ls "$HASH_DIR2" >>actual45 && + ipfs ls "$HASH_DIR1" >>actual45 && + test_cmp expected45 actual45 ' test_expect_success "remove dir recursive pin succeeds" ' - echo "unpinned $HASH_DIR1" >expected5 && - ipfs pin rm -r "$HASH_DIR1" >actual5 && - test_cmp expected5 actual5 + echo "unpinned $HASH_DIR1" >expected5 && + ipfs pin rm -r "$HASH_DIR1" >actual5 && + test_cmp expected5 actual5 ' test_expect_success "none are pinned any more" ' - test_pin "$HASH_FILE6" && - test_pin "$HASH_FILE5" && - test_pin "$HASH_FILE4" && - test_pin "$HASH_FILE3" && - test_pin "$HASH_FILE2" && - test_pin "$HASH_FILE1" && - test_pin "$HASH_DIR3" && - test_pin "$HASH_DIR4" && - test_pin "$HASH_DIR2" && - test_pin "$HASH_DIR1" + test_pin "$HASH_FILE6" && + test_pin "$HASH_FILE5" && + test_pin "$HASH_FILE4" && + test_pin "$HASH_FILE3" && + test_pin "$HASH_FILE2" && + test_pin "$HASH_FILE1" && + test_pin "$HASH_DIR3" && + test_pin "$HASH_DIR4" && + test_pin "$HASH_DIR2" && + test_pin "$HASH_DIR1" ' test_expect_success "pin some directly and indirectly" ' - ipfs pin add -r=false "$HASH_DIR1" >actual7 && - ipfs pin add -r=true "$HASH_DIR2" >>actual7 && - ipfs pin add -r=false "$HASH_FILE1" >>actual7 && - echo "pinned $HASH_DIR1 directly" >expected7 && - echo "pinned $HASH_DIR2 recursively" >>expected7 && - echo "pinned $HASH_FILE1 directly" >>expected7 && - test_cmp expected7 actual7 + ipfs pin add -r=false "$HASH_DIR1" >actual7 && + ipfs pin add -r=true "$HASH_DIR2" >>actual7 && + ipfs pin add -r=false "$HASH_FILE1" >>actual7 && + echo "pinned $HASH_DIR1 directly" >expected7 && + echo "pinned $HASH_DIR2 recursively" >>expected7 && + echo "pinned $HASH_FILE1 directly" >>expected7 && + test_cmp expected7 actual7 ' test_expect_success "pin lists look good" ' - test_pin $HASH_DIR1 direct && - test_pin $HASH_DIR2 recursive && - test_pin $HASH_DIR3 && - test_pin $HASH_DIR4 indirect && - test_pin $HASH_FILE1 indirect direct && - test_pin $HASH_FILE2 indirect && - test_pin $HASH_FILE3 && - test_pin $HASH_FILE4 indirect && - test_pin $HASH_FILE5 && - test_pin $HASH_FILE6 indirect + test_pin $HASH_DIR1 direct && + test_pin $HASH_DIR2 recursive && + test_pin $HASH_DIR3 && + test_pin $HASH_DIR4 indirect && + test_pin $HASH_FILE1 indirect direct && + test_pin $HASH_FILE2 indirect && + test_pin $HASH_FILE3 && + test_pin $HASH_FILE4 indirect && + test_pin $HASH_FILE5 && + test_pin $HASH_FILE6 indirect ' test_expect_success "'ipfs repo gc' succeeds" ' - ipfs repo gc >gc_out_actual2 && - echo "removed $HASH_FILE3" > gc_out_exp2 && - echo "removed $HASH_FILE5" >> gc_out_exp2 && - echo "removed $HASH_DIR3" >> gc_out_exp2 && - test_includes_lines gc_out_exp2 gc_out_actual2 + ipfs repo gc >gc_out_actual2 && + echo "removed $HASH_FILE3" > gc_out_exp2 && + echo "removed $HASH_FILE5" >> gc_out_exp2 && + echo "removed $HASH_DIR3" >> gc_out_exp2 && + test_includes_lines gc_out_exp2 gc_out_actual2 ' # use object links for HASH_DIR1 here because its children # no longer exist test_expect_success "some objects are still there" ' - cat FILE6_a FILE4_a FILE2_a FILE1_a >expected8 && - cat DIR4_a DIR2_a DIR1_objlink >>expected8 && - ipfs cat "$HASH_FILE6" >actual8 && - ipfs cat "$HASH_FILE4" >>actual8 && - ipfs cat "$HASH_FILE2" >>actual8 && - ipfs cat "$HASH_FILE1" >>actual8 && - ipfs ls "$HASH_DIR4" >>actual8 && - ipfs ls "$HASH_DIR2" >>actual8 && - ipfs object links "$HASH_DIR1" >>actual8 && - test_cmp expected8 actual8 + cat FILE6_a FILE4_a FILE2_a FILE1_a >expected8 && + cat DIR4_a DIR2_a DIR1_objlink >>expected8 && + ipfs cat "$HASH_FILE6" >actual8 && + ipfs cat "$HASH_FILE4" >>actual8 && + ipfs cat "$HASH_FILE2" >>actual8 && + ipfs cat "$HASH_FILE1" >>actual8 && + ipfs ls "$HASH_DIR4" >>actual8 && + ipfs ls "$HASH_DIR2" >>actual8 && + ipfs object links "$HASH_DIR1" >>actual8 && + test_cmp expected8 actual8 ' # todo: make this faster somehow. test_expect_success "some are no longer there" ' - test_must_fail ipfs cat "$HASH_FILE5" && - test_must_fail ipfs cat "$HASH_FILE3" && - test_must_fail ipfs ls "$HASH_DIR3" + test_must_fail ipfs cat "$HASH_FILE5" && + test_must_fail ipfs cat "$HASH_FILE3" && + test_must_fail ipfs ls "$HASH_DIR3" ' test_expect_success "recursive pin fails without objects" ' - ipfs pin rm -r=false "$HASH_DIR1" && - test_must_fail ipfs pin add -r "$HASH_DIR1" 2>err_expected8 && - grep "pin: merkledag: not found" err_expected8 || - test_fsh cat err_expected8 + ipfs pin rm -r=false "$HASH_DIR1" && + test_must_fail ipfs pin add -r "$HASH_DIR1" 2>err_expected8 && + grep "pin: merkledag: not found" err_expected8 || + test_fsh cat err_expected8 ' test_expect_success "test add nopin file" ' - echo "test nopin data" > test_nopin_data && - NOPINHASH=$(ipfs add -q --pin=false test_nopin_data) && - test_pin_flag "$NOPINHASH" direct false && - test_pin_flag "$NOPINHASH" indirect false && - test_pin_flag "$NOPINHASH" recursive false + echo "test nopin data" > test_nopin_data && + NOPINHASH=$(ipfs add -q --pin=false test_nopin_data) && + test_pin_flag "$NOPINHASH" direct false && + test_pin_flag "$NOPINHASH" indirect false && + test_pin_flag "$NOPINHASH" recursive false ' test_expect_success "test add nopin dir" ' - mkdir nopin_dir1 && - echo "some nopin text 1" >nopin_dir1/file1 && - echo "some nopin text 2" >nopin_dir1/file2 && - ipfs add -q -r --pin=false nopin_dir1 | tail -n1 >actual1 && - echo "$HASH_NOPINDIR" >expected1 && - test_cmp actual1 expected1 && - test_pin_flag "$HASH_NOPINDIR" direct false && - test_pin_flag "$HASH_NOPINDIR" indirect false && - test_pin_flag "$HASH_NOPINDIR" recursive false && - test_pin_flag "$HASH_NOPIN_FILE1" direct false && - test_pin_flag "$HASH_NOPIN_FILE1" indirect false && - test_pin_flag "$HASH_NOPIN_FILE1" recursive false && - test_pin_flag "$HASH_NOPIN_FILE2" direct false && - test_pin_flag "$HASH_NOPIN_FILE2" indirect false && - test_pin_flag "$HASH_NOPIN_FILE2" recursive false + mkdir nopin_dir1 && + echo "some nopin text 1" >nopin_dir1/file1 && + echo "some nopin text 2" >nopin_dir1/file2 && + ipfs add -q -r --pin=false nopin_dir1 | tail -n1 >actual1 && + echo "$HASH_NOPINDIR" >expected1 && + test_cmp actual1 expected1 && + test_pin_flag "$HASH_NOPINDIR" direct false && + test_pin_flag "$HASH_NOPINDIR" indirect false && + test_pin_flag "$HASH_NOPINDIR" recursive false && + test_pin_flag "$HASH_NOPIN_FILE1" direct false && + test_pin_flag "$HASH_NOPIN_FILE1" indirect false && + test_pin_flag "$HASH_NOPIN_FILE1" recursive false && + test_pin_flag "$HASH_NOPIN_FILE2" direct false && + test_pin_flag "$HASH_NOPIN_FILE2" indirect false && + test_pin_flag "$HASH_NOPIN_FILE2" recursive false ' FICTIONAL_HASH="QmXV4f9v8a56MxWKBhP3ETsz4EaafudU1cKfPaaJnenc48" test_launch_ipfs_daemon test_expect_success "test unpinning a hash that's not pinned" " - test_expect_code 1 ipfs pin rm $FICTIONAL_HASH --timeout=2s - test_expect_code 1 ipfs pin rm $FICTIONAL_HASH/a --timeout=2s - test_expect_code 1 ipfs pin rm $FICTIONAL_HASH/a/b --timeout=2s + test_expect_code 1 ipfs pin rm $FICTIONAL_HASH --timeout=2s + test_expect_code 1 ipfs pin rm $FICTIONAL_HASH/a --timeout=2s + test_expect_code 1 ipfs pin rm $FICTIONAL_HASH/a/b --timeout=2s " test_kill_ipfs_daemon diff --git a/test/sharness/t0082-repo-gc-auto.sh b/test/sharness/t0082-repo-gc-auto.sh index 2030fc4707a..04cfdb0bd45 100755 --- a/test/sharness/t0082-repo-gc-auto.sh +++ b/test/sharness/t0082-repo-gc-auto.sh @@ -12,61 +12,61 @@ skip_all="skipping auto repo gc tests until they can be fixed" test_done check_ipfs_storage() { - ipfs config Datastore.StorageMax + ipfs config Datastore.StorageMax } test_init_ipfs test_expect_success "generate 2 600 kB files and 2 MB file using go-random" ' - random 600k 41 >600k1 && - random 600k 42 >600k2 && - random 2M 43 >2M + random 600k 41 >600k1 && + random 600k 42 >600k2 && + random 2M 43 >2M ' test_expect_success "set ipfs gc watermark, storage max, and gc timeout" ' - test_config_set Datastore.StorageMax "2MB" && - test_config_set --json Datastore.StorageGCWatermark 60 && - test_config_set Datastore.GCPeriod "20ms" + test_config_set Datastore.StorageMax "2MB" && + test_config_set --json Datastore.StorageGCWatermark 60 && + test_config_set Datastore.GCPeriod "20ms" ' test_launch_ipfs_daemon --enable-gc test_gc() { - test_expect_success "adding data below watermark doesn't trigger auto gc" ' - ipfs add 600k1 >/dev/null && - disk_usage "$IPFS_PATH/blocks" >expected && - go-sleep 40ms && - disk_usage "$IPFS_PATH/blocks" >actual && - test_cmp expected actual - ' + test_expect_success "adding data below watermark doesn't trigger auto gc" ' + ipfs add 600k1 >/dev/null && + disk_usage "$IPFS_PATH/blocks" >expected && + go-sleep 40ms && + disk_usage "$IPFS_PATH/blocks" >actual && + test_cmp expected actual + ' - test_expect_success "adding data beyond watermark triggers auto gc" ' - HASH=`ipfs add -q 600k2` && - ipfs pin rm -r $HASH && - go-sleep 40ms && - DU=$(disk_usage "$IPFS_PATH/blocks") && - if test $(uname -s) = "Darwin"; then - test "$DU" -lt 1400 # 60% of 2MB - else - test "$DU" -lt 1000000 - fi - ' + test_expect_success "adding data beyond watermark triggers auto gc" ' + HASH=`ipfs add -q 600k2` && + ipfs pin rm -r $HASH && + go-sleep 40ms && + DU=$(disk_usage "$IPFS_PATH/blocks") && + if test $(uname -s) = "Darwin"; then + test "$DU" -lt 1400 # 60% of 2MB + else + test "$DU" -lt 1000000 + fi + ' } #TODO: conditional GC test is disabled due to files size bug in ipfs add #test_expect_success "adding data beyond storageMax fails" ' -# test_must_fail ipfs add 2M 2>add_fail_out +# test_must_fail ipfs add 2M 2>add_fail_out #' #test_expect_success "ipfs add not enough space message looks good" ' -# echo "Error: file size exceeds slack space allowed by storageMax. Maybe unpin some files?" >add_fail_exp && -# test_cmp add_fail_exp add_fail_out +# echo "Error: file size exceeds slack space allowed by storageMax. Maybe unpin some files?" >add_fail_exp && +# test_cmp add_fail_exp add_fail_out #' test_expect_success "periodic auto gc stress test" ' - for i in $(test_seq 1 20) - do - test_gc - done + for i in $(test_seq 1 20) + do + test_gc + done ' test_kill_ipfs_daemon diff --git a/test/sharness/t0083-repo-fsck.sh b/test/sharness/t0083-repo-fsck.sh index 438d1f166b8..8bfea7afdca 100755 --- a/test/sharness/t0083-repo-fsck.sh +++ b/test/sharness/t0083-repo-fsck.sh @@ -19,22 +19,22 @@ test_init_ipfs # repo.lock and datastore/LOCK being empty test_expect_success "'ipfs repo fsck' succeeds with no daemon running empty repo.lock" ' - mkdir -p $IPFS_PATH && - mkdir -p $IPFS_PATH/datastore && - touch $IPFS_PATH/datastore/LOCK && - touch $IPFS_PATH/repo.lock && - printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api && - ipfs repo fsck > fsck_out_actual1 + mkdir -p $IPFS_PATH && + mkdir -p $IPFS_PATH/datastore && + touch $IPFS_PATH/datastore/LOCK && + touch $IPFS_PATH/repo.lock && + printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api && + ipfs repo fsck > fsck_out_actual1 ' test_expect_success "'ipfs repo fsck' output looks good with no daemon" ' - grep "Lockfiles have been removed." fsck_out_actual1 + grep "Lockfiles have been removed." fsck_out_actual1 ' # Make sure the files are actually removed test_expect_success "'ipfs repo fsck' confirm file deletion" ' - test ! -e "$IPFS_PATH/repo.lock" && - test ! -e "$IPFS_PATH/datastore/LOCK" && - test ! -e "$IPFS_PATH/api" + test ! -e "$IPFS_PATH/repo.lock" && + test ! -e "$IPFS_PATH/datastore/LOCK" && + test ! -e "$IPFS_PATH/api" ' # Try with all lock files present: repo.lock, api, and datastore/LOCK with @@ -42,20 +42,20 @@ test_expect_success "'ipfs repo fsck' confirm file deletion" ' # non-zero repo.lock issue test_expect_success "'ipfs repo fsck' succeeds with no daemon running non-zero repo.lock" ' - mkdir -p $IPFS_PATH && - printf ":D" > $IPFS_PATH/repo.lock && - touch $IPFS_PATH/datastore/LOCK && - ipfs repo fsck > fsck_out_actual1b + mkdir -p $IPFS_PATH && + printf ":D" > $IPFS_PATH/repo.lock && + touch $IPFS_PATH/datastore/LOCK && + ipfs repo fsck > fsck_out_actual1b ' test_expect_success "'ipfs repo fsck' output looks good with no daemon" ' - grep "Lockfiles have been removed." fsck_out_actual1b + grep "Lockfiles have been removed." fsck_out_actual1b ' # Make sure the files are actually removed test_expect_success "'ipfs repo fsck' confirm file deletion" ' - test ! -e "$IPFS_PATH/repo.lock" && - test ! -e "$IPFS_PATH/datastore/LOCK" && - test ! -e "$IPFS_PATH/api" + test ! -e "$IPFS_PATH/repo.lock" && + test ! -e "$IPFS_PATH/datastore/LOCK" && + test ! -e "$IPFS_PATH/api" ' ######################## @@ -64,56 +64,56 @@ test_expect_success "'ipfs repo fsck' confirm file deletion" ' # Try with locks api and datastore/LOCK test_expect_success "'ipfs repo fsck' succeeds partial lock" ' - printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api && - touch $IPFS_PATH/datastore/LOCK && - ipfs repo fsck > fsck_out_actual2 + printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api && + touch $IPFS_PATH/datastore/LOCK && + ipfs repo fsck > fsck_out_actual2 ' test_expect_success "'ipfs repo fsck' output looks good with no daemon" ' - grep "Lockfiles have been removed." fsck_out_actual2 + grep "Lockfiles have been removed." fsck_out_actual2 ' # Make sure the files are actually removed test_expect_success "'ipfs repo fsck' confirm file deletion" ' - test ! -e "$IPFS_PATH/repo.lock" && - test ! -e "$IPFS_PATH/datastore/LOCK" && - test ! -e "$IPFS_PATH/api" + test ! -e "$IPFS_PATH/repo.lock" && + test ! -e "$IPFS_PATH/datastore/LOCK" && + test ! -e "$IPFS_PATH/api" ' # Try with locks api and repo.lock test_expect_success "'ipfs repo fsck' succeeds partial lock" ' - printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api && - touch $IPFS_PATH/repo.lock && - ipfs repo fsck > fsck_out_actual3 + printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api && + touch $IPFS_PATH/repo.lock && + ipfs repo fsck > fsck_out_actual3 ' test_expect_success "'ipfs repo fsck' output looks good with no daemon" ' - grep "Lockfiles have been removed." fsck_out_actual3 + grep "Lockfiles have been removed." fsck_out_actual3 ' # Make sure the files are actually removed test_expect_success "'ipfs repo fsck' confirm file deletion" ' - test ! -e "$IPFS_PATH/repo.lock" && - test ! -e "$IPFS_PATH/datastore/LOCK" && - test ! -e "$IPFS_PATH/api" + test ! -e "$IPFS_PATH/repo.lock" && + test ! -e "$IPFS_PATH/datastore/LOCK" && + test ! -e "$IPFS_PATH/api" ' # Try with locks repo.lock and datastore test_expect_success "'ipfs repo fsck' succeeds partial lock" ' - touch $IPFS_PATH/repo.lock && - touch $IPFS_PATH/datastore/LOCK && - ipfs repo fsck > fsck_out_actual4 + touch $IPFS_PATH/repo.lock && + touch $IPFS_PATH/datastore/LOCK && + ipfs repo fsck > fsck_out_actual4 ' test_expect_success "'ipfs repo fsck' output looks good with no daemon" ' - grep "Lockfiles have been removed." fsck_out_actual4 + grep "Lockfiles have been removed." fsck_out_actual4 ' # Make sure the files are actually removed test_expect_success "'ipfs repo fsck' confirm file deletion" ' - test ! -e "$IPFS_PATH/repo.lock" && - test ! -e "$IPFS_PATH/datastore/LOCK" && - test ! -e "$IPFS_PATH/api" + test ! -e "$IPFS_PATH/repo.lock" && + test ! -e "$IPFS_PATH/datastore/LOCK" && + test ! -e "$IPFS_PATH/api" ' ####################### @@ -122,51 +122,51 @@ test_expect_success "'ipfs repo fsck' confirm file deletion" ' # Try with single locks repo.lock test_expect_success "'ipfs repo fsck' succeeds partial lock" ' - touch $IPFS_PATH/repo.lock && - ipfs repo fsck > fsck_out_actual5 + touch $IPFS_PATH/repo.lock && + ipfs repo fsck > fsck_out_actual5 ' test_expect_success "'ipfs repo fsck' output looks good with no daemon" ' - grep "Lockfiles have been removed." fsck_out_actual5 + grep "Lockfiles have been removed." fsck_out_actual5 ' # Make sure the files are actually removed test_expect_success "'ipfs repo fsck' confirm file deletion" ' - test ! -e "$IPFS_PATH/repo.lock" && - test ! -e "$IPFS_PATH/datastore/LOCK" && - test ! -e "$IPFS_PATH/api" + test ! -e "$IPFS_PATH/repo.lock" && + test ! -e "$IPFS_PATH/datastore/LOCK" && + test ! -e "$IPFS_PATH/api" ' # Try with single locks datastore/LOCK test_expect_success "'ipfs repo fsck' succeeds partial lock" ' - touch $IPFS_PATH/datastore/LOCK && - ipfs repo fsck > fsck_out_actual6 + touch $IPFS_PATH/datastore/LOCK && + ipfs repo fsck > fsck_out_actual6 ' test_expect_success "'ipfs repo fsck' output looks good with no daemon" ' - grep "Lockfiles have been removed." fsck_out_actual6 + grep "Lockfiles have been removed." fsck_out_actual6 ' # Make sure the files are actually removed test_expect_success "'ipfs repo fsck' confirm file deletion" ' - test ! -e "$IPFS_PATH/repo.lock" && - test ! -e "$IPFS_PATH/datastore/LOCK" && - test ! -e "$IPFS_PATH/api" + test ! -e "$IPFS_PATH/repo.lock" && + test ! -e "$IPFS_PATH/datastore/LOCK" && + test ! -e "$IPFS_PATH/api" ' # Try with single lock api test_expect_success "'ipfs repo fsck' succeeds partial lock" ' - printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api && - ipfs repo fsck > fsck_out_actual7 + printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api && + ipfs repo fsck > fsck_out_actual7 ' test_expect_success "'ipfs repo fsck' output looks good with no daemon" ' - grep "Lockfiles have been removed." fsck_out_actual7 + grep "Lockfiles have been removed." fsck_out_actual7 ' # Make sure the files are actually removed test_expect_success "'ipfs repo fsck' confirm file deletion" ' - test ! -e "$IPFS_PATH/repo.lock" && - test ! -e "$IPFS_PATH/datastore/LOCK" && - test ! -e "$IPFS_PATH/api" + test ! -e "$IPFS_PATH/repo.lock" && + test ! -e "$IPFS_PATH/datastore/LOCK" && + test ! -e "$IPFS_PATH/api" ' ########################## @@ -177,12 +177,12 @@ test_launch_ipfs_daemon # Daemon is running -> command doesn't run test_expect_success "'ipfs repo fsck' fails with daemon running" ' - ! (ipfs repo fsck 2>fsck_out_actual8 ) + ! (ipfs repo fsck 2>fsck_out_actual8 ) ' test_expect_success "'ipfs repo fsck' output looks good with daemon" ' - grep "Error: ipfs daemon is running" fsck_out_actual8 + grep "Error: ipfs daemon is running" fsck_out_actual8 ' test_kill_ipfs_daemon diff --git a/test/sharness/t0084-repo-read-rehash.sh b/test/sharness/t0084-repo-read-rehash.sh index 80bbc936d23..cb887f9f5bf 100755 --- a/test/sharness/t0084-repo-read-rehash.sh +++ b/test/sharness/t0084-repo-read-rehash.sh @@ -21,31 +21,31 @@ BS_BLOCK2="CK/CIQNYWBOKHY7TCY7FUOBXKVJ66YRMARDT3KC7PPY6UWWPZR4YA67CKQ.data" test_expect_success 'blocks are swapped' ' - ipfs cat $H_BLOCK2 > noswap && - cp -f "$IPFS_PATH/blocks/$BS_BLOCK1" "$IPFS_PATH/blocks/$BS_BLOCK2" && - ipfs cat $H_BLOCK2 > swap && - test_must_fail test_cmp noswap swap + ipfs cat $H_BLOCK2 > noswap && + cp -f "$IPFS_PATH/blocks/$BS_BLOCK1" "$IPFS_PATH/blocks/$BS_BLOCK2" && + ipfs cat $H_BLOCK2 > swap && + test_must_fail test_cmp noswap swap ' ipfs config --bool Datastore.HashOnRead true test_check_bad_blocks() { - test_expect_success 'getting modified block fails' ' - (test_must_fail ipfs cat $H_BLOCK2 2> err_msg) && - grep "block in storage has different hash than requested" err_msg - ' - - test_expect_success "block shows up in repo verify" ' - test_expect_code 1 ipfs repo verify > verify_out && - grep "$H_BLOCK2" verify_out - ' + test_expect_success 'getting modified block fails' ' + (test_must_fail ipfs cat $H_BLOCK2 2> err_msg) && + grep "block in storage has different hash than requested" err_msg + ' + + test_expect_success "block shows up in repo verify" ' + test_expect_code 1 ipfs repo verify > verify_out && + grep "$H_BLOCK2" verify_out + ' } test_check_bad_blocks test_expect_success "can add and cat a raw-leaf file" ' - HASH=$(echo "stuff" | ipfs add -q --raw-leaves) && - ipfs cat $HASH > /dev/null + HASH=$(echo "stuff" | ipfs add -q --raw-leaves) && + ipfs cat $HASH > /dev/null ' test_launch_ipfs_daemon diff --git a/test/sharness/t0085-pins.sh b/test/sharness/t0085-pins.sh index 94889dc8a4a..4f17f00c916 100755 --- a/test/sharness/t0085-pins.sh +++ b/test/sharness/t0085-pins.sh @@ -10,91 +10,91 @@ test_description="Test ipfs pinning operations" test_pins() { - EXTRA_ARGS=$1 - - test_expect_success "create some hashes" ' - HASH_A=$(echo "A" | ipfs add -q --pin=false) && - HASH_B=$(echo "B" | ipfs add -q --pin=false) && - HASH_C=$(echo "C" | ipfs add -q --pin=false) && - HASH_D=$(echo "D" | ipfs add -q --pin=false) && - HASH_E=$(echo "E" | ipfs add -q --pin=false) && - HASH_F=$(echo "F" | ipfs add -q --pin=false) && - HASH_G=$(echo "G" | ipfs add -q --pin=false) - ' - - test_expect_success "put all those hashes in a file" ' - echo $HASH_A > hashes && - echo $HASH_B >> hashes && - echo $HASH_C >> hashes && - echo $HASH_D >> hashes && - echo $HASH_E >> hashes && - echo $HASH_F >> hashes && - echo $HASH_G >> hashes - ' - - test_expect_success "'ipfs pin add $EXTRA_ARGS' via stdin" ' - cat hashes | ipfs pin add $EXTRA_ARGS - ' - - test_expect_success "unpin those hashes" ' - cat hashes | ipfs pin rm - ' + EXTRA_ARGS=$1 + + test_expect_success "create some hashes" ' + HASH_A=$(echo "A" | ipfs add -q --pin=false) && + HASH_B=$(echo "B" | ipfs add -q --pin=false) && + HASH_C=$(echo "C" | ipfs add -q --pin=false) && + HASH_D=$(echo "D" | ipfs add -q --pin=false) && + HASH_E=$(echo "E" | ipfs add -q --pin=false) && + HASH_F=$(echo "F" | ipfs add -q --pin=false) && + HASH_G=$(echo "G" | ipfs add -q --pin=false) + ' + + test_expect_success "put all those hashes in a file" ' + echo $HASH_A > hashes && + echo $HASH_B >> hashes && + echo $HASH_C >> hashes && + echo $HASH_D >> hashes && + echo $HASH_E >> hashes && + echo $HASH_F >> hashes && + echo $HASH_G >> hashes + ' + + test_expect_success "'ipfs pin add $EXTRA_ARGS' via stdin" ' + cat hashes | ipfs pin add $EXTRA_ARGS + ' + + test_expect_success "unpin those hashes" ' + cat hashes | ipfs pin rm + ' } RANDOM_HASH=Qme8uX5n9hn15pw9p6WcVKoziyyC9LXv4LEgvsmKMULjnV test_pins_error_reporting() { - EXTRA_ARGS=$1 + EXTRA_ARGS=$1 - test_expect_success "'ipfs pin add $EXTRA_ARGS' on non-existent hash should fail" ' - test_must_fail ipfs pin add $EXTRA_ARGS $RANDOM_HASH 2> err && - grep -q "not found" err - ' + test_expect_success "'ipfs pin add $EXTRA_ARGS' on non-existent hash should fail" ' + test_must_fail ipfs pin add $EXTRA_ARGS $RANDOM_HASH 2> err && + grep -q "not found" err + ' } test_pin_dag_init() { - EXTRA_ARGS=$1 + EXTRA_ARGS=$1 - test_expect_success "'ipfs add $EXTRA_ARGS --pin=false' 1MB file" ' - random 1048576 56 > afile && - HASH=`ipfs add $EXTRA_ARGS --pin=false -q afile` - ' + test_expect_success "'ipfs add $EXTRA_ARGS --pin=false' 1MB file" ' + random 1048576 56 > afile && + HASH=`ipfs add $EXTRA_ARGS --pin=false -q afile` + ' } test_pin_dag() { - test_pin_dag_init $1 - - test_expect_success "'ipfs pin add --progress' file" ' - ipfs pin add --recursive=true $HASH - ' - - test_expect_success "'ipfs pin rm' file" ' - ipfs pin rm $HASH - ' - - test_expect_success "remove part of the dag" ' - PART=`ipfs refs $HASH | head -1` && - ipfs block rm $PART - ' - - test_expect_success "pin file, should fail" ' - test_must_fail ipfs pin add --recursive=true $HASH 2> err && - cat err && - grep -q "not found" err - ' + test_pin_dag_init $1 + + test_expect_success "'ipfs pin add --progress' file" ' + ipfs pin add --recursive=true $HASH + ' + + test_expect_success "'ipfs pin rm' file" ' + ipfs pin rm $HASH + ' + + test_expect_success "remove part of the dag" ' + PART=`ipfs refs $HASH | head -1` && + ipfs block rm $PART + ' + + test_expect_success "pin file, should fail" ' + test_must_fail ipfs pin add --recursive=true $HASH 2> err && + cat err && + grep -q "not found" err + ' } test_pin_progress() { - test_pin_dag_init + test_pin_dag_init - test_expect_success "'ipfs pin add --progress' file" ' - ipfs pin add --progress $HASH 2> err - ' + test_expect_success "'ipfs pin add --progress' file" ' + ipfs pin add --progress $HASH 2> err + ' - test_expect_success "pin progress reported correctly" ' - cat err - grep -q " 5 nodes" err - ' + test_expect_success "pin progress reported correctly" ' + cat err + grep -q " 5 nodes" err + ' } test_init_ipfs diff --git a/test/sharness/t0086-repo-verify.sh b/test/sharness/t0086-repo-verify.sh index b0527e8b487..f106b7f1c0e 100755 --- a/test/sharness/t0086-repo-verify.sh +++ b/test/sharness/t0086-repo-verify.sh @@ -11,50 +11,50 @@ test_description="Test ipfs repo fsck" test_init_ipfs sort_rand() { - case `uname` in - Linux) - sort -R - ;; - Darwin) - ruby -e 'puts STDIN.readlines.shuffle' - ;; - *) - echo "unsupported system: $(uname)" - esac + case `uname` in + Linux) + sort -R + ;; + Darwin) + ruby -e 'puts STDIN.readlines.shuffle' + ;; + *) + echo "unsupported system: $(uname)" + esac } check_random_corruption() { - to_break=$(find "$IPFS_PATH/blocks" -type f | grep -v README | grep -v SHARDING | sort_rand | head -n 1) + to_break=$(find "$IPFS_PATH/blocks" -type f | grep -v README | grep -v SHARDING | sort_rand | head -n 1) - test_expect_success "back up file and overwrite it" ' - cp "$to_break" backup_file && - echo "this is super broken" > "$to_break" - ' + test_expect_success "back up file and overwrite it" ' + cp "$to_break" backup_file && + echo "this is super broken" > "$to_break" + ' - test_expect_success "repo verify detects failure" ' - test_expect_code 1 ipfs repo verify - ' + test_expect_success "repo verify detects failure" ' + test_expect_code 1 ipfs repo verify + ' - test_expect_success "replace the object" ' - cp backup_file "$to_break" - ' + test_expect_success "replace the object" ' + cp backup_file "$to_break" + ' - test_expect_success "ipfs repo verify passes just fine now" ' - ipfs repo verify - ' + test_expect_success "ipfs repo verify passes just fine now" ' + ipfs repo verify + ' } test_expect_success "create some files" ' - random-files -depth=3 -dirs=4 -files=10 foobar > /dev/null + random-files -depth=3 -dirs=4 -files=10 foobar > /dev/null ' test_expect_success "add them all" ' - ipfs add -r -q foobar > /dev/null + ipfs add -r -q foobar > /dev/null ' for i in `seq 20` do - check_random_corruption + check_random_corruption done test_done diff --git a/test/sharness/t0087-repo-robust-gc.sh b/test/sharness/t0087-repo-robust-gc.sh index 2c92c785b4b..de5d0b7fbf0 100755 --- a/test/sharness/t0087-repo-robust-gc.sh +++ b/test/sharness/t0087-repo-robust-gc.sh @@ -11,145 +11,145 @@ set -e test_gc_robust_part1() { - test_expect_success "add a 1MB file with --raw-leaves" ' - random 1048576 56 > afile && - HASH1=`ipfs add --raw-leaves -q afile` - ' - - HASH1FILE=.ipfs/blocks/L3/CIQNIPL4GP62ZMNNSLZ2G33Z3T5VAN3YHCJTGT5FG45XWH5FGZRXL3A.data - - LEAF1=zb2rhZWKCMcHCfCym41ocwE5BhNQsEVLrwBkLEQaxJzRHHZch - LEAF1FILE=.ipfs/blocks/C2/AFKREIBKRCW7HF6NHR6DVWECQXC5RQC7U7PKHKTI53BYYZNQP23DK5FC2Y.data - - LEAF2=zb2rhdUpCuyoQPRtvBW8JhAEfPaNd9dBb3QQCMMWYS1V8hjBR - LEAF2FILE=.ipfs/blocks/Q6/BAFKREIDFSUIR43GJPHNDXXQA45GJVNRZBET3CRPUMYJCBLK3RTN7ZAMQ6Q - - LEAF3=zb2rhnwyvreekPqEMAbKqs35KYHxkNi7pXED7L2TfJKveTTva - LEAF4=zb2rhnvAVvfDDnndcfQkwqNgUm94ba3zBSXyJKCfVXwU4FXx2 - - test_expect_success "remove a leaf node from the repo manually" ' - rm "$LEAF1FILE" - ' - - test_expect_success "check that the node is removed" ' - test_must_fail ipfs cat $HASH1 - ' - - test_expect_success "'ipfs repo gc' should still be be fine" ' - ipfs repo gc - ' - - test_expect_success "corrupt the root node of 1MB file" ' - test -e "$HASH1FILE" && - dd if=/dev/zero of="$HASH1FILE" count=1 bs=100 conv=notrunc - ' - - test_expect_success "'ipfs repo gc' should abort without removing anything" ' - test_must_fail ipfs repo gc 2>&1 | tee gc_err && - grep -q "could not retrieve links for $HASH1" gc_err && - grep -q "aborted" gc_err - ' - - test_expect_success "leaf nodes were not removed after gc" ' - ipfs cat $LEAF3 > /dev/null && - ipfs cat $LEAF4 > /dev/null - ' - - test_expect_success "unpin the 1MB file" ' - ipfs pin rm $HASH1 - ' - - # make sure the permission problem is fixed on exit, otherwise cleanup - # will fail - trap "chmod 700 `dirname "$LEAF2FILE"` 2> /dev/null || true" 0 - - test_expect_success "create a permission problem" ' - chmod 500 `dirname "$LEAF2FILE"` && - test_must_fail ipfs block rm $LEAF2 2>&1 | tee block_rm_err && - grep -q "permission denied" block_rm_err - ' - - test_expect_success "'ipfs repo gc' should still run and remove as much as possible" ' - test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out && - grep -q "removed $HASH1" repo_gc_out && - grep -q "could not remove $LEAF2" repo_gc_out && - grep -q "removed $LEAF3" repo_gc_out && - grep -q "removed $LEAF4" repo_gc_out - ' - - test_expect_success "fix the permission problem" ' - chmod 700 `dirname "$LEAF2FILE"` - ' - - test_expect_success "'ipfs repo gc' should be ok now" ' - ipfs repo gc | tee repo_gc_out - grep -q "removed $LEAF2" repo_gc_out - ' + test_expect_success "add a 1MB file with --raw-leaves" ' + random 1048576 56 > afile && + HASH1=`ipfs add --raw-leaves -q afile` + ' + + HASH1FILE=.ipfs/blocks/L3/CIQNIPL4GP62ZMNNSLZ2G33Z3T5VAN3YHCJTGT5FG45XWH5FGZRXL3A.data + + LEAF1=zb2rhZWKCMcHCfCym41ocwE5BhNQsEVLrwBkLEQaxJzRHHZch + LEAF1FILE=.ipfs/blocks/C2/AFKREIBKRCW7HF6NHR6DVWECQXC5RQC7U7PKHKTI53BYYZNQP23DK5FC2Y.data + + LEAF2=zb2rhdUpCuyoQPRtvBW8JhAEfPaNd9dBb3QQCMMWYS1V8hjBR + LEAF2FILE=.ipfs/blocks/Q6/BAFKREIDFSUIR43GJPHNDXXQA45GJVNRZBET3CRPUMYJCBLK3RTN7ZAMQ6Q + + LEAF3=zb2rhnwyvreekPqEMAbKqs35KYHxkNi7pXED7L2TfJKveTTva + LEAF4=zb2rhnvAVvfDDnndcfQkwqNgUm94ba3zBSXyJKCfVXwU4FXx2 + + test_expect_success "remove a leaf node from the repo manually" ' + rm "$LEAF1FILE" + ' + + test_expect_success "check that the node is removed" ' + test_must_fail ipfs cat $HASH1 + ' + + test_expect_success "'ipfs repo gc' should still be be fine" ' + ipfs repo gc + ' + + test_expect_success "corrupt the root node of 1MB file" ' + test -e "$HASH1FILE" && + dd if=/dev/zero of="$HASH1FILE" count=1 bs=100 conv=notrunc + ' + + test_expect_success "'ipfs repo gc' should abort without removing anything" ' + test_must_fail ipfs repo gc 2>&1 | tee gc_err && + grep -q "could not retrieve links for $HASH1" gc_err && + grep -q "aborted" gc_err + ' + + test_expect_success "leaf nodes were not removed after gc" ' + ipfs cat $LEAF3 > /dev/null && + ipfs cat $LEAF4 > /dev/null + ' + + test_expect_success "unpin the 1MB file" ' + ipfs pin rm $HASH1 + ' + + # make sure the permission problem is fixed on exit, otherwise cleanup + # will fail + trap "chmod 700 `dirname "$LEAF2FILE"` 2> /dev/null || true" 0 + + test_expect_success "create a permission problem" ' + chmod 500 `dirname "$LEAF2FILE"` && + test_must_fail ipfs block rm $LEAF2 2>&1 | tee block_rm_err && + grep -q "permission denied" block_rm_err + ' + + test_expect_success "'ipfs repo gc' should still run and remove as much as possible" ' + test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out && + grep -q "removed $HASH1" repo_gc_out && + grep -q "could not remove $LEAF2" repo_gc_out && + grep -q "removed $LEAF3" repo_gc_out && + grep -q "removed $LEAF4" repo_gc_out + ' + + test_expect_success "fix the permission problem" ' + chmod 700 `dirname "$LEAF2FILE"` + ' + + test_expect_success "'ipfs repo gc' should be ok now" ' + ipfs repo gc | tee repo_gc_out + grep -q "removed $LEAF2" repo_gc_out + ' } test_gc_robust_part2() { - test_expect_success "add 1MB file normally (i.e., without raw leaves)" ' - random 1048576 56 > afile && - HASH2=`ipfs add -q afile` - ' - - LEAF1=QmSijovevteoY63Uj1uC5b8pkpDU5Jgyk2dYBqz3sMJUPc - LEAF1FILE=.ipfs/blocks/ME/CIQECF2K344QITW5S6E6H6T4DOXDDB2XA2V7BBOCIMN2VVF4Q77SMEY.data - - LEAF2=QmTbPEyrA1JyGUHFvmtx1FNZVzdBreMv8Hc8jV9sBRWhNA - LEAF2FILE=.ipfs/blocks/WM/CIQE4EFIJN2SUTQYSKMKNG7VM75W3SXT6LWJCHJJ73UAWN73WCX3WMY.data - - test_expect_success "add some additional unpinned content" ' - random 1000 3 > junk1 && - random 1000 4 > junk2 && - JUNK1=`ipfs add --pin=false -q junk1` && - JUNK2=`ipfs add --pin=false -q junk2` - ' - - test_expect_success "remove a leaf node from the repo manually" ' - rm "$LEAF1FILE" - ' - - test_expect_success "'ipfs repo gc' should abort" ' - test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out && - grep -q "could not retrieve links for $LEAF1" repo_gc_out && - grep -q "aborted" repo_gc_out - ' - - test_expect_success "test that garbage collector really aborted" ' - ipfs cat $JUNK1 > /dev/null && - ipfs cat $JUNK2 > /dev/null - ' - - test_expect_success "corrupt a key" ' - test -e "$LEAF2FILE" && - dd if=/dev/zero of="$LEAF2FILE" count=1 bs=100 conv=notrunc - ' - - test_expect_success "'ipfs repo gc' should abort with two errors" ' - test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out && - grep -q "could not retrieve links for $LEAF1" repo_gc_out && - grep -q "could not retrieve links for $LEAF2" repo_gc_out && - grep -q "aborted" repo_gc_out - ' - - test_expect_success "'ipfs repo gc --stream-errors' should abort and report each error separately" ' - test_must_fail ipfs repo gc --stream-errors 2>&1 | tee repo_gc_out && - grep -q "Error: could not retrieve links for $LEAF1" repo_gc_out && - grep -q "Error: could not retrieve links for $LEAF2" repo_gc_out && - grep -q "Error: garbage collection aborted" repo_gc_out - ' - - test_expect_success "unpin 1MB file" ' - ipfs pin rm $HASH2 - ' - - test_expect_success "'ipfs repo gc' should be fine now" ' - ipfs repo gc | tee repo_gc_out && - grep -q "removed $HASH2" repo_gc_out && - grep -q "removed $LEAF2" repo_gc_out - ' + test_expect_success "add 1MB file normally (i.e., without raw leaves)" ' + random 1048576 56 > afile && + HASH2=`ipfs add -q afile` + ' + + LEAF1=QmSijovevteoY63Uj1uC5b8pkpDU5Jgyk2dYBqz3sMJUPc + LEAF1FILE=.ipfs/blocks/ME/CIQECF2K344QITW5S6E6H6T4DOXDDB2XA2V7BBOCIMN2VVF4Q77SMEY.data + + LEAF2=QmTbPEyrA1JyGUHFvmtx1FNZVzdBreMv8Hc8jV9sBRWhNA + LEAF2FILE=.ipfs/blocks/WM/CIQE4EFIJN2SUTQYSKMKNG7VM75W3SXT6LWJCHJJ73UAWN73WCX3WMY.data + + test_expect_success "add some additional unpinned content" ' + random 1000 3 > junk1 && + random 1000 4 > junk2 && + JUNK1=`ipfs add --pin=false -q junk1` && + JUNK2=`ipfs add --pin=false -q junk2` + ' + + test_expect_success "remove a leaf node from the repo manually" ' + rm "$LEAF1FILE" + ' + + test_expect_success "'ipfs repo gc' should abort" ' + test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out && + grep -q "could not retrieve links for $LEAF1" repo_gc_out && + grep -q "aborted" repo_gc_out + ' + + test_expect_success "test that garbage collector really aborted" ' + ipfs cat $JUNK1 > /dev/null && + ipfs cat $JUNK2 > /dev/null + ' + + test_expect_success "corrupt a key" ' + test -e "$LEAF2FILE" && + dd if=/dev/zero of="$LEAF2FILE" count=1 bs=100 conv=notrunc + ' + + test_expect_success "'ipfs repo gc' should abort with two errors" ' + test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out && + grep -q "could not retrieve links for $LEAF1" repo_gc_out && + grep -q "could not retrieve links for $LEAF2" repo_gc_out && + grep -q "aborted" repo_gc_out + ' + + test_expect_success "'ipfs repo gc --stream-errors' should abort and report each error separately" ' + test_must_fail ipfs repo gc --stream-errors 2>&1 | tee repo_gc_out && + grep -q "Error: could not retrieve links for $LEAF1" repo_gc_out && + grep -q "Error: could not retrieve links for $LEAF2" repo_gc_out && + grep -q "Error: garbage collection aborted" repo_gc_out + ' + + test_expect_success "unpin 1MB file" ' + ipfs pin rm $HASH2 + ' + + test_expect_success "'ipfs repo gc' should be fine now" ' + ipfs repo gc | tee repo_gc_out && + grep -q "removed $HASH2" repo_gc_out && + grep -q "removed $LEAF2" repo_gc_out + ' } test_init_ipfs diff --git a/test/sharness/t0090-get.sh b/test/sharness/t0090-get.sh index d9b4ed59865..12e23819c29 100755 --- a/test/sharness/t0090-get.sh +++ b/test/sharness/t0090-get.sh @@ -11,138 +11,138 @@ test_description="Test get command" test_init_ipfs test_ipfs_get_flag() { - ext="$1"; shift - tar_flag="$1"; shift - flag="$@" - - test_expect_success "ipfs get $flag succeeds" ' - ipfs get "$HASH" '"$flag"' >actual - ' - - test_expect_success "ipfs get $flag output looks good" ' - printf "%s\n\n" "Saving archive to $HASH$ext" >expected && - test_cmp expected actual - ' - - test_expect_success "ipfs get $flag archive output is valid" ' - tar "$tar_flag" "$HASH$ext" && - test_cmp "$HASH" data && - rm "$HASH$ext" && - rm "$HASH" - ' + ext="$1"; shift + tar_flag="$1"; shift + flag="$@" + + test_expect_success "ipfs get $flag succeeds" ' + ipfs get "$HASH" '"$flag"' >actual + ' + + test_expect_success "ipfs get $flag output looks good" ' + printf "%s\n\n" "Saving archive to $HASH$ext" >expected && + test_cmp expected actual + ' + + test_expect_success "ipfs get $flag archive output is valid" ' + tar "$tar_flag" "$HASH$ext" && + test_cmp "$HASH" data && + rm "$HASH$ext" && + rm "$HASH" + ' } # we use a function so that we can run it both offline + online test_get_cmd() { - test_expect_success "'ipfs get --help' succeeds" ' - ipfs get --help >actual - ' - - test_expect_success "'ipfs get --help' output looks good" ' - egrep "ipfs get.*" actual >/dev/null || - test_fsh cat actual - ' - - test_expect_success "ipfs get succeeds" ' - echo "Hello Worlds!" >data && - HASH=`ipfs add -q data` && - ipfs get "$HASH" >actual - ' - - test_expect_success "ipfs get output looks good" ' - printf "%s\n\n" "Saving file(s) to $HASH" >expected && - test_cmp expected actual - ' - - test_expect_success "ipfs get file output looks good" ' - test_cmp "$HASH" data - ' - - test_expect_success "ipfs get DOES NOT error when trying to overwrite a file" ' - ipfs get "$HASH" >actual && - rm "$HASH" - ' - - test_expect_success "ipfs get works with raw leaves" ' - HASH2=$(ipfs add --raw-leaves -q data) && - ipfs get "$HASH2" >actual2 - ' - - test_expect_success "ipfs get output looks good" ' - printf "%s\n\n" "Saving file(s) to $HASH2" >expected2 && - test_cmp expected2 actual2 - ' - - test_expect_success "ipfs get file output looks good" ' - test_cmp "$HASH2" data - ' - - test_ipfs_get_flag ".tar" "-xf" -a - - test_ipfs_get_flag ".tar.gz" "-zxf" -a -C - - test_ipfs_get_flag ".tar.gz" "-zxf" -a -C -l 9 - - test_expect_success "ipfs get succeeds (directory)" ' - mkdir -p dir && - touch dir/a && - mkdir -p dir/b && - echo "Hello, Worlds!" >dir/b/c && - HASH2=`ipfs add -r -q dir | tail -n 1` && - ipfs get "$HASH2" >actual - ' - - test_expect_success "ipfs get output looks good (directory)" ' - printf "%s\n\n" "Saving file(s) to $HASH2" >expected && - test_cmp expected actual - ' - - test_expect_success "ipfs get output is valid (directory)" ' - test_cmp dir/a "$HASH2"/a && - test_cmp dir/b/c "$HASH2"/b/c && - rm -r "$HASH2" - ' - - test_expect_success "ipfs get -a -C succeeds (directory)" ' - ipfs get "$HASH2" -a -C >actual - ' - - test_expect_success "ipfs get -a -C output looks good (directory)" ' - printf "%s\n\n" "Saving archive to $HASH2.tar.gz" >expected && - test_cmp expected actual - ' - - test_expect_success "gzipped tar archive output is valid (directory)" ' - tar -zxf "$HASH2".tar.gz && - test_cmp dir/a "$HASH2"/a && - test_cmp dir/b/c "$HASH2"/b/c && - rm -r "$HASH2" - ' - - test_expect_success "ipfs get ../.. should fail" ' - echo "Error: invalid 'ipfs ref' path" >expected && - test_must_fail ipfs get ../.. 2>actual && - test_cmp expected actual - ' + test_expect_success "'ipfs get --help' succeeds" ' + ipfs get --help >actual + ' + + test_expect_success "'ipfs get --help' output looks good" ' + egrep "ipfs get.*" actual >/dev/null || + test_fsh cat actual + ' + + test_expect_success "ipfs get succeeds" ' + echo "Hello Worlds!" >data && + HASH=`ipfs add -q data` && + ipfs get "$HASH" >actual + ' + + test_expect_success "ipfs get output looks good" ' + printf "%s\n\n" "Saving file(s) to $HASH" >expected && + test_cmp expected actual + ' + + test_expect_success "ipfs get file output looks good" ' + test_cmp "$HASH" data + ' + + test_expect_success "ipfs get DOES NOT error when trying to overwrite a file" ' + ipfs get "$HASH" >actual && + rm "$HASH" + ' + + test_expect_success "ipfs get works with raw leaves" ' + HASH2=$(ipfs add --raw-leaves -q data) && + ipfs get "$HASH2" >actual2 + ' + + test_expect_success "ipfs get output looks good" ' + printf "%s\n\n" "Saving file(s) to $HASH2" >expected2 && + test_cmp expected2 actual2 + ' + + test_expect_success "ipfs get file output looks good" ' + test_cmp "$HASH2" data + ' + + test_ipfs_get_flag ".tar" "-xf" -a + + test_ipfs_get_flag ".tar.gz" "-zxf" -a -C + + test_ipfs_get_flag ".tar.gz" "-zxf" -a -C -l 9 + + test_expect_success "ipfs get succeeds (directory)" ' + mkdir -p dir && + touch dir/a && + mkdir -p dir/b && + echo "Hello, Worlds!" >dir/b/c && + HASH2=`ipfs add -r -q dir | tail -n 1` && + ipfs get "$HASH2" >actual + ' + + test_expect_success "ipfs get output looks good (directory)" ' + printf "%s\n\n" "Saving file(s) to $HASH2" >expected && + test_cmp expected actual + ' + + test_expect_success "ipfs get output is valid (directory)" ' + test_cmp dir/a "$HASH2"/a && + test_cmp dir/b/c "$HASH2"/b/c && + rm -r "$HASH2" + ' + + test_expect_success "ipfs get -a -C succeeds (directory)" ' + ipfs get "$HASH2" -a -C >actual + ' + + test_expect_success "ipfs get -a -C output looks good (directory)" ' + printf "%s\n\n" "Saving archive to $HASH2.tar.gz" >expected && + test_cmp expected actual + ' + + test_expect_success "gzipped tar archive output is valid (directory)" ' + tar -zxf "$HASH2".tar.gz && + test_cmp dir/a "$HASH2"/a && + test_cmp dir/b/c "$HASH2"/b/c && + rm -r "$HASH2" + ' + + test_expect_success "ipfs get ../.. should fail" ' + echo "Error: invalid 'ipfs ref' path" >expected && + test_must_fail ipfs get ../.. 2>actual && + test_cmp expected actual + ' } test_get_fail() { - test_expect_success "create an object that has unresolveable links" ' - cat <<-\EOF >bad_object && + test_expect_success "create an object that has unresolveable links" ' + cat <<-\EOF >bad_object && { "Links": [ { "Name": "foo", "Hash": "QmZzaC6ydNXiR65W8VjGA73ET9MZ6VFAqUT1ngYMXcpihn", "Size": 1897 }, { "Name": "bar", "Hash": "Qmd4mG6pDFDmDTn6p3hX1srP8qTbkyXKj5yjpEsiHDX3u8", "Size": 56 }, { "Name": "baz", "Hash": "QmUTjwRnG28dSrFFVTYgbr6LiDLsBmRr2SaUSTGheK2YqG", "Size": 24266 } ], "Data": "\b\u0001" } - EOF - cat bad_object | ipfs object put > put_out - ' - - test_expect_success "output looks good" ' - echo "added QmaGidyrnX8FMbWJoxp8HVwZ1uRKwCyxBJzABnR1S2FVUr" > put_exp && - test_cmp put_exp put_out - ' - - test_expect_success "ipfs get fails" ' - test_expect_code 1 ipfs get QmaGidyrnX8FMbWJoxp8HVwZ1uRKwCyxBJzABnR1S2FVUr - ' +EOF + cat bad_object | ipfs object put > put_out + ' + + test_expect_success "output looks good" ' + echo "added QmaGidyrnX8FMbWJoxp8HVwZ1uRKwCyxBJzABnR1S2FVUr" > put_exp && + test_cmp put_exp put_out + ' + + test_expect_success "ipfs get fails" ' + test_expect_code 1 ipfs get QmaGidyrnX8FMbWJoxp8HVwZ1uRKwCyxBJzABnR1S2FVUr + ' } # should work offline @@ -156,8 +156,8 @@ test_launch_ipfs_daemon test_get_cmd test_expect_success "empty request to get doesn't panic and returns error" ' - curl "http://$API_ADDR/api/v0/get" > curl_out || true && - grep "not enough arugments provided" curl_out + curl "http://$API_ADDR/api/v0/get" > curl_out || true && + grep "not enough arugments provided" curl_out ' diff --git a/test/sharness/t0100-name.sh b/test/sharness/t0100-name.sh index 7a0310f6186..bbe9922d891 100755 --- a/test/sharness/t0100-name.sh +++ b/test/sharness/t0100-name.sh @@ -13,81 +13,81 @@ test_init_ipfs # test publishing a hash test_expect_success "'ipfs name publish' succeeds" ' - PEERID=`ipfs id --format=""` && - test_check_peerid "${PEERID}" && - ipfs name publish "/ipfs/$HASH_WELCOME_DOCS" >publish_out + PEERID=`ipfs id --format=""` && + test_check_peerid "${PEERID}" && + ipfs name publish "/ipfs/$HASH_WELCOME_DOCS" >publish_out ' test_expect_success "publish output looks good" ' - echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected1 && - test_cmp expected1 publish_out + echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected1 && + test_cmp expected1 publish_out ' test_expect_success "'ipfs name resolve' succeeds" ' - ipfs name resolve "$PEERID" >output + ipfs name resolve "$PEERID" >output ' test_expect_success "resolve output looks good" ' - printf "/ipfs/%s\n" "$HASH_WELCOME_DOCS" >expected2 && - test_cmp expected2 output + printf "/ipfs/%s\n" "$HASH_WELCOME_DOCS" >expected2 && + test_cmp expected2 output ' # now test with a path 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 + PEERID=`ipfs id --format=""` && + test_check_peerid "${PEERID}" && + ipfs name publish "/ipfs/$HASH_WELCOME_DOCS/help" >publish_out ' test_expect_success "publish a path looks good" ' - echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS/help" >expected3 && - test_cmp expected3 publish_out + echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS/help" >expected3 && + test_cmp expected3 publish_out ' test_expect_success "'ipfs name resolve' succeeds" ' - ipfs name resolve "$PEERID" >output + ipfs name resolve "$PEERID" >output ' test_expect_success "resolve output looks good" ' - printf "/ipfs/%s/help\n" "$HASH_WELCOME_DOCS" >expected4 && - test_cmp expected4 output + printf "/ipfs/%s/help\n" "$HASH_WELCOME_DOCS" >expected4 && + test_cmp expected4 output ' test_expect_success "ipfs cat on published content succeeds" ' - ipfs cat "/ipfs/$HASH_WELCOME_DOCS/help" >expected && - ipfs cat "/ipns/$PEERID" >actual && - test_cmp expected actual + ipfs cat "/ipfs/$HASH_WELCOME_DOCS/help" >expected && + ipfs cat "/ipns/$PEERID" >actual && + test_cmp expected actual ' # publish with an explicit node ID test_expect_failure "'ipfs name publish ' succeeds" ' - PEERID=`ipfs id --format=""` && - test_check_peerid "${PEERID}" && - echo ipfs name publish "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" && - ipfs name publish "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish + PEERID=`ipfs id --format=""` && + test_check_peerid "${PEERID}" && + echo ipfs name publish "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" && + ipfs name publish "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish ' test_expect_failure "publish with our explicit node ID looks good" ' - echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish && - test_cmp expected_node_id_publish actual_node_id_publish + echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish && + test_cmp expected_node_id_publish actual_node_id_publish ' # publish with an explicit node ID as key name test_expect_success "generate and verify a new key" ' - NEWID=`ipfs key gen --type=rsa --size=2048 keyname` && - test_check_peerid "${NEWID}" + NEWID=`ipfs key gen --type=rsa --size=2048 keyname` && + test_check_peerid "${NEWID}" ' test_expect_success "'ipfs name publish --key= ' succeeds" ' - ipfs name publish --key=${NEWID} "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish + ipfs name publish --key=${NEWID} "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish ' test_expect_success "publish an explicit node ID as key name looks good" ' - echo "Published to ${NEWID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish && - test_cmp expected_node_id_publish actual_node_id_publish + echo "Published to ${NEWID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish && + test_cmp expected_node_id_publish actual_node_id_publish ' test_done diff --git a/test/sharness/t0101-iptb-name.sh b/test/sharness/t0101-iptb-name.sh index 3dbea47da64..5547bffb59b 100755 --- a/test/sharness/t0101-iptb-name.sh +++ b/test/sharness/t0101-iptb-name.sh @@ -11,36 +11,36 @@ test_description="Test ipfs repo operations" num_nodes=4 test_expect_success "set up an iptb cluster" ' - iptb init -n $num_nodes -p 0 -f --bootstrap=none + iptb init -n $num_nodes -p 0 -f --bootstrap=none ' startup_cluster $num_nodes test_expect_success "add an obect on one node" ' - echo "ipns is super fun" > file && - HASH_FILE=$(ipfsi 1 add -q file) + echo "ipns is super fun" > file && + HASH_FILE=$(ipfsi 1 add -q file) ' test_expect_success "publish that object as an ipns entry" ' - ipfsi 1 name publish $HASH_FILE + ipfsi 1 name publish $HASH_FILE ' test_expect_success "add an entry on another node pointing to that one" ' - NODE1_ID=$(iptb get id 1) && - ipfsi 2 name publish /ipns/$NODE1_ID + NODE1_ID=$(iptb get id 1) && + ipfsi 2 name publish /ipns/$NODE1_ID ' test_expect_success "cat that entry on a third node" ' - NODE2_ID=$(iptb get id 2) && - ipfsi 3 cat /ipns/$NODE2_ID > output + NODE2_ID=$(iptb get id 2) && + ipfsi 3 cat /ipns/$NODE2_ID > output ' test_expect_success "ensure output was the same" ' - test_cmp file output + test_cmp file output ' test_expect_success "shut down iptb" ' - iptb stop + iptb stop ' test_done diff --git a/test/sharness/t0110-gateway.sh b/test/sharness/t0110-gateway.sh index b7f77a9ca59..6041b39c980 100755 --- a/test/sharness/t0110-gateway.sh +++ b/test/sharness/t0110-gateway.sh @@ -22,137 +22,137 @@ apiport=$API_PORT # for now we check 5001 here as 5002 will be checked in gateway-writable. test_expect_success "Make a file to test with" ' - echo "Hello Worlds!" >expected && - HASH=$(ipfs add -q expected) || - test_fsh cat daemon_err + echo "Hello Worlds!" >expected && + HASH=$(ipfs add -q expected) || + test_fsh cat daemon_err ' test_expect_success "GET IPFS path succeeds" ' - curl -sfo actual "http://127.0.0.1:$port/ipfs/$HASH" + curl -sfo actual "http://127.0.0.1:$port/ipfs/$HASH" ' test_expect_success "GET IPFS path output looks good" ' - test_cmp expected actual && - rm actual + test_cmp expected actual && + rm actual ' test_expect_success "GET IPFS directory path succeeds" ' - mkdir dir && - echo "12345" >dir/test && - ipfs add -r -q dir >actual && - HASH2=$(tail -n 1 actual) && - curl -sf "http://127.0.0.1:$port/ipfs/$HASH2" + mkdir dir && + echo "12345" >dir/test && + ipfs add -r -q dir >actual && + HASH2=$(tail -n 1 actual) && + curl -sf "http://127.0.0.1:$port/ipfs/$HASH2" ' test_expect_success "GET IPFS directory file succeeds" ' - curl -sfo actual "http://127.0.0.1:$port/ipfs/$HASH2/test" + curl -sfo actual "http://127.0.0.1:$port/ipfs/$HASH2/test" ' test_expect_success "GET IPFS directory file output looks good" ' - test_cmp dir/test actual + test_cmp dir/test actual ' test_expect_success "GET IPFS non existent file returns code expected (404)" ' - test_curl_resp_http_code "http://127.0.0.1:$port/ipfs/$HASH2/pleaseDontAddMe" "HTTP/1.1 404 Not Found" + test_curl_resp_http_code "http://127.0.0.1:$port/ipfs/$HASH2/pleaseDontAddMe" "HTTP/1.1 404 Not Found" ' test_expect_failure "GET IPNS path succeeds" ' - ipfs name publish "$HASH" && - PEERID=$(ipfs config Identity.PeerID) && - test_check_peerid "$PEERID" && - curl -sfo actual "http://127.0.0.1:$port/ipns/$PEERID" + ipfs name publish "$HASH" && + 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" ' - test_cmp expected actual + test_cmp expected actual ' test_expect_success "GET invalid IPFS path errors" ' - test_must_fail curl -sf "http://127.0.0.1:$port/ipfs/12345" + test_must_fail curl -sf "http://127.0.0.1:$port/ipfs/12345" ' test_expect_success "GET invalid path errors" ' - test_must_fail curl -sf "http://127.0.0.1:$port/12345" + test_must_fail curl -sf "http://127.0.0.1:$port/12345" ' test_expect_success "GET /webui returns code expected" ' - test_curl_resp_http_code "http://127.0.0.1:$apiport/webui" "HTTP/1.1 302 Found" "HTTP/1.1 301 Moved Permanently" + test_curl_resp_http_code "http://127.0.0.1:$apiport/webui" "HTTP/1.1 302 Found" "HTTP/1.1 301 Moved Permanently" ' test_expect_success "GET /webui/ returns code expected" ' - test_curl_resp_http_code "http://127.0.0.1:$apiport/webui/" "HTTP/1.1 302 Found" "HTTP/1.1 301 Moved Permanently" + test_curl_resp_http_code "http://127.0.0.1:$apiport/webui/" "HTTP/1.1 302 Found" "HTTP/1.1 301 Moved Permanently" ' test_expect_success "GET /logs returns logs" ' - test_expect_code 28 curl http://127.0.0.1:$apiport/logs -m1 > log_out + test_expect_code 28 curl http://127.0.0.1:$apiport/logs -m1 > log_out ' test_expect_success "log output looks good" ' - grep "log API client connected" log_out + grep "log API client connected" log_out ' test_expect_success "GET /api/v0/version succeeds" ' - curl -v "http://127.0.0.1:$apiport/api/v0/version" 2> version_out + curl -v "http://127.0.0.1:$apiport/api/v0/version" 2> version_out ' test_expect_success "output only has one transfer encoding header" ' - grep "Transfer-Encoding: chunked" version_out | wc -l | xargs echo > tecount_out && - echo "1" > tecount_exp && - test_cmp tecount_out tecount_exp + grep "Transfer-Encoding: chunked" version_out | wc -l | xargs echo > tecount_out && + echo "1" > tecount_exp && + test_cmp tecount_out tecount_exp ' test_expect_success "setup index hash" ' - mkdir index && - echo "

" > index/index.html && - INDEXHASH=$(ipfs add -q -r index | tail -n1) - echo index: $INDEXHASH + mkdir index && + echo "

" > index/index.html && + INDEXHASH=$(ipfs add -q -r index | tail -n1) + echo index: $INDEXHASH ' test_expect_success "GET 'index.html' has correct content type" ' - curl -I "http://127.0.0.1:$port/ipfs/$INDEXHASH/" > indexout + curl -I "http://127.0.0.1:$port/ipfs/$INDEXHASH/" > indexout ' test_expect_success "output looks good" ' - grep "Content-Type: text/html" indexout + grep "Content-Type: text/html" indexout ' test_expect_success "HEAD 'index.html' has no content" ' - curl -X HEAD --max-time 1 http://127.0.0.1:$port/ipfs/$INDEXHASH/ > output; - [ ! -s output ] + curl -X HEAD --max-time 1 http://127.0.0.1:$port/ipfs/$INDEXHASH/ > output; + [ ! -s output ] ' # test ipfs readonly api test_curl_gateway_api() { - curl -sfo actual "http://127.0.0.1:$port/api/v0/$1" + curl -sfo actual "http://127.0.0.1:$port/api/v0/$1" } test_expect_success "get IPFS directory file through readonly API succeeds" ' - test_curl_gateway_api "cat?arg=$HASH2/test" + test_curl_gateway_api "cat?arg=$HASH2/test" ' test_expect_success "get IPFS directory file through readonly API output looks good" ' - test_cmp dir/test actual + test_cmp dir/test actual ' test_expect_success "refs IPFS directory file through readonly API succeeds" ' - test_curl_gateway_api "refs?arg=$HASH2/test" + test_curl_gateway_api "refs?arg=$HASH2/test" ' test_expect_success "test gateway api is sanitized" ' -for cmd in "add" "block/put" "bootstrap" "config" "dht" "diag" "dns" "get" "id" "mount" "name/publish" "object/put" "object/new" "object/patch" "pin" "ping" "refs/local" "repo" "resolve" "stats" "swarm" "file" "update" "version" "bitswap"; do - test_curl_resp_http_code "http://127.0.0.1:$port/api/v0/$cmd" "HTTP/1.1 404 Not Found" - done +for cmd in "add" "block/put" "bootstrap" "config" "dht" "diag" "dns" "get" "id" "mount" "name/publish" "object/put" "object/new" "object/patch" "pin" "ping" "refs/local" "repo" "resolve" "stats" "swarm" "file" "update" "version" "bitswap"; do + test_curl_resp_http_code "http://127.0.0.1:$port/api/v0/$cmd" "HTTP/1.1 404 Not Found" + done ' test_expect_success "create raw-leaves node" ' - echo "This is RAW!" > rfile && - echo "This is RAW!" | ipfs add --raw-leaves -q > rhash + echo "This is RAW!" > rfile && + echo "This is RAW!" | ipfs add --raw-leaves -q > rhash ' test_expect_success "try fetching it from gateway" ' - curl http://127.0.0.1:$port/ipfs/$(cat rhash) > ffile && - test_cmp rfile ffile + curl http://127.0.0.1:$port/ipfs/$(cat rhash) > ffile && + test_cmp rfile ffile ' test_kill_ipfs_daemon diff --git a/test/sharness/t0111-gateway-writeable.sh b/test/sharness/t0111-gateway-writeable.sh index 51df33cfb2e..655f60a178a 100755 --- a/test/sharness/t0111-gateway-writeable.sh +++ b/test/sharness/t0111-gateway-writeable.sh @@ -12,17 +12,17 @@ test_init_ipfs test_launch_ipfs_daemon --writable test_expect_success "ipfs daemon --writable overrides config" ' - curl -v -X POST http://$GWAY_ADDR/ipfs/ 2> outfile && - grep "HTTP/1.1 201 Created" outfile && - grep "Location: /ipfs/QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" outfile + curl -v -X POST http://$GWAY_ADDR/ipfs/ 2> outfile && + grep "HTTP/1.1 201 Created" outfile && + grep "Location: /ipfs/QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" outfile ' test_kill_ipfs_daemon test_config_ipfs_gateway_writable test_launch_ipfs_daemon --writable=false test_expect_success "ipfs daemon --writable=false overrides Writable=true config" ' - curl -v -X POST http://$GWAY_ADDR/ipfs/ 2> outfile && - grep "HTTP/1.1 405 Method Not Allowed" outfile + curl -v -X POST http://$GWAY_ADDR/ipfs/ 2> outfile && + grep "HTTP/1.1 405 Method Not Allowed" outfile ' test_kill_ipfs_daemon test_launch_ipfs_daemon @@ -30,79 +30,79 @@ test_launch_ipfs_daemon port=$GWAY_PORT test_expect_success "ipfs daemon up" ' - pollEndpoint -host $GWAY_MADDR -ep=/version -v -tout=1s -tries=60 2>poll_apierr > poll_apiout || - test_fsh cat poll_apierr || test_fsh cat poll_apiout + pollEndpoint -host $GWAY_MADDR -ep=/version -v -tout=1s -tries=60 2>poll_apierr > poll_apiout || + test_fsh cat poll_apierr || test_fsh cat poll_apiout ' test_expect_success "HTTP gateway gives access to sample file" ' - curl -s -o welcome "http://$GWAY_ADDR/ipfs/$HASH_WELCOME_DOCS/readme" && - grep "Hello and Welcome to IPFS!" welcome + curl -s -o welcome "http://$GWAY_ADDR/ipfs/$HASH_WELCOME_DOCS/readme" && + grep "Hello and Welcome to IPFS!" welcome ' test_expect_success "HTTP POST file gives Hash" ' - echo "$RANDOM" >infile && - URL="http://localhost:$port/ipfs/" && - curl -svX POST --data-binary @infile "$URL" 2>curl_post.out && - grep "HTTP/1.1 201 Created" curl_post.out && - LOCATION=$(grep Location curl_post.out) && - HASH=$(echo $LOCATION | cut -d":" -f2- |tr -d " \n\r") + echo "$RANDOM" >infile && + URL="http://localhost:$port/ipfs/" && + curl -svX POST --data-binary @infile "$URL" 2>curl_post.out && + grep "HTTP/1.1 201 Created" curl_post.out && + LOCATION=$(grep Location curl_post.out) && + HASH=$(echo $LOCATION | cut -d":" -f2- |tr -d " \n\r") ' test_expect_success "We can HTTP GET file just created" ' - URL="http://localhost:${port}${HASH}" && - curl -so outfile "$URL" && - test_cmp infile outfile + URL="http://localhost:${port}${HASH}" && + curl -so outfile "$URL" && + test_cmp infile outfile ' test_expect_success "HTTP PUT empty directory" ' - URL="http://localhost:$port/ipfs/$HASH_EMPTY_DIR/" && - echo "PUT $URL" && - curl -svX PUT "$URL" 2>curl_putEmpty.out && - cat curl_putEmpty.out && - grep "Ipfs-Hash: $HASH_EMPTY_DIR" curl_putEmpty.out && - grep "Location: /ipfs/$HASH_EMPTY_DIR" curl_putEmpty.out && - grep "HTTP/1.1 201 Created" curl_putEmpty.out + URL="http://localhost:$port/ipfs/$HASH_EMPTY_DIR/" && + echo "PUT $URL" && + curl -svX PUT "$URL" 2>curl_putEmpty.out && + cat curl_putEmpty.out && + grep "Ipfs-Hash: $HASH_EMPTY_DIR" curl_putEmpty.out && + grep "Location: /ipfs/$HASH_EMPTY_DIR" curl_putEmpty.out && + grep "HTTP/1.1 201 Created" curl_putEmpty.out ' test_expect_success "HTTP GET empty directory" ' - echo "GET $URL" && - curl -so outfile "$URL" 2>curl_getEmpty.out && - grep "Index of /ipfs/$HASH_EMPTY_DIR/" outfile + echo "GET $URL" && + curl -so outfile "$URL" 2>curl_getEmpty.out && + grep "Index of /ipfs/$HASH_EMPTY_DIR/" outfile ' test_expect_success "HTTP PUT file to construct a hierarchy" ' - echo "$RANDOM" >infile && - URL="http://localhost:$port/ipfs/$HASH_EMPTY_DIR/test.txt" && - echo "PUT $URL" && - curl -svX PUT --data-binary @infile "$URL" 2>curl_put.out && - grep "HTTP/1.1 201 Created" curl_put.out && - LOCATION=$(grep Location curl_put.out) && - HASH=$(expr "$LOCATION" : "< Location: /ipfs/\(.*\)/test.txt") + echo "$RANDOM" >infile && + URL="http://localhost:$port/ipfs/$HASH_EMPTY_DIR/test.txt" && + echo "PUT $URL" && + curl -svX PUT --data-binary @infile "$URL" 2>curl_put.out && + grep "HTTP/1.1 201 Created" curl_put.out && + LOCATION=$(grep Location curl_put.out) && + HASH=$(expr "$LOCATION" : "< Location: /ipfs/\(.*\)/test.txt") ' test_expect_success "We can HTTP GET file just created" ' - URL="http://localhost:$port/ipfs/$HASH/test.txt" && - echo "GET $URL" && - curl -so outfile "$URL" && - test_cmp infile outfile + URL="http://localhost:$port/ipfs/$HASH/test.txt" && + echo "GET $URL" && + curl -so outfile "$URL" && + test_cmp infile outfile ' test_expect_success "HTTP PUT file to append to existing hierarchy" ' - echo "$RANDOM" >infile2 && - URL="http://localhost:$port/ipfs/$HASH/test/test.txt" && - echo "PUT $URL" && - curl -svX PUT --data-binary @infile2 "$URL" 2>curl_putAgain.out && - grep "HTTP/1.1 201 Created" curl_putAgain.out && - LOCATION=$(grep Location curl_putAgain.out) && - HASH=$(expr "$LOCATION" : "< Location: /ipfs/\(.*\)/test/test.txt") + echo "$RANDOM" >infile2 && + URL="http://localhost:$port/ipfs/$HASH/test/test.txt" && + echo "PUT $URL" && + curl -svX PUT --data-binary @infile2 "$URL" 2>curl_putAgain.out && + grep "HTTP/1.1 201 Created" curl_putAgain.out && + LOCATION=$(grep Location curl_putAgain.out) && + HASH=$(expr "$LOCATION" : "< Location: /ipfs/\(.*\)/test/test.txt") ' test_expect_success "We can HTTP GET file just updated" ' - URL="http://localhost:$port/ipfs/$HASH/test/test.txt" && - echo "GET $URL" && - curl -svo outfile2 "$URL" 2>curl_getAgain.out && - test_cmp infile2 outfile2 + URL="http://localhost:$port/ipfs/$HASH/test/test.txt" && + echo "GET $URL" && + curl -svo outfile2 "$URL" 2>curl_getAgain.out && + test_cmp infile2 outfile2 ' test_kill_ipfs_daemon diff --git a/test/sharness/t0112-gateway-cors.sh b/test/sharness/t0112-gateway-cors.sh index d3c5ee1b4c5..a173ed8b58d 100755 --- a/test/sharness/t0112-gateway-cors.sh +++ b/test/sharness/t0112-gateway-cors.sh @@ -7,9 +7,9 @@ test_description="Test HTTP Gateway CORS Support" test_config_ipfs_cors_headers() { - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]' - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Headers '["X-Requested-With"]' + ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' + ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]' + ipfs config --json API.HTTPHeaders.Access-Control-Allow-Headers '["X-Requested-With"]' } . lib/test-lib.sh @@ -26,48 +26,48 @@ thash='QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn' # HTTP GET Request test_expect_success "GET to Gateway succeeds" ' - curl -svX GET "http://127.0.0.1:$gwport/ipfs/$thash" 2>curl_output + curl -svX GET "http://127.0.0.1:$gwport/ipfs/$thash" 2>curl_output ' cat curl_output # GET Response from Gateway should contain CORS headers test_expect_success "GET response for Gateway resource looks good" ' - grep "Access-Control-Allow-Origin:" curl_output | grep "\*" && - grep "Access-Control-Allow-Methods:" curl_output | grep " GET\b" && - grep "Access-Control-Allow-Headers:" curl_output + grep "Access-Control-Allow-Origin:" curl_output | grep "\*" && + grep "Access-Control-Allow-Methods:" curl_output | grep " GET\b" && + grep "Access-Control-Allow-Headers:" curl_output ' # HTTP OPTIONS Request test_expect_success "OPTIONS to Gateway succeeds" ' - curl -svX OPTIONS "http://127.0.0.1:$gwport/ipfs/$thash" 2>curl_output + curl -svX OPTIONS "http://127.0.0.1:$gwport/ipfs/$thash" 2>curl_output ' # OPTION Response from Gateway should contain CORS headers test_expect_success "OPTIONS response for Gateway resource looks good" ' - grep "Access-Control-Allow-Origin:" curl_output | grep "\*" && - grep "Access-Control-Allow-Methods:" curl_output | grep " GET\b" && - grep "Access-Control-Allow-Headers:" curl_output + grep "Access-Control-Allow-Origin:" curl_output | grep "\*" && + grep "Access-Control-Allow-Methods:" curl_output | grep " GET\b" && + grep "Access-Control-Allow-Headers:" curl_output ' # Read-Only API (at the Gateway Port) # HTTP GET Request test_expect_success "GET to API succeeds" ' - curl -svX GET "http://127.0.0.1:$gwport/api/v0/cat?arg=$thash" 2>curl_output + curl -svX GET "http://127.0.0.1:$gwport/api/v0/cat?arg=$thash" 2>curl_output ' # GET Response from the API should NOT contain CORS headers # Blacklisting: https://git.io/vzaj2 # Rationale: https://git.io/vzajX test_expect_success "OPTIONS response for API looks good" ' - grep -q "Access-Control-Allow-" curl_output && false || true + grep -q "Access-Control-Allow-" curl_output && false || true ' # HTTP OPTIONS Request test_expect_success "OPTIONS to API succeeds" ' - curl -svX OPTIONS "http://127.0.0.1:$gwport/api/v0/cat?arg=$thash" 2>curl_output + curl -svX OPTIONS "http://127.0.0.1:$gwport/api/v0/cat?arg=$thash" 2>curl_output ' # OPTIONS Response from the API should NOT contain CORS headers test_expect_success "OPTIONS response for API looks good" ' - grep -q "Access-Control-Allow-" curl_output && false || true + grep -q "Access-Control-Allow-" curl_output && false || true ' test_kill_ipfs_daemon diff --git a/test/sharness/t0120-bootstrap.sh b/test/sharness/t0120-bootstrap.sh index bdafe704b1b..49ab560ae7a 100755 --- a/test/sharness/t0120-bootstrap.sh +++ b/test/sharness/t0120-bootstrap.sh @@ -27,132 +27,132 @@ test_init_ipfs # we use a function so that we can run it both offline + online test_bootstrap_list_cmd() { - printf "" >list_expected - for BP in "$@" - do - echo "$BP" >>list_expected - done - - test_expect_success "'ipfs bootstrap' succeeds" ' - ipfs bootstrap >list_actual - ' - - test_expect_success "'ipfs bootstrap' output looks good" ' - test_cmp list_expected list_actual - ' - - test_expect_success "'ipfs bootstrap list' succeeds" ' - ipfs bootstrap list >list2_actual - ' - - test_expect_success "'ipfs bootstrap list' output looks good" ' - test_cmp list_expected list2_actual - ' + printf "" >list_expected + for BP in "$@" + do + echo "$BP" >>list_expected + done + + test_expect_success "'ipfs bootstrap' succeeds" ' + ipfs bootstrap >list_actual + ' + + test_expect_success "'ipfs bootstrap' output looks good" ' + test_cmp list_expected list_actual + ' + + test_expect_success "'ipfs bootstrap list' succeeds" ' + ipfs bootstrap list >list2_actual + ' + + test_expect_success "'ipfs bootstrap list' output looks good" ' + test_cmp list_expected list2_actual + ' } # we use a function so that we can run it both offline + online test_bootstrap_cmd() { - # remove all peers just in case. - # if this fails, the first listing may not be empty - ipfs bootstrap rm --all - - test_bootstrap_list_cmd - - test_expect_success "'ipfs bootstrap add' succeeds" ' - ipfs bootstrap add "$BP1" "$BP2" "$BP3" >add_actual - ' - - test_expect_success "'ipfs bootstrap add' output looks good" ' - echo $BP1 >add_expected && - echo $BP2 >>add_expected && - echo $BP3 >>add_expected && - test_cmp add_expected add_actual - ' - - test_bootstrap_list_cmd $BP1 $BP2 $BP3 - - test_expect_success "'ipfs bootstrap rm' succeeds" ' - ipfs bootstrap rm "$BP1" "$BP3" >rm_actual - ' - - test_expect_success "'ipfs bootstrap rm' output looks good" ' - echo $BP1 >rm_expected && - echo $BP3 >>rm_expected && - test_cmp rm_expected rm_actual - ' - - test_bootstrap_list_cmd $BP2 - - test_expect_success "'ipfs bootstrap add --default' succeeds" ' - ipfs bootstrap add --default >add2_actual - ' - - test_expect_success "'ipfs bootstrap add --default' output has default BP" ' - echo $BP1 >add2_expected && - echo $BP2 >>add2_expected && - echo $BP3 >>add2_expected && - echo $BP4 >>add2_expected && - echo $BP5 >>add2_expected && - echo $BP6 >>add2_expected && - echo $BP7 >>add2_expected && - echo $BP8 >>add2_expected && - echo $BP9 >>add2_expected && - echo $BP10 >>add2_expected && - echo $BP11 >>add2_expected && - echo $BP12 >>add2_expected && - echo $BP13 >>add2_expected && - test_cmp add2_expected add2_actual - ' - - test_bootstrap_list_cmd $BP1 $BP2 $BP3 $BP4 $BP5 $BP6 $BP7 $BP8 $BP9 $BP10 $BP11 $BP12 $BP13 $BP14 $BP15 $BP16 $BP17 - - test_expect_success "'ipfs bootstrap rm --all' succeeds" ' - ipfs bootstrap rm --all >rm2_actual - ' - - test_expect_success "'ipfs bootstrap rm' output looks good" ' - echo $BP1 >rm2_expected && - echo $BP2 >>rm2_expected && - echo $BP3 >>rm2_expected && - echo $BP4 >>rm2_expected && - echo $BP5 >>rm2_expected && - echo $BP6 >>rm2_expected && - echo $BP7 >>rm2_expected && - echo $BP8 >>rm2_expected && - echo $BP9 >>rm2_expected && - echo $BP10 >>rm2_expected && - echo $BP11 >>rm2_expected && - echo $BP12 >>rm2_expected && - echo $BP13 >>rm2_expected && - test_cmp rm2_expected rm2_actual - ' - - test_bootstrap_list_cmd - - test_expect_success "'ipfs bootstrap add' accepts args from stdin" ' - echo $BP1 > bpeers && - echo $BP2 >> bpeers && - echo $BP3 >> bpeers && - echo $BP4 >> bpeers && - cat bpeers | ipfs bootstrap add > add_stdin_actual - ' - - test_expect_success "output looks good" ' - test_cmp add_stdin_actual bpeers - ' - - test_bootstrap_list_cmd $BP1 $BP2 $BP3 $BP4 - - test_expect_success "'ipfs bootstrap rm' accepts args from stdin" ' - cat bpeers | ipfs bootstrap rm > rm_stdin_actual - ' - - test_expect_success "output looks good" ' - test_cmp rm_stdin_actual bpeers - ' - - test_bootstrap_list_cmd + # remove all peers just in case. + # if this fails, the first listing may not be empty + ipfs bootstrap rm --all + + test_bootstrap_list_cmd + + test_expect_success "'ipfs bootstrap add' succeeds" ' + ipfs bootstrap add "$BP1" "$BP2" "$BP3" >add_actual + ' + + test_expect_success "'ipfs bootstrap add' output looks good" ' + echo $BP1 >add_expected && + echo $BP2 >>add_expected && + echo $BP3 >>add_expected && + test_cmp add_expected add_actual + ' + + test_bootstrap_list_cmd $BP1 $BP2 $BP3 + + test_expect_success "'ipfs bootstrap rm' succeeds" ' + ipfs bootstrap rm "$BP1" "$BP3" >rm_actual + ' + + test_expect_success "'ipfs bootstrap rm' output looks good" ' + echo $BP1 >rm_expected && + echo $BP3 >>rm_expected && + test_cmp rm_expected rm_actual + ' + + test_bootstrap_list_cmd $BP2 + + test_expect_success "'ipfs bootstrap add --default' succeeds" ' + ipfs bootstrap add --default >add2_actual + ' + + test_expect_success "'ipfs bootstrap add --default' output has default BP" ' + echo $BP1 >add2_expected && + echo $BP2 >>add2_expected && + echo $BP3 >>add2_expected && + echo $BP4 >>add2_expected && + echo $BP5 >>add2_expected && + echo $BP6 >>add2_expected && + echo $BP7 >>add2_expected && + echo $BP8 >>add2_expected && + echo $BP9 >>add2_expected && + echo $BP10 >>add2_expected && + echo $BP11 >>add2_expected && + echo $BP12 >>add2_expected && + echo $BP13 >>add2_expected && + test_cmp add2_expected add2_actual + ' + + test_bootstrap_list_cmd $BP1 $BP2 $BP3 $BP4 $BP5 $BP6 $BP7 $BP8 $BP9 $BP10 $BP11 $BP12 $BP13 $BP14 $BP15 $BP16 $BP17 + + test_expect_success "'ipfs bootstrap rm --all' succeeds" ' + ipfs bootstrap rm --all >rm2_actual + ' + + test_expect_success "'ipfs bootstrap rm' output looks good" ' + echo $BP1 >rm2_expected && + echo $BP2 >>rm2_expected && + echo $BP3 >>rm2_expected && + echo $BP4 >>rm2_expected && + echo $BP5 >>rm2_expected && + echo $BP6 >>rm2_expected && + echo $BP7 >>rm2_expected && + echo $BP8 >>rm2_expected && + echo $BP9 >>rm2_expected && + echo $BP10 >>rm2_expected && + echo $BP11 >>rm2_expected && + echo $BP12 >>rm2_expected && + echo $BP13 >>rm2_expected && + test_cmp rm2_expected rm2_actual + ' + + test_bootstrap_list_cmd + + test_expect_success "'ipfs bootstrap add' accepts args from stdin" ' + echo $BP1 > bpeers && + echo $BP2 >> bpeers && + echo $BP3 >> bpeers && + echo $BP4 >> bpeers && + cat bpeers | ipfs bootstrap add > add_stdin_actual + ' + + test_expect_success "output looks good" ' + test_cmp add_stdin_actual bpeers + ' + + test_bootstrap_list_cmd $BP1 $BP2 $BP3 $BP4 + + test_expect_success "'ipfs bootstrap rm' accepts args from stdin" ' + cat bpeers | ipfs bootstrap rm > rm_stdin_actual + ' + + test_expect_success "output looks good" ' + test_cmp rm_stdin_actual bpeers + ' + + test_bootstrap_list_cmd } # should work offline diff --git a/test/sharness/t0121-bootstrap-iptb.sh b/test/sharness/t0121-bootstrap-iptb.sh index f9039e16468..33234703bd5 100755 --- a/test/sharness/t0121-bootstrap-iptb.sh +++ b/test/sharness/t0121-bootstrap-iptb.sh @@ -12,76 +12,76 @@ test_description="test node bootstrapping" test_init_ipfs test_expect_success "disable mdns" ' - ipfs config Discovery.MDNS.Enabled false --json + ipfs config Discovery.MDNS.Enabled false --json ' test_launch_ipfs_daemon test_expect_success "setup iptb nodes" ' - iptb init -n 5 -f --bootstrap=none --port=0 + iptb init -n 5 -f --bootstrap=none --port=0 ' test_expect_success "start up iptb nodes" ' - iptb start + iptb start ' test_expect_success "check peers works" ' - ipfs swarm peers >peers_out + ipfs swarm peers >peers_out ' test_expect_success "correct number of peers" ' - test -z "`cat peers_out`" + test -z "`cat peers_out`" ' betterwait() { - while kill -0 $1; do true; done + 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 + 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 + # 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 "") && - BADDR="/ip4/127.0.0.1/tcp/$SWARM_PORT/ipfs/$bsn_peer_id" && - ipfsi 0 bootstrap add $BADDR && - ipfsi 1 bootstrap add $BADDR && - ipfsi 2 bootstrap add $BADDR && - ipfsi 3 bootstrap add $BADDR && - ipfsi 4 bootstrap add $BADDR + bsn_peer_id=$(ipfs id -f "") && + BADDR="/ip4/127.0.0.1/tcp/$SWARM_PORT/ipfs/$bsn_peer_id" && + ipfsi 0 bootstrap add $BADDR && + ipfsi 1 bootstrap add $BADDR && + ipfsi 2 bootstrap add $BADDR && + ipfsi 3 bootstrap add $BADDR && + ipfsi 4 bootstrap add $BADDR ' test_expect_success "start up iptb nodes" ' - iptb start --wait + iptb start --wait ' test_expect_success "check peers works" ' - ipfs swarm peers > peers_out + ipfs swarm peers > peers_out ' 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 test_expect_success "bring down iptb nodes" ' - iptb stop + iptb stop ' test_done diff --git a/test/sharness/t0125-twonode.sh b/test/sharness/t0125-twonode.sh index 5d6ad9f7d5d..1ba9b3ba421 100755 --- a/test/sharness/t0125-twonode.sh +++ b/test/sharness/t0125-twonode.sh @@ -9,84 +9,84 @@ test_description="Test two ipfs nodes transferring a file" . lib/test-lib.sh check_file_fetch() { - node=$1 - fhash=$2 - fname=$3 + node=$1 + fhash=$2 + fname=$3 - test_expect_success "can fetch file" ' - ipfsi $node cat $fhash > fetch_out - ' + test_expect_success "can fetch file" ' + ipfsi $node cat $fhash > fetch_out + ' - test_expect_success "file looks good" ' - test_cmp $fname fetch_out - ' + test_expect_success "file looks good" ' + test_cmp $fname fetch_out + ' } check_dir_fetch() { - node=$1 - ref=$2 + node=$1 + ref=$2 - test_expect_success "node can fetch all refs for dir" ' - ipfsi $node refs -r $ref > /dev/null - ' + test_expect_success "node can fetch all refs for dir" ' + ipfsi $node refs -r $ref > /dev/null + ' } run_single_file_test() { - test_expect_success "add a file on node1" ' - random 1000000 > filea && - FILEA_HASH=$(ipfsi 1 add -q filea) - ' + test_expect_success "add a file on node1" ' + random 1000000 > filea && + FILEA_HASH=$(ipfsi 1 add -q filea) + ' - check_file_fetch 0 $FILEA_HASH filea + check_file_fetch 0 $FILEA_HASH filea } run_random_dir_test() { - test_expect_success "create a bunch of random files" ' - random-files -depth=3 -dirs=4 -files=5 -seed=5 foobar > /dev/null - ' + test_expect_success "create a bunch of random files" ' + random-files -depth=3 -dirs=4 -files=5 -seed=5 foobar > /dev/null + ' - test_expect_success "add those on node 0" ' - DIR_HASH=$(ipfsi 0 add -r -q foobar | tail -n1) - ' + test_expect_success "add those on node 0" ' + DIR_HASH=$(ipfsi 0 add -r -q foobar | tail -n1) + ' - check_dir_fetch 1 $DIR_HASH + check_dir_fetch 1 $DIR_HASH } run_advanced_test() { - startup_cluster 2 "$@" - - test_expect_success "clean repo before test" ' - ipfsi 0 repo gc > /dev/null && - ipfsi 1 repo gc > /dev/null - ' - - run_single_file_test - - run_random_dir_test - - test_expect_success "node0 data transferred looks correct" ' - ipfsi 0 bitswap stat > stat0 && - grep "blocks sent: 126" stat0 > /dev/null && - grep "blocks received: 5" stat0 > /dev/null && - grep "data sent: 228113" stat0 > /dev/null && - grep "data received: 1000256" stat0 > /dev/null - ' - - test_expect_success "node1 data transferred looks correct" ' - ipfsi 1 bitswap stat > stat1 && - grep "blocks received: 126" stat1 > /dev/null && - grep "blocks sent: 5" stat1 > /dev/null && - grep "data received: 228113" stat1 > /dev/null && - grep "data sent: 1000256" stat1 > /dev/null - ' - - test_expect_success "shut down nodes" ' - iptb stop - ' + startup_cluster 2 "$@" + + test_expect_success "clean repo before test" ' + ipfsi 0 repo gc > /dev/null && + ipfsi 1 repo gc > /dev/null + ' + + run_single_file_test + + run_random_dir_test + + test_expect_success "node0 data transferred looks correct" ' + ipfsi 0 bitswap stat > stat0 && + grep "blocks sent: 126" stat0 > /dev/null && + grep "blocks received: 5" stat0 > /dev/null && + grep "data sent: 228113" stat0 > /dev/null && + grep "data received: 1000256" stat0 > /dev/null + ' + + test_expect_success "node1 data transferred looks correct" ' + ipfsi 1 bitswap stat > stat1 && + grep "blocks received: 126" stat1 > /dev/null && + grep "blocks sent: 5" stat1 > /dev/null && + grep "data received: 228113" stat1 > /dev/null && + grep "data sent: 1000256" stat1 > /dev/null + ' + + test_expect_success "shut down nodes" ' + iptb stop + ' } test_expect_success "set up tcp testbed" ' - iptb init -n 2 -p 0 -f --bootstrap=none + iptb init -n 2 -p 0 -f --bootstrap=none ' # test multiplex muxer diff --git a/test/sharness/t0130-multinode.sh b/test/sharness/t0130-multinode.sh index 47330b97dcd..7138393f586 100755 --- a/test/sharness/t0130-multinode.sh +++ b/test/sharness/t0130-multinode.sh @@ -9,83 +9,83 @@ test_description="Test multiple ipfs nodes" . lib/test-lib.sh check_file_fetch() { - node=$1 - fhash=$2 - fname=$3 + node=$1 + fhash=$2 + fname=$3 - test_expect_success "can fetch file" ' - ipfsi $node cat $fhash > fetch_out - ' + test_expect_success "can fetch file" ' + ipfsi $node cat $fhash > fetch_out + ' - test_expect_success "file looks good" ' - test_cmp $fname fetch_out - ' + test_expect_success "file looks good" ' + test_cmp $fname fetch_out + ' } check_dir_fetch() { - node=$1 - ref=$2 + node=$1 + ref=$2 - test_expect_success "node can fetch all refs for dir" ' - ipfsi $node refs -r $ref > /dev/null - ' + test_expect_success "node can fetch all refs for dir" ' + ipfsi $node refs -r $ref > /dev/null + ' } run_single_file_test() { - test_expect_success "add a file on node1" ' - random 1000000 > filea && - FILEA_HASH=$(ipfsi 1 add -q filea) - ' - - check_file_fetch 4 $FILEA_HASH filea - check_file_fetch 3 $FILEA_HASH filea - check_file_fetch 2 $FILEA_HASH filea - check_file_fetch 1 $FILEA_HASH filea - check_file_fetch 0 $FILEA_HASH filea + test_expect_success "add a file on node1" ' + random 1000000 > filea && + FILEA_HASH=$(ipfsi 1 add -q filea) + ' + + check_file_fetch 4 $FILEA_HASH filea + check_file_fetch 3 $FILEA_HASH filea + check_file_fetch 2 $FILEA_HASH filea + check_file_fetch 1 $FILEA_HASH filea + check_file_fetch 0 $FILEA_HASH filea } run_random_dir_test() { - test_expect_success "create a bunch of random files" ' - random-files -depth=4 -dirs=5 -files=8 foobar > /dev/null - ' - - test_expect_success "add those on node 2" ' - DIR_HASH=$(ipfsi 2 add -r -q foobar | tail -n1) - ' - - check_dir_fetch 0 $DIR_HASH - check_dir_fetch 1 $DIR_HASH - check_dir_fetch 2 $DIR_HASH - check_dir_fetch 3 $DIR_HASH - check_dir_fetch 4 $DIR_HASH + test_expect_success "create a bunch of random files" ' + random-files -depth=4 -dirs=5 -files=8 foobar > /dev/null + ' + + test_expect_success "add those on node 2" ' + DIR_HASH=$(ipfsi 2 add -r -q foobar | tail -n1) + ' + + check_dir_fetch 0 $DIR_HASH + check_dir_fetch 1 $DIR_HASH + check_dir_fetch 2 $DIR_HASH + check_dir_fetch 3 $DIR_HASH + check_dir_fetch 4 $DIR_HASH } run_basic_test() { - startup_cluster 5 + startup_cluster 5 - run_single_file_test + run_single_file_test - test_expect_success "shut down nodes" ' - iptb stop - ' + test_expect_success "shut down nodes" ' + iptb stop + ' } run_advanced_test() { - startup_cluster 5 "$@" + startup_cluster 5 "$@" - run_single_file_test + run_single_file_test - run_random_dir_test + run_random_dir_test - test_expect_success "shut down nodes" ' - iptb stop || - test_fsh tail -n +1 .iptb/*/daemon.std* - ' + test_expect_success "shut down nodes" ' + iptb stop || + test_fsh tail -n +1 .iptb/*/daemon.std* + ' } test_expect_success "set up /tcp testbed" ' - iptb init -n 5 -p 0 -f --bootstrap=none + iptb init -n 5 -p 0 -f --bootstrap=none ' # test multiplex muxer @@ -97,7 +97,7 @@ unset LIBP2P_MUX_PREFS run_advanced_test test_expect_success "set up /ws testbed" ' - iptb init -n 5 -ws -p 0 -f --bootstrap=none + iptb init -n 5 -ws -p 0 -f --bootstrap=none ' # test multiplex muxer diff --git a/test/sharness/t0131-multinode-client-routing.sh b/test/sharness/t0131-multinode-client-routing.sh index 255bc9e3307..6b2017d06e4 100755 --- a/test/sharness/t0131-multinode-client-routing.sh +++ b/test/sharness/t0131-multinode-client-routing.sh @@ -9,65 +9,65 @@ test_description="Test client mode dht" . lib/test-lib.sh check_file_fetch() { - node=$1 - fhash=$2 - fname=$3 + node=$1 + fhash=$2 + fname=$3 - test_expect_success "can fetch file" ' - ipfsi $node cat $fhash > fetch_out - ' + test_expect_success "can fetch file" ' + ipfsi $node cat $fhash > fetch_out + ' - test_expect_success "file looks good" ' - test_cmp $fname fetch_out - ' + test_expect_success "file looks good" ' + test_cmp $fname fetch_out + ' } run_single_file_test() { - test_expect_success "add a file on node1" ' - random 1000000 > filea && - FILEA_HASH=$(ipfsi 1 add -q filea) - ' - - check_file_fetch 9 $FILEA_HASH filea - check_file_fetch 8 $FILEA_HASH filea - check_file_fetch 7 $FILEA_HASH filea - check_file_fetch 6 $FILEA_HASH filea - check_file_fetch 5 $FILEA_HASH filea - check_file_fetch 4 $FILEA_HASH filea - check_file_fetch 3 $FILEA_HASH filea - check_file_fetch 2 $FILEA_HASH filea - check_file_fetch 1 $FILEA_HASH filea - check_file_fetch 0 $FILEA_HASH filea + test_expect_success "add a file on node1" ' + random 1000000 > filea && + FILEA_HASH=$(ipfsi 1 add -q filea) + ' + + check_file_fetch 9 $FILEA_HASH filea + check_file_fetch 8 $FILEA_HASH filea + check_file_fetch 7 $FILEA_HASH filea + check_file_fetch 6 $FILEA_HASH filea + check_file_fetch 5 $FILEA_HASH filea + check_file_fetch 4 $FILEA_HASH filea + check_file_fetch 3 $FILEA_HASH filea + check_file_fetch 2 $FILEA_HASH filea + check_file_fetch 1 $FILEA_HASH filea + check_file_fetch 0 $FILEA_HASH filea } NNODES=10 test_expect_success "set up testbed" ' - iptb init -n $NNODES -p 0 -f --bootstrap=none + iptb init -n $NNODES -p 0 -f --bootstrap=none ' test_expect_success "start up nodes" ' - iptb start [0-7] && - iptb start [8-9] --args="--routing=dhtclient" + iptb start [0-7] && + iptb start [8-9] --args="--routing=dhtclient" ' test_expect_success "connect up nodes" ' - iptb connect [1-9] 0 + iptb connect [1-9] 0 ' test_expect_success "add a file on a node in client mode" ' - random 1000000 > filea && - FILE_HASH=$(ipfsi 8 add -q filea) + random 1000000 > filea && + FILE_HASH=$(ipfsi 8 add -q filea) ' test_expect_success "retrieve that file on a client mode node" ' - check_file_fetch 9 $FILE_HASH filea + check_file_fetch 9 $FILE_HASH filea ' run_single_file_test test_expect_success "shut down nodes" ' - iptb stop + iptb stop ' test_done diff --git a/test/sharness/t0140-swarm.sh b/test/sharness/t0140-swarm.sh index 6344c043c66..d4d5a96a5c4 100755 --- a/test/sharness/t0140-swarm.sh +++ b/test/sharness/t0140-swarm.sh @@ -13,86 +13,86 @@ test_init_ipfs test_launch_ipfs_daemon test_expect_success 'disconnected: peers is empty' ' - ipfs swarm peers >actual && - test_must_be_empty actual + ipfs swarm peers >actual && + test_must_be_empty actual ' test_expect_success 'disconnected: addrs local has localhost' ' - ipfs swarm addrs local >actual && - grep "/ip4/127.0.0.1" actual + ipfs swarm addrs local >actual && + grep "/ip4/127.0.0.1" actual ' test_expect_success 'disconnected: addrs local matches ipfs id' ' - ipfs id -f="\\n" | sort >expected && - ipfs swarm addrs local --id | sort >actual && - test_cmp expected actual + ipfs id -f="\\n" | sort >expected && + ipfs swarm addrs local --id | sort >actual && + test_cmp expected actual ' test_expect_success "ipfs id self works" ' - myid=$(ipfs id -f="") && - ipfs id --timeout=1s $myid > output + myid=$(ipfs id -f="") && + ipfs id --timeout=1s $myid > output ' test_expect_success "output looks good" ' - grep $myid output && - grep PublicKey output + grep $myid output && + grep PublicKey output ' addr="/ip4/127.0.0.1/tcp/9898/ipfs/QmUWKoHbjsqsSMesRC2Zoscs8edyFz6F77auBB1YBBhgpX" test_expect_success "cant trigger a dial backoff with swarm connect" ' - test_expect_code 1 ipfs swarm connect $addr 2> connect_out - test_expect_code 1 ipfs swarm connect $addr 2>> connect_out - test_expect_code 1 ipfs swarm connect $addr 2>> connect_out - test_expect_code 1 grep "backoff" connect_out + test_expect_code 1 ipfs swarm connect $addr 2> connect_out + test_expect_code 1 ipfs swarm connect $addr 2>> connect_out + test_expect_code 1 ipfs swarm connect $addr 2>> connect_out + test_expect_code 1 grep "backoff" connect_out ' test_kill_ipfs_daemon announceCfg='["/ip4/127.0.0.1/tcp/4001", "/ip4/1.2.3.4/tcp/1234"]' test_expect_success "test_config_set succeeds" " - ipfs config --json Addresses.Announce '$announceCfg' + ipfs config --json Addresses.Announce '$announceCfg' " test_launch_ipfs_daemon test_expect_success 'Addresses.Announce affects addresses' ' - ipfs swarm addrs local >actual && - grep "/ip4/1.2.3.4/tcp/1234" actual && - ipfs id -f"" | xargs -n1 echo >actual && - grep "/ip4/1.2.3.4/tcp/1234" actual + ipfs swarm addrs local >actual && + grep "/ip4/1.2.3.4/tcp/1234" actual && + ipfs id -f"" | xargs -n1 echo >actual && + grep "/ip4/1.2.3.4/tcp/1234" actual ' test_kill_ipfs_daemon noAnnounceCfg='["/ip4/1.2.3.4/tcp/1234"]' test_expect_success "test_config_set succeeds" " - ipfs config --json Addresses.NoAnnounce '$noAnnounceCfg' + ipfs config --json Addresses.NoAnnounce '$noAnnounceCfg' " test_launch_ipfs_daemon test_expect_success "Addresses.NoAnnounce affects addresses" ' - ipfs swarm addrs local >actual && - grep -v "/ip4/1.2.3.4/tcp/1234" actual && - ipfs id -f"" | xargs -n1 echo >actual && - grep -v "/ip4/1.2.3.4/tcp/1234" actual + ipfs swarm addrs local >actual && + grep -v "/ip4/1.2.3.4/tcp/1234" actual && + ipfs id -f"" | xargs -n1 echo >actual && + grep -v "/ip4/1.2.3.4/tcp/1234" actual ' test_kill_ipfs_daemon noAnnounceCfg='["/ip4/1.2.3.4/ipcidr/16"]' test_expect_success "test_config_set succeeds" " - ipfs config --json Addresses.NoAnnounce '$noAnnounceCfg' + ipfs config --json Addresses.NoAnnounce '$noAnnounceCfg' " test_launch_ipfs_daemon test_expect_success "Addresses.NoAnnounce with /ipcidr affects addresses" ' - ipfs swarm addrs local >actual && - grep -v "/ip4/1.2.3.4/tcp/1234" actual && - ipfs id -f"" | xargs -n1 echo >actual && - grep -v "/ip4/1.2.3.4/tcp/1234" actual + ipfs swarm addrs local >actual && + grep -v "/ip4/1.2.3.4/tcp/1234" actual && + ipfs id -f"" | xargs -n1 echo >actual && + grep -v "/ip4/1.2.3.4/tcp/1234" actual ' test_kill_ipfs_daemon diff --git a/test/sharness/t0141-addfilter.sh b/test/sharness/t0141-addfilter.sh index ab75e832ded..490fb3a0d37 100755 --- a/test/sharness/t0141-addfilter.sh +++ b/test/sharness/t0141-addfilter.sh @@ -16,99 +16,99 @@ AF4="/ip4/172.16.0.0/ipcidr/12" test_init_ipfs test_swarm_filter_cmd() { - printf "" > list_expected - for AF in "$@" - do - echo "$AF" >>list_expected - done - - test_expect_success "'ipfs swarm filters' succeeds" ' - ipfs swarm filters > list_actual - ' - - test_expect_success "'ipfs swarm filters' output looks good" ' - test_sort_cmp list_expected list_actual - ' + printf "" > list_expected + for AF in "$@" + do + echo "$AF" >>list_expected + done + + test_expect_success "'ipfs swarm filters' succeeds" ' + ipfs swarm filters > list_actual + ' + + test_expect_success "'ipfs swarm filters' output looks good" ' + test_sort_cmp list_expected list_actual + ' } test_config_swarm_addrfilters_cmd() { - printf "" > list_expected - for AF in "$@" - do - echo "$AF" >>list_expected - done - - test_expect_success "'ipfs config Swarm.AddrFilters' succeeds" ' - ipfs config Swarm.AddrFilters > list_actual - ' - - printf "" > list_actual_cleaned - if [ "$( cat list_actual )" != "[]" -a "$( cat list_actual )" != "null" ]; - then - grep -v "^\]" list_actual | - grep -v "^\[" | - tr -d '" ,' > list_actual_cleaned - fi - - test_expect_success "'ipfs config Swarm.AddrFilters' output looks good" ' - test_sort_cmp list_expected list_actual_cleaned - ' + printf "" > list_expected + for AF in "$@" + do + echo "$AF" >>list_expected + done + + test_expect_success "'ipfs config Swarm.AddrFilters' succeeds" ' + ipfs config Swarm.AddrFilters > list_actual + ' + + printf "" > list_actual_cleaned + if [ "$( cat list_actual )" != "[]" -a "$( cat list_actual )" != "null" ]; + then + grep -v "^\]" list_actual | + grep -v "^\[" | + tr -d '" ,' > list_actual_cleaned + fi + + test_expect_success "'ipfs config Swarm.AddrFilters' output looks good" ' + test_sort_cmp list_expected list_actual_cleaned + ' } test_swarm_filters() { - # expect first address from config - test_swarm_filter_cmd $AF1 $AF4 + # expect first address from config + test_swarm_filter_cmd $AF1 $AF4 - test_config_swarm_addrfilters_cmd $AF1 $AF4 + test_config_swarm_addrfilters_cmd $AF1 $AF4 - ipfs swarm filters rm all + ipfs swarm filters rm all - test_swarm_filter_cmd + test_swarm_filter_cmd - test_config_swarm_addrfilters_cmd + test_config_swarm_addrfilters_cmd - test_expect_success "'ipfs swarm filter add' succeeds" ' - ipfs swarm filters add $AF1 $AF2 $AF3 - ' + test_expect_success "'ipfs swarm filter add' succeeds" ' + ipfs swarm filters add $AF1 $AF2 $AF3 + ' - test_swarm_filter_cmd $AF1 $AF2 $AF3 + test_swarm_filter_cmd $AF1 $AF2 $AF3 - test_config_swarm_addrfilters_cmd $AF1 $AF2 $AF3 + test_config_swarm_addrfilters_cmd $AF1 $AF2 $AF3 - test_expect_success "'ipfs swarm filter rm' succeeds" ' - ipfs swarm filters rm $AF2 $AF3 - ' + test_expect_success "'ipfs swarm filter rm' succeeds" ' + ipfs swarm filters rm $AF2 $AF3 + ' - test_swarm_filter_cmd $AF1 + test_swarm_filter_cmd $AF1 - test_config_swarm_addrfilters_cmd $AF1 + test_config_swarm_addrfilters_cmd $AF1 - test_expect_success "'ipfs swarm filter add' succeeds" ' - ipfs swarm filters add $AF4 $AF2 - ' + test_expect_success "'ipfs swarm filter add' succeeds" ' + ipfs swarm filters add $AF4 $AF2 + ' - test_swarm_filter_cmd $AF1 $AF2 $AF4 + test_swarm_filter_cmd $AF1 $AF2 $AF4 - test_config_swarm_addrfilters_cmd $AF1 $AF2 $AF4 + test_config_swarm_addrfilters_cmd $AF1 $AF2 $AF4 - test_expect_success "'ipfs swarm filter rm' succeeds" ' - ipfs swarm filters rm $AF1 $AF2 $AF4 - ' + test_expect_success "'ipfs swarm filter rm' succeeds" ' + ipfs swarm filters rm $AF1 $AF2 $AF4 + ' - test_swarm_filter_cmd + test_swarm_filter_cmd - test_config_swarm_addrfilters_cmd + test_config_swarm_addrfilters_cmd } test_expect_success "init without any filters" ' - echo "null" >expected && - ipfs config Swarm.AddrFilters >actual && - test_cmp expected actual + echo "null" >expected && + ipfs config Swarm.AddrFilters >actual && + test_cmp expected actual ' test_expect_success "adding addresses to the config to filter succeeds" ' - ipfs config --json Swarm.AddrFilters "[\"$AF1\", \"$AF4\"]" + ipfs config --json Swarm.AddrFilters "[\"$AF1\", \"$AF4\"]" ' test_launch_ipfs_daemon diff --git a/test/sharness/t0150-clisuggest.sh b/test/sharness/t0150-clisuggest.sh index 6cf6ad1be17..f7ab64acfc0 100755 --- a/test/sharness/t0150-clisuggest.sh +++ b/test/sharness/t0150-clisuggest.sh @@ -7,26 +7,26 @@ test_description="Test ipfs cli cmd suggest" test_suggest() { - test_expect_success "test command fails" ' - test_must_fail ipfs kog 2>actual - ' - - test_expect_success "test one command is suggested" ' - grep "Did you mean this?" actual && - grep "log" actual || - test_fsh cat actual - ' - - test_expect_success "test command fails" ' - test_must_fail ipfs lis 2>actual - ' - - test_expect_success "test multiple commands are suggested" ' - grep "Did you mean any of these?" actual && - grep "ls" actual && - grep "id" actual || - test_fsh cat actual - ' + test_expect_success "test command fails" ' + test_must_fail ipfs kog 2>actual + ' + + test_expect_success "test one command is suggested" ' + grep "Did you mean this?" actual && + grep "log" actual || + test_fsh cat actual + ' + + test_expect_success "test command fails" ' + test_must_fail ipfs lis 2>actual + ' + + test_expect_success "test multiple commands are suggested" ' + grep "Did you mean any of these?" actual && + grep "ls" actual && + grep "id" actual || + test_fsh cat actual + ' } diff --git a/test/sharness/t0151-sysdiag.sh b/test/sharness/t0151-sysdiag.sh index a0a37831fc5..9565570371b 100755 --- a/test/sharness/t0151-sysdiag.sh +++ b/test/sharness/t0151-sysdiag.sh @@ -11,38 +11,38 @@ test_description="test output of sysdiag command" test_init_ipfs test_expect_success "ipfs diag sys succeeds" ' - ipfs diag sys > output + ipfs diag sys > output ' test_expect_success "output contains some expected keys" ' - grep "virt" output && - grep "interface_addresses" output && - grep "arch" output && - grep "online" output + grep "virt" output && + grep "interface_addresses" output && + grep "arch" output && + grep "online" output ' test_expect_success "uname succeeds" ' - UOUT=$(uname) + UOUT=$(uname) ' test_expect_success "output is similar to uname" ' - case $UOUT in - Linux) - grep linux output > /dev/null - ;; - Darwin) - grep darwin output > /dev/null - ;; - FreeBSD) - grep freebsd output > /dev/null - ;; - CYGWIN*) - grep windows output > /dev/null - ;; - *) - test_fsh echo system check for $UOUT failed, unsupported system? - ;; - esac + case $UOUT in + Linux) + grep linux output > /dev/null + ;; + Darwin) + grep darwin output > /dev/null + ;; + FreeBSD) + grep freebsd output > /dev/null + ;; + CYGWIN*) + grep windows output > /dev/null + ;; + *) + test_fsh echo system check for $UOUT failed, unsupported system? + ;; + esac ' test_done diff --git a/test/sharness/t0160-resolve.sh b/test/sharness/t0160-resolve.sh index 1642d51aacb..65aac42ddc9 100755 --- a/test/sharness/t0160-resolve.sh +++ b/test/sharness/t0160-resolve.sh @@ -7,103 +7,103 @@ test_description="Test resolve command" test_init_ipfs test_expect_success "resolve: prepare files" ' - mkdir -p a/b && - echo "a/b/c" >a/b/c && - a_hash=$(ipfs add -q -r a | tail -n1) && - b_hash=$(ipfs add -q -r a/b | tail -n1) && - c_hash=$(ipfs add -q -r a/b/c | tail -n1) + mkdir -p a/b && + echo "a/b/c" >a/b/c && + a_hash=$(ipfs add -q -r a | tail -n1) && + b_hash=$(ipfs add -q -r a/b | tail -n1) && + c_hash=$(ipfs add -q -r a/b/c | tail -n1) ' test_resolve_setup_name() { - ref=$1 - - test_expect_success "resolve: prepare name" ' - id_hash=$(ipfs id -f="") && - ipfs name publish "$ref" && - printf "$ref\n" >expected_nameval && - ipfs name resolve >actual_nameval && - test_cmp expected_nameval actual_nameval - ' + ref=$1 + + test_expect_success "resolve: prepare name" ' + id_hash=$(ipfs id -f="") && + ipfs name publish "$ref" && + printf "$ref\n" >expected_nameval && + ipfs name resolve >actual_nameval && + test_cmp expected_nameval actual_nameval + ' } test_resolve_setup_name_fail() { - ref=$1 - - test_expect_failure "resolve: prepare name" ' - id_hash=$(ipfs id -f="") && - ipfs name publish "$ref" && - printf "$ref" >expected_nameval && - ipfs name resolve >actual_nameval && - test_cmp expected_nameval actual_nameval - ' + ref=$1 + + test_expect_failure "resolve: prepare name" ' + id_hash=$(ipfs id -f="") && + ipfs name publish "$ref" && + printf "$ref" >expected_nameval && + ipfs name resolve >actual_nameval && + test_cmp expected_nameval actual_nameval + ' } test_resolve() { - src=$1 - dst=$2 + src=$1 + dst=$2 - test_expect_success "resolve succeeds: $src" ' - ipfs resolve -r "$src" >actual - ' + test_expect_success "resolve succeeds: $src" ' + ipfs resolve -r "$src" >actual + ' - test_expect_success "resolved correctly: $src -> $dst" ' - printf "$dst\n" >expected && - test_cmp expected actual - ' + test_expect_success "resolved correctly: $src -> $dst" ' + printf "$dst\n" >expected && + test_cmp expected actual + ' } test_resolve_cmd() { - test_resolve "/ipfs/$a_hash" "/ipfs/$a_hash" - test_resolve "/ipfs/$a_hash/b" "/ipfs/$b_hash" - test_resolve "/ipfs/$a_hash/b/c" "/ipfs/$c_hash" - test_resolve "/ipfs/$b_hash/c" "/ipfs/$c_hash" + test_resolve "/ipfs/$a_hash" "/ipfs/$a_hash" + test_resolve "/ipfs/$a_hash/b" "/ipfs/$b_hash" + test_resolve "/ipfs/$a_hash/b/c" "/ipfs/$c_hash" + test_resolve "/ipfs/$b_hash/c" "/ipfs/$c_hash" - test_resolve_setup_name "/ipfs/$a_hash" - test_resolve "/ipns/$id_hash" "/ipfs/$a_hash" - test_resolve "/ipns/$id_hash/b" "/ipfs/$b_hash" - test_resolve "/ipns/$id_hash/b/c" "/ipfs/$c_hash" + test_resolve_setup_name "/ipfs/$a_hash" + test_resolve "/ipns/$id_hash" "/ipfs/$a_hash" + test_resolve "/ipns/$id_hash/b" "/ipfs/$b_hash" + test_resolve "/ipns/$id_hash/b/c" "/ipfs/$c_hash" - test_resolve_setup_name "/ipfs/$b_hash" - test_resolve "/ipns/$id_hash" "/ipfs/$b_hash" - test_resolve "/ipns/$id_hash/c" "/ipfs/$c_hash" + test_resolve_setup_name "/ipfs/$b_hash" + test_resolve "/ipns/$id_hash" "/ipfs/$b_hash" + test_resolve "/ipns/$id_hash/c" "/ipfs/$c_hash" - test_resolve_setup_name "/ipfs/$c_hash" - test_resolve "/ipns/$id_hash" "/ipfs/$c_hash" + test_resolve_setup_name "/ipfs/$c_hash" + test_resolve "/ipns/$id_hash" "/ipfs/$c_hash" } #todo remove this once the online resolve is fixed test_resolve_fail() { - src=$1 - dst=$2 + src=$1 + dst=$2 - test_expect_failure "resolve succeeds: $src" ' - ipfs resolve "$src" >actual - ' + test_expect_failure "resolve succeeds: $src" ' + ipfs resolve "$src" >actual + ' - test_expect_failure "resolved correctly: $src -> $dst" ' - printf "$dst" >expected && - test_cmp expected actual - ' + test_expect_failure "resolved correctly: $src -> $dst" ' + printf "$dst" >expected && + test_cmp expected actual + ' } test_resolve_cmd_fail() { - test_resolve "/ipfs/$a_hash" "/ipfs/$a_hash" - test_resolve "/ipfs/$a_hash/b" "/ipfs/$b_hash" - test_resolve "/ipfs/$a_hash/b/c" "/ipfs/$c_hash" - test_resolve "/ipfs/$b_hash/c" "/ipfs/$c_hash" - - test_resolve_setup_name_fail "/ipfs/$a_hash" - test_resolve_fail "/ipns/$id_hash" "/ipfs/$a_hash" - test_resolve_fail "/ipns/$id_hash/b" "/ipfs/$b_hash" - test_resolve_fail "/ipns/$id_hash/b/c" "/ipfs/$c_hash" - - test_resolve_setup_name_fail "/ipfs/$b_hash" - test_resolve_fail "/ipns/$id_hash" "/ipfs/$b_hash" - test_resolve_fail "/ipns/$id_hash/c" "/ipfs/$c_hash" - - test_resolve_setup_name_fail "/ipfs/$c_hash" - test_resolve_fail "/ipns/$id_hash" "/ipfs/$c_hash" + test_resolve "/ipfs/$a_hash" "/ipfs/$a_hash" + test_resolve "/ipfs/$a_hash/b" "/ipfs/$b_hash" + test_resolve "/ipfs/$a_hash/b/c" "/ipfs/$c_hash" + test_resolve "/ipfs/$b_hash/c" "/ipfs/$c_hash" + + test_resolve_setup_name_fail "/ipfs/$a_hash" + test_resolve_fail "/ipns/$id_hash" "/ipfs/$a_hash" + test_resolve_fail "/ipns/$id_hash/b" "/ipfs/$b_hash" + test_resolve_fail "/ipns/$id_hash/b/c" "/ipfs/$c_hash" + + test_resolve_setup_name_fail "/ipfs/$b_hash" + test_resolve_fail "/ipns/$id_hash" "/ipfs/$b_hash" + test_resolve_fail "/ipns/$id_hash/c" "/ipfs/$c_hash" + + test_resolve_setup_name_fail "/ipfs/$c_hash" + test_resolve_fail "/ipns/$id_hash" "/ipfs/$c_hash" } # should work offline diff --git a/test/sharness/t0165-keystore.sh b/test/sharness/t0165-keystore.sh index 305ab1e38c1..966edb11879 100755 --- a/test/sharness/t0165-keystore.sh +++ b/test/sharness/t0165-keystore.sh @@ -11,62 +11,62 @@ test_description="Test keystore commands" test_init_ipfs test_key_cmd() { - test_expect_success "create a new rsa key" ' - rsahash=$(ipfs key gen foobarsa --type=rsa --size=2048) - ' + test_expect_success "create a new rsa key" ' + rsahash=$(ipfs key gen foobarsa --type=rsa --size=2048) + ' - test_expect_success "create a new ed25519 key" ' - edhash=$(ipfs key gen bazed --type=ed25519) - ' + test_expect_success "create a new ed25519 key" ' + edhash=$(ipfs key gen bazed --type=ed25519) + ' - test_expect_success "both keys show up in list output" ' - echo bazed > list_exp && - echo foobarsa >> list_exp && - echo self >> list_exp - ipfs key list | sort > list_out && - test_cmp list_exp list_out - ' + test_expect_success "both keys show up in list output" ' + echo bazed > list_exp && + echo foobarsa >> list_exp && + echo self >> list_exp + ipfs key list | sort > list_out && + test_cmp list_exp list_out + ' - test_expect_success "key hashes show up in long list output" ' - ipfs key list -l | grep $edhash > /dev/null && - ipfs key list -l | grep $rsahash > /dev/null - ' + test_expect_success "key hashes show up in long list output" ' + ipfs key list -l | grep $edhash > /dev/null && + ipfs key list -l | grep $rsahash > /dev/null + ' - test_expect_success "key list -l contains self key with peerID" ' - PeerID="$(ipfs config Identity.PeerID)" - ipfs key list -l | grep "$PeerID self" - ' + test_expect_success "key list -l contains self key with peerID" ' + PeerID="$(ipfs config Identity.PeerID)" + ipfs key list -l | grep "$PeerID self" + ' - test_expect_success "key rm remove a key" ' - ipfs key rm foobarsa - echo bazed > list_exp && - echo self >> list_exp - ipfs key list | sort > list_out && - test_cmp list_exp list_out - ' + test_expect_success "key rm remove a key" ' + ipfs key rm foobarsa + echo bazed > list_exp && + echo self >> list_exp + ipfs key list | sort > list_out && + test_cmp list_exp list_out + ' - test_expect_success "key rm can't remove self" ' - test_must_fail ipfs key rm self 2>&1 | tee key_rm_out && - grep -q "Error: cannot remove key with name" key_rm_out - ' + test_expect_success "key rm can't remove self" ' + test_must_fail ipfs key rm self 2>&1 | tee key_rm_out && + grep -q "Error: cannot remove key with name" key_rm_out + ' - test_expect_success "key rename rename a key" ' - ipfs key rename bazed fooed - echo fooed > list_exp && - echo self >> list_exp - ipfs key list | sort > list_out && - test_cmp list_exp list_out - ' + test_expect_success "key rename rename a key" ' + ipfs key rename bazed fooed + echo fooed > list_exp && + echo self >> list_exp + ipfs key list | sort > list_out && + test_cmp list_exp list_out + ' - test_expect_success "key rename can't rename self" ' - test_must_fail ipfs key rename self bar 2>&1 | tee key_rename_out && - grep -q "Error: cannot rename key with name" key_rename_out - ' + test_expect_success "key rename can't rename self" ' + test_must_fail ipfs key rename self bar 2>&1 | tee key_rename_out && + grep -q "Error: cannot rename key with name" key_rename_out + ' - test_expect_success "key rename can't overwrite self, even with force" ' - test_must_fail ipfs key rename -f fooed self 2>&1 | tee key_rename_out && - grep -q "Error: cannot overwrite key with name" key_rename_out - ' + test_expect_success "key rename can't overwrite self, even with force" ' + test_must_fail ipfs key rename -f fooed self 2>&1 | tee key_rename_out && + grep -q "Error: cannot overwrite key with name" key_rename_out + ' } test_key_cmd diff --git a/test/sharness/t0170-dht.sh b/test/sharness/t0170-dht.sh index 06c4a4ee3cf..597481d56df 100755 --- a/test/sharness/t0170-dht.sh +++ b/test/sharness/t0170-dht.sh @@ -7,48 +7,48 @@ test_description="Test dht command" # start iptb + wait for peering NUM_NODES=5 test_expect_success 'init iptb' ' - iptb init -n $NUM_NODES --bootstrap=none --port=0 + iptb init -n $NUM_NODES --bootstrap=none --port=0 ' startup_cluster $NUM_NODES test_expect_success 'peer ids' ' - PEERID_0=$(iptb get id 0) && - PEERID_2=$(iptb get id 2) + PEERID_0=$(iptb get id 0) && + PEERID_2=$(iptb get id 2) ' # ipfs dht findpeer test_expect_success 'findpeer' ' - ipfsi 1 dht findpeer $PEERID_0 | sort >actual && - ipfsi 0 id -f "" | cut -d / -f 1-5 | sort >expected && - test_cmp actual expected + ipfsi 1 dht findpeer $PEERID_0 | sort >actual && + ipfsi 0 id -f "" | cut -d / -f 1-5 | sort >expected && + test_cmp actual expected ' # ipfs dht put test_expect_success 'put' ' - ipfsi 1 dht put planet pluto | sort >putted && - [ -s putted ] || - test_fsh cat putted + ipfsi 1 dht put planet pluto | sort >putted && + [ -s putted ] || + test_fsh cat putted ' test_expect_success "add a ref so we can find providers for it" ' - echo "some stuff" > afile && - HASH=$(ipfsi 3 add -q afile) + echo "some stuff" > afile && + HASH=$(ipfsi 3 add -q afile) ' # ipfs dht findprovs test_expect_success 'findprovs' ' - ipfsi 4 dht findprovs $HASH > provs && - iptb get id 3 > expected && - test_cmp provs expected + ipfsi 4 dht findprovs $HASH > provs && + iptb get id 3 > expected && + test_cmp provs expected ' # ipfs dht get test_expect_success 'get' ' - ipfsi 0 dht put bar foo >actual && - ipfsi 4 dht get -v bar >actual && - egrep "error: record key does not have selectorfunc" actual > /dev//null || - test_fsh cat actual + ipfsi 0 dht put bar foo >actual && + ipfsi 4 dht get -v bar >actual && + egrep "error: record key does not have selectorfunc" actual > /dev//null || + test_fsh cat actual ' # ipfs dht query @@ -56,16 +56,16 @@ test_expect_success 'get' ' ## turns out to be the closest to what a key hashes to. # TODO: flaky. tracked by https://github.com/ipfs/go-ipfs/issues/2620 test_expect_success 'query' ' - ipfsi 3 dht query banana >actual && - ipfsi 3 dht query apple >>actual && - ipfsi 3 dht query pear >>actual && - PEERS=$(wc -l actual | cut -d '"'"' '"'"' -f 1) && - [ -s actual ] || - test_might_fail test_fsh cat actual + ipfsi 3 dht query banana >actual && + ipfsi 3 dht query apple >>actual && + ipfsi 3 dht query pear >>actual && + PEERS=$(wc -l actual | cut -d '"'"' '"'"' -f 1) && + [ -s actual ] || + test_might_fail test_fsh cat actual ' test_expect_success 'stop iptb' ' - iptb stop + iptb stop ' test_done diff --git a/test/sharness/t0175-reprovider.sh b/test/sharness/t0175-reprovider.sh index c1116c612ac..88051b7d25c 100755 --- a/test/sharness/t0175-reprovider.sh +++ b/test/sharness/t0175-reprovider.sh @@ -7,59 +7,59 @@ test_description="Test reprovider" NUM_NODES=6 init_strategy() { - test_expect_success 'init iptb' ' - iptb init -f -n $NUM_NODES --bootstrap=none --port=0 - ' + test_expect_success 'init iptb' ' + iptb init -f -n $NUM_NODES --bootstrap=none --port=0 + ' - test_expect_success 'peer ids' ' - PEERID_0=$(iptb get id 0) && - PEERID_1=$(iptb get id 1) - ' + test_expect_success 'peer ids' ' + PEERID_0=$(iptb get id 0) && + PEERID_1=$(iptb get id 1) + ' - test_expect_success 'use pinning startegy for reprovider' ' - ipfsi 0 config Reprovider.Strategy '$1' - ' + test_expect_success 'use pinning startegy for reprovider' ' + ipfsi 0 config Reprovider.Strategy '$1' + ' - startup_cluster ${NUM_NODES} + startup_cluster ${NUM_NODES} } findprovs_empty() { - test_expect_success 'findprovs '$1' succeeds' ' - ipfsi 1 dht findprovs -n 1 '$1' > findprovsOut - ' + test_expect_success 'findprovs '$1' succeeds' ' + ipfsi 1 dht findprovs -n 1 '$1' > findprovsOut + ' - test_expect_success "findprovs $1 output is empty" ' - test_must_be_empty findprovsOut - ' + test_expect_success "findprovs $1 output is empty" ' + test_must_be_empty findprovsOut + ' } findprovs_expect() { - test_expect_success 'findprovs '$1' succeeds' ' - ipfsi 1 dht findprovs -n 1 '$1' > findprovsOut && - echo '$2' > expected - ' - - test_expect_success "findprovs $1 output looks good" ' - test_cmp findprovsOut expected - ' + test_expect_success 'findprovs '$1' succeeds' ' + ipfsi 1 dht findprovs -n 1 '$1' > findprovsOut && + echo '$2' > expected + ' + + test_expect_success "findprovs $1 output looks good" ' + test_cmp findprovsOut expected + ' } reprovide() { - test_expect_success 'reprovide' ' - # TODO: this hangs, though only after reprovision was done - ipfsi 0 bitswap reprovide - ' + test_expect_success 'reprovide' ' + # TODO: this hangs, though only after reprovision was done + ipfsi 0 bitswap reprovide + ' } test_expect_success 'stop peer 1' ' - iptb stop 1 + iptb stop 1 ' # Test 'all' strategy init_strategy 'all' test_expect_success 'add test object' ' - HASH_0=$(echo "foo" | ipfsi 0 add -q --local) + HASH_0=$(echo "foo" | ipfsi 0 add -q --local) ' findprovs_empty '$HASH_0' @@ -70,14 +70,14 @@ findprovs_expect '$HASH_0' '$PEERID_0' init_strategy 'pinned' test_expect_success 'prepare test files' ' - echo foo > f1 && - echo bar > f2 + echo foo > f1 && + echo bar > f2 ' test_expect_success 'add test objects' ' - HASH_FOO=$(ipfsi 0 add -q --local --pin=false f1) && - HASH_BAR=$(ipfsi 0 add -q --local --pin=false f2) && - HASH_BAR_DIR=$(ipfsi 0 add -q --local -w f2) + HASH_FOO=$(ipfsi 0 add -q --local --pin=false f1) && + HASH_BAR=$(ipfsi 0 add -q --local --pin=false f2) && + HASH_BAR_DIR=$(ipfsi 0 add -q --local -w f2) ' findprovs_empty '$HASH_FOO' @@ -91,23 +91,23 @@ findprovs_expect '$HASH_BAR' '$PEERID_0' findprovs_expect '$HASH_BAR_DIR' '$PEERID_0' test_expect_success 'stop peer 1' ' - iptb stop 1 + iptb stop 1 ' # Test 'roots' strategy init_strategy 'roots' test_expect_success 'prepare test files' ' - echo foo > f1 && - echo bar > f2 && - echo baz > f3 + echo foo > f1 && + echo bar > f2 && + echo baz > f3 ' test_expect_success 'add test objects' ' - HASH_FOO=$(ipfsi 0 add -q --local --pin=false f1) && - HASH_BAR=$(ipfsi 0 add -q --local --pin=false f2) && - HASH_BAZ=$(ipfsi 0 add -q --local f3) && - HASH_BAR_DIR=$(ipfsi 0 add -q --local -w f2 | tail -1) + HASH_FOO=$(ipfsi 0 add -q --local --pin=false f1) && + HASH_BAR=$(ipfsi 0 add -q --local --pin=false f2) && + HASH_BAZ=$(ipfsi 0 add -q --local f3) && + HASH_BAR_DIR=$(ipfsi 0 add -q --local -w f2 | tail -1) ' findprovs_empty '$HASH_FOO' @@ -122,27 +122,27 @@ findprovs_expect '$HASH_BAZ' '$PEERID_0' findprovs_expect '$HASH_BAR_DIR' '$PEERID_0' test_expect_success 'stop peer 1' ' - iptb stop 1 + iptb stop 1 ' # Test reprovider working with ticking disabled test_expect_success 'init iptb' ' - iptb init -f -n $NUM_NODES --bootstrap=none --port=0 + iptb init -f -n $NUM_NODES --bootstrap=none --port=0 ' test_expect_success 'peer ids' ' - PEERID_0=$(iptb get id 0) && - PEERID_1=$(iptb get id 1) + PEERID_0=$(iptb get id 0) && + PEERID_1=$(iptb get id 1) ' test_expect_success 'Disable reprovider ticking' ' - ipfsi 0 config Reprovider.Interval 0 + ipfsi 0 config Reprovider.Interval 0 ' startup_cluster ${NUM_NODES} test_expect_success 'add test object' ' - HASH_0=$(echo "foo" | ipfsi 0 add -q --local) + HASH_0=$(echo "foo" | ipfsi 0 add -q --local) ' findprovs_empty '$HASH_0' diff --git a/test/sharness/t0180-p2p.sh b/test/sharness/t0180-p2p.sh index e55ee95888e..a6f69642183 100755 --- a/test/sharness/t0180-p2p.sh +++ b/test/sharness/t0180-p2p.sh @@ -6,159 +6,159 @@ test_description="Test experimental p2p commands" # start iptb + wait for peering test_expect_success 'init iptb' ' - iptb init -n 2 --bootstrap=none --port=0 + iptb init -n 2 --bootstrap=none --port=0 ' test_expect_success 'generate test data' ' - echo "ABCDEF" > test0.bin && - echo "012345" > test1.bin + echo "ABCDEF" > test0.bin && + echo "012345" > test1.bin ' startup_cluster 2 test_expect_success 'peer ids' ' - PEERID_0=$(iptb get id 0) && - PEERID_1=$(iptb get id 1) + PEERID_0=$(iptb get id 0) && + PEERID_1=$(iptb get id 1) ' test_expect_success "test ports are closed" ' - (! (netstat -ln | grep "LISTEN" | grep ":10101 ")) && - (! (netstat -ln | grep "LISTEN" | grep ":10102 ")) + (! (netstat -ln | grep "LISTEN" | grep ":10101 ")) && + (! (netstat -ln | grep "LISTEN" | grep ":10102 ")) ' test_expect_success 'fail without config option being enabled' ' - test_must_fail ipfsi 0 p2p stream ls + test_must_fail ipfsi 0 p2p stream ls ' test_expect_success "enable filestore config setting" ' - ipfsi 0 config --json Experimental.Libp2pStreamMounting true - ipfsi 1 config --json Experimental.Libp2pStreamMounting true + ipfsi 0 config --json Experimental.Libp2pStreamMounting true + ipfsi 1 config --json Experimental.Libp2pStreamMounting true ' test_expect_success 'start p2p listener' ' - ipfsi 0 p2p listener open p2p-test /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log + ipfsi 0 p2p listener open p2p-test /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log ' test_expect_success 'Test server to client communications' ' - ma-pipe-unidir --listen --pidFile=listener.pid send /ip4/127.0.0.1/tcp/10101 < test0.bin & + ma-pipe-unidir --listen --pidFile=listener.pid send /ip4/127.0.0.1/tcp/10101 < test0.bin & - go-sleep 500ms && - kill -0 $(cat listener.pid) && + go-sleep 500ms && + kill -0 $(cat listener.pid) && - ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log && - ma-pipe-unidir recv /ip4/127.0.0.1/tcp/10102 > client.out && - test ! -f listener.pid + ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log && + ma-pipe-unidir recv /ip4/127.0.0.1/tcp/10102 > client.out && + test ! -f listener.pid ' test_expect_success 'Test client to server communications' ' - ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 > server.out & + ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 > server.out & - go-sleep 500ms && - kill -0 $(cat listener.pid) && + go-sleep 500ms && + kill -0 $(cat listener.pid) && - ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log && - ma-pipe-unidir send /ip4/127.0.0.1/tcp/10102 < test1.bin && - go-sleep 250ms && - test ! -f listener.pid + ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log && + ma-pipe-unidir send /ip4/127.0.0.1/tcp/10102 < test1.bin && + go-sleep 250ms && + test ! -f listener.pid ' test_expect_success 'server to client output looks good' ' - test_cmp client.out test0.bin + test_cmp client.out test0.bin ' test_expect_success 'client to server output looks good' ' - test_cmp server.out test1.bin + test_cmp server.out test1.bin ' test_expect_success "'ipfs listener p2p ls' succeeds" ' - echo "/ip4/127.0.0.1/tcp/10101 /p2p/p2p-test" > expected && - ipfsi 0 p2p listener ls > actual + echo "/ip4/127.0.0.1/tcp/10101 /p2p/p2p-test" > expected && + ipfsi 0 p2p listener ls > actual ' test_expect_success "'ipfs p2p listener ls' output looks good" ' - test_cmp expected actual + test_cmp expected actual ' test_expect_success "Cannot re-register app handler" ' - (! ipfsi 0 p2p listener open p2p-test /ip4/127.0.0.1/tcp/10101) + (! ipfsi 0 p2p listener open p2p-test /ip4/127.0.0.1/tcp/10101) ' test_expect_success "'ipfs p2p stream ls' output is empty" ' - ipfsi 0 p2p stream ls > actual && - test_must_be_empty actual + ipfsi 0 p2p stream ls > actual && + test_must_be_empty actual ' test_expect_success "Setup: Idle stream" ' - ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 & + ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 & - ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log && - ma-pipe-unidir --pidFile=client.pid recv /ip4/127.0.0.1/tcp/10102 & + ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log && + ma-pipe-unidir --pidFile=client.pid recv /ip4/127.0.0.1/tcp/10102 & - go-sleep 500ms && - kill -0 $(cat listener.pid) && kill -0 $(cat client.pid) + go-sleep 500ms && + kill -0 $(cat listener.pid) && kill -0 $(cat client.pid) ' test_expect_success "'ipfs p2p stream ls' succeeds" ' - echo "2 /p2p/p2p-test /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected - ipfsi 0 p2p stream ls > actual + echo "2 /p2p/p2p-test /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected + ipfsi 0 p2p stream ls > actual ' test_expect_success "'ipfs p2p stream ls' output looks good" ' - test_cmp expected actual + test_cmp expected actual ' test_expect_success "'ipfs p2p stream close' closes stream" ' - ipfsi 0 p2p stream close 2 && - ipfsi 0 p2p stream ls > actual && - [ ! -f listener.pid ] && [ ! -f client.pid ] && - test_must_be_empty actual + ipfsi 0 p2p stream close 2 && + ipfsi 0 p2p stream ls > actual && + [ ! -f listener.pid ] && [ ! -f client.pid ] && + test_must_be_empty actual ' test_expect_success "'ipfs p2p listener close' closes app handler" ' - ipfsi 0 p2p listener close p2p-test && - ipfsi 0 p2p listener ls > actual && - test_must_be_empty actual + ipfsi 0 p2p listener close p2p-test && + ipfsi 0 p2p listener ls > actual && + test_must_be_empty actual ' test_expect_success "Setup: Idle stream(2)" ' - ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 & + ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 & - ipfsi 0 p2p listener open p2p-test2 /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log && - ipfsi 1 p2p stream dial $PEERID_0 p2p-test2 /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log && - ma-pipe-unidir --pidFile=client.pid recv /ip4/127.0.0.1/tcp/10102 & + ipfsi 0 p2p listener open p2p-test2 /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log && + ipfsi 1 p2p stream dial $PEERID_0 p2p-test2 /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log && + ma-pipe-unidir --pidFile=client.pid recv /ip4/127.0.0.1/tcp/10102 & - go-sleep 500ms && - kill -0 $(cat listener.pid) && kill -0 $(cat client.pid) + go-sleep 500ms && + kill -0 $(cat listener.pid) && kill -0 $(cat client.pid) ' test_expect_success "'ipfs p2p stream ls' succeeds(2)" ' - echo "3 /p2p/p2p-test2 /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected - ipfsi 0 p2p stream ls > actual - test_cmp expected actual + echo "3 /p2p/p2p-test2 /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected + ipfsi 0 p2p stream ls > actual + test_cmp expected actual ' test_expect_success "'ipfs p2p listener close -a' closes app handlers" ' - ipfsi 0 p2p listener close -a && - ipfsi 0 p2p listener ls > actual && - test_must_be_empty actual + ipfsi 0 p2p listener close -a && + ipfsi 0 p2p listener ls > actual && + test_must_be_empty actual ' test_expect_success "'ipfs p2p stream close -a' closes streams" ' - ipfsi 0 p2p stream close -a && - ipfsi 0 p2p stream ls > actual && - [ ! -f listener.pid ] && [ ! -f client.pid ] && - test_must_be_empty actual + ipfsi 0 p2p stream close -a && + ipfsi 0 p2p stream ls > actual && + [ ! -f listener.pid ] && [ ! -f client.pid ] && + test_must_be_empty actual ' test_expect_success "'ipfs p2p listener close' closes app numeric handlers" ' - ipfsi 0 p2p listener open 1234 /ip4/127.0.0.1/tcp/10101 && - ipfsi 0 p2p listener close 1234 && - ipfsi 0 p2p listener ls > actual && - test_must_be_empty actual + ipfsi 0 p2p listener open 1234 /ip4/127.0.0.1/tcp/10101 && + ipfsi 0 p2p listener close 1234 && + ipfsi 0 p2p listener ls > actual && + test_must_be_empty actual ' test_expect_success 'stop iptb' ' - iptb stop + iptb stop ' test_done diff --git a/test/sharness/t0180-pubsub.sh b/test/sharness/t0180-pubsub.sh index 57f6136081f..b8f5f0b1061 100755 --- a/test/sharness/t0180-pubsub.sh +++ b/test/sharness/t0180-pubsub.sh @@ -7,58 +7,58 @@ test_description="Test dht command" # start iptb + wait for peering NUM_NODES=5 test_expect_success 'init iptb' ' - iptb init -n $NUM_NODES --bootstrap=none --port=0 + iptb init -n $NUM_NODES --bootstrap=none --port=0 ' startup_cluster $NUM_NODES --enable-pubsub-experiment test_expect_success 'peer ids' ' - PEERID_0=$(iptb get id 0) && - PEERID_2=$(iptb get id 2) + PEERID_0=$(iptb get id 0) && + PEERID_2=$(iptb get id 2) ' # ipfs pubsub sub test_expect_success 'pubsub' ' - echo "testOK" > expected && - touch empty && - mkfifo wait || - test_fsh echo init fail + echo "testOK" > expected && + touch empty && + mkfifo wait || + test_fsh echo init fail - # ipfs pubsub sub is long-running so we need to start it in the background and - # wait put its output somewhere where we can access it - ( - ipfsi 0 pubsub sub --enc=ndpayload testTopic | if read line; then - echo $line > actual && - echo > wait - fi - ) & + # ipfs pubsub sub is long-running so we need to start it in the background and + # wait put its output somewhere where we can access it + ( + ipfsi 0 pubsub sub --enc=ndpayload testTopic | if read line; then + echo $line > actual && + echo > wait + fi + ) & ' test_expect_success "wait until ipfs pubsub sub is ready to do work" ' - sleep 1 + sleep 1 ' test_expect_success "can see peer subscribed to testTopic" ' - ipfsi 1 pubsub peers testTopic > peers_out + ipfsi 1 pubsub peers testTopic > peers_out ' test_expect_success "output looks good" ' - echo $PEERID_0 > peers_exp && - test_cmp peers_exp peers_out + echo $PEERID_0 > peers_exp && + test_cmp peers_exp peers_out ' test_expect_success "publish something" ' - ipfsi 1 pubsub pub testTopic "testOK" &> pubErr + ipfsi 1 pubsub pub testTopic "testOK" &> pubErr ' test_expect_success "wait until echo > wait executed" ' - cat wait && - test_cmp pubErr empty && - test_cmp expected actual + cat wait && + test_cmp pubErr empty && + test_cmp expected actual ' test_expect_success 'stop iptb' ' - iptb stop + iptb stop ' test_done diff --git a/test/sharness/t0181-private-network.sh b/test/sharness/t0181-private-network.sh index f848a314637..cf2efc6b6f8 100755 --- a/test/sharness/t0181-private-network.sh +++ b/test/sharness/t0181-private-network.sh @@ -13,20 +13,20 @@ test_init_ipfs export LIBP2P_FORCE_PNET=1 test_expect_success "daemon won't start with force pnet env but with no key" ' - test_must_fail go-timeout 5 ipfs daemon > stdout 2>&1 + test_must_fail go-timeout 5 ipfs daemon > stdout 2>&1 ' unset LIBP2P_FORCE_PNET test_expect_success "daemon output incudes info about the reason" ' - grep "private network was not configured but is enforced by the environment" stdout || - test_fsh cat stdout + grep "private network was not configured but is enforced by the environment" stdout || + test_fsh cat stdout ' pnet_key() { - echo '/key/swarm/psk/1.0.0/' - echo '/bin/' - random 16 + echo '/key/swarm/psk/1.0.0/' + echo '/bin/' + random 16 } pnet_key > $IPFS_PATH/swarm.key @@ -34,15 +34,15 @@ pnet_key > $IPFS_PATH/swarm.key LIBP2P_FORCE_PNET=1 test_launch_ipfs_daemon test_expect_success "set up iptb testbed" ' - iptb init -n 5 -p 0 -f --bootstrap=none && - iptb for-each ipfs config --json Addresses.Swarm '"'"'["/ip4/127.0.0.1/tcp/0"]'"'"' + iptb init -n 5 -p 0 -f --bootstrap=none && + iptb for-each ipfs config --json Addresses.Swarm '"'"'["/ip4/127.0.0.1/tcp/0"]'"'"' ' set_key() { - node="$1" - keyfile="$2" + node="$1" + keyfile="$2" - cp "$keyfile" "$IPTB_ROOT/$node/swarm.key" + cp "$keyfile" "$IPTB_ROOT/$node/swarm.key" } pnet_key > key1 @@ -57,68 +57,68 @@ set_key 4 key2 unset LIBP2P_FORCE_PNET test_expect_success "start nodes" ' - iptb start [0-4] + iptb start [0-4] ' test_expect_success "try connecting node in public network with priv networks" ' - iptb connect [1-4] 0 + iptb connect [1-4] 0 ' test_expect_success "node 0 (public network) swarm is empty" ' - ipfsi 0 swarm peers && - [ $(ipfsi 0 swarm peers | wc -l) -eq 0 ] + ipfsi 0 swarm peers && + [ $(ipfsi 0 swarm peers | wc -l) -eq 0 ] ' test_expect_success "try connecting nodes in different private networks" ' - iptb connect 2 3 + iptb connect 2 3 ' test_expect_success "node 3 (pnet 2) swarm is empty" ' - ipfsi 3 swarm peers && - [ $(ipfsi 3 swarm peers | wc -l) -eq 0 ] + ipfsi 3 swarm peers && + [ $(ipfsi 3 swarm peers | wc -l) -eq 0 ] ' test_expect_success "connect nodes in the same pnet" ' - iptb connect 1 2 && - iptb connect 3 4 + iptb connect 1 2 && + iptb connect 3 4 ' test_expect_success "nodes 1 and 2 have connected" ' - ipfsi 2 swarm peers && - [ $(ipfsi 2 swarm peers | wc -l) -eq 1 ] + ipfsi 2 swarm peers && + [ $(ipfsi 2 swarm peers | wc -l) -eq 1 ] ' test_expect_success "nodes 3 and 4 have connected" ' - ipfsi 4 swarm peers && - [ $(ipfsi 4 swarm peers | wc -l) -eq 1 ] + ipfsi 4 swarm peers && + [ $(ipfsi 4 swarm peers | wc -l) -eq 1 ] ' run_single_file_test() { - node1=$1 - node2=$2 + node1=$1 + node2=$2 - test_expect_success "add a file on node$node1" ' - random 1000000 > filea && - FILEA_HASH=$(ipfsi $node1 add -q filea) - ' + test_expect_success "add a file on node$node1" ' + random 1000000 > filea && + FILEA_HASH=$(ipfsi $node1 add -q filea) + ' - check_file_fetch $node1 $FILEA_HASH filea - check_file_fetch $node2 $FILEA_HASH filea + check_file_fetch $node1 $FILEA_HASH filea + check_file_fetch $node2 $FILEA_HASH filea } check_file_fetch() { - node="$1" - fhash="$2" - fname="$3" + node="$1" + fhash="$2" + fname="$3" - test_expect_success "can fetch file" ' - ipfsi $node cat $fhash > fetch_out - ' + test_expect_success "can fetch file" ' + ipfsi $node cat $fhash > fetch_out + ' - test_expect_success "file looks good" ' - test_cmp $fname fetch_out - ' + test_expect_success "file looks good" ' + test_cmp $fname fetch_out + ' } run_single_file_test 1 2 @@ -129,7 +129,7 @@ run_single_file_test 4 3 test_expect_success "stop testbed" ' - iptb stop + iptb stop ' test_done diff --git a/test/sharness/t0182-circuit-relay.sh b/test/sharness/t0182-circuit-relay.sh index 4797447ac73..a9c5dff1f41 100755 --- a/test/sharness/t0182-circuit-relay.sh +++ b/test/sharness/t0182-circuit-relay.sh @@ -7,81 +7,81 @@ test_description="Test circuit relay" # start iptb + wait for peering NUM_NODES=3 test_expect_success 'init iptb' ' - iptb init -n $NUM_NODES --bootstrap=none --port=0 + iptb init -n $NUM_NODES --bootstrap=none --port=0 ' # Network toplogy: A <-> Relay <-> B test_expect_success 'start up nodes for configuration' ' - iptb start --args --routing=none + iptb start --args --routing=none ' test_expect_success 'configure EnableRelayHop in relay node' ' - ipfsi 1 config --json Swarm.EnableRelayHop true + ipfsi 1 config --json Swarm.EnableRelayHop true ' test_expect_success 'restart nodes' ' - iptb stop && - iptb start --args --routing=none + iptb stop && + iptb start --args --routing=none ' test_expect_success 'connect A <-> Relay' ' - iptb connect 0 1 + iptb connect 0 1 ' test_expect_success 'connect B <-> Relay' ' - iptb connect 2 1 + iptb connect 2 1 ' test_expect_success 'wait until relay is ready to do work' ' - sleep 1 + sleep 1 ' test_expect_success 'peer ids' ' - PEERID_0=$(iptb get id 0) && - PEERID_1=$(iptb get id 1) && - PEERID_2=$(iptb get id 2) + PEERID_0=$(iptb get id 0) && + PEERID_1=$(iptb get id 1) && + PEERID_2=$(iptb get id 2) ' test_expect_success 'connect A <-Relay-> B' ' - ipfsi 0 swarm connect /p2p-circuit/ipfs/$PEERID_2 > peers_out + ipfsi 0 swarm connect /p2p-circuit/ipfs/$PEERID_2 > peers_out ' test_expect_success 'output looks good' ' - echo "connect $PEERID_2 success" > peers_exp && - test_cmp peers_exp peers_out + echo "connect $PEERID_2 success" > peers_exp && + test_cmp peers_exp peers_out ' test_expect_success 'peers for A look good' ' - ipfsi 0 swarm peers | grep p2p-circuit > peers_out && - echo "/ipfs/$PEERID_1/p2p-circuit/ipfs/$PEERID_2" > peers_exp && - test_cmp peers_exp peers_out + ipfsi 0 swarm peers | grep p2p-circuit > peers_out && + echo "/ipfs/$PEERID_1/p2p-circuit/ipfs/$PEERID_2" > peers_exp && + test_cmp peers_exp peers_out ' test_expect_success 'peers for B look good' ' - ipfsi 2 swarm peers | grep p2p-circuit > peers_out && - echo "/ipfs/$PEERID_1/p2p-circuit/ipfs/$PEERID_0" > peers_exp && - test_cmp peers_exp peers_out + ipfsi 2 swarm peers | grep p2p-circuit > peers_out && + echo "/ipfs/$PEERID_1/p2p-circuit/ipfs/$PEERID_0" > peers_exp && + test_cmp peers_exp peers_out ' test_expect_success 'add an object in A' ' - echo "hello relay" | ipfsi 0 add > peers_out + echo "hello relay" | ipfsi 0 add > peers_out ' test_expect_success 'object ID' ' - OBJID=$(cut -f3 -d " " peers_out) + OBJID=$(cut -f3 -d " " peers_out) ' test_expect_success 'cat the object in B' ' - ipfsi 2 cat $OBJID > peers_out + ipfsi 2 cat $OBJID > peers_out ' test_expect_success 'output looks good' ' - echo "hello relay" > peers_exp && - test_cmp peers_exp peers_out + echo "hello relay" > peers_exp && + test_cmp peers_exp peers_out ' test_expect_success 'stop iptb' ' - iptb stop + iptb stop ' test_done diff --git a/test/sharness/t0200-unixfs-ls.sh b/test/sharness/t0200-unixfs-ls.sh index 691762d8191..5b617ce894f 100755 --- a/test/sharness/t0200-unixfs-ls.sh +++ b/test/sharness/t0200-unixfs-ls.sh @@ -12,119 +12,119 @@ test_init_ipfs test_ls_cmd() { - test_expect_success "'ipfs add -r testData' succeeds" ' - mkdir -p testData testData/d1 testData/d2 && - echo "test" >testData/f1 && - echo "data" >testData/f2 && - echo "hello" >testData/d1/a && - random 128 42 >testData/d1/128 && - echo "world" >testData/d2/a && - random 1024 42 >testData/d2/1024 && - ipfs add -r testData >actual_add - ' - - test_expect_success "'ipfs add' output looks good" ' - cat <<-\EOF >expected_add && - added QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe testData/d1/128 - added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN testData/d1/a - added QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd testData/d2/1024 - added QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL testData/d2/a - added QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH testData/f1 - added QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M testData/f2 - added QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss testData/d1 - added QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy testData/d2 - added QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj testData - EOF - test_cmp expected_add actual_add - ' - - test_expect_success "'ipfs file ls ' succeeds" ' - ipfs file ls QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy >actual_ls_one_directory - ' - - test_expect_success "'ipfs file ls ' output looks good" ' - cat <<-\EOF >expected_ls_one_directory && - 1024 - a - EOF - test_cmp expected_ls_one_directory actual_ls_one_directory - ' - - test_expect_success "'ipfs file ls ' succeeds" ' - ipfs file ls QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls_three_directories - ' - - test_expect_success "'ipfs file ls ' output looks good" ' - cat <<-\EOF >expected_ls_three_directories && - QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy: - 1024 - a - - QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss: - 128 - a - - QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj: - d1 - d2 - f1 - f2 - EOF - test_cmp expected_ls_three_directories actual_ls_three_directories - ' - - test_expect_success "'ipfs file ls ' succeeds" ' - ipfs file ls /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe >actual_ls_file - ' - - test_expect_success "'ipfs file ls ' output looks good" ' - cat <<-\EOF >expected_ls_file && - /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 - QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe - EOF - test_cmp expected_ls_file actual_ls_file - ' - - test_expect_success "'ipfs file ls ' succeeds" ' - ipfs file ls /ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1 /ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 /ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd >actual_ls_duplicates_file - ' - - test_expect_success "'ipfs file ls ' output looks good" ' - cat <<-\EOF >expected_ls_duplicates_file && - /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 - /ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd - - /ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss: - /ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1: - 128 - a - EOF - test_cmp expected_ls_duplicates_file actual_ls_duplicates_file - ' - - test_expect_success "'ipfs --encoding=json file ls ' succeeds" ' - ipfs --encoding=json file ls /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 >actual_json_ls_file - ' - - test_expect_success "'ipfs --encoding=json file ls ' output looks good" ' - cat <<-\EOF >expected_json_ls_file_trailing_newline && - {"Arguments":{"/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd"},"Objects":{"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":{"Hash":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","Size":1024,"Type":"File","Links":null}}} - EOF - printf "%s\n" "$(cat expected_json_ls_file_trailing_newline)" >expected_json_ls_file && - test_cmp expected_json_ls_file actual_json_ls_file - ' - - test_expect_success "'ipfs --encoding=json file ls ' succeeds" ' - ipfs --encoding=json file ls /ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1 /ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 /ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd >actual_json_ls_duplicates_file - ' - - test_expect_success "'ipfs --encoding=json file ls ' output looks good" ' - cat <<-\EOF >expected_json_ls_duplicates_file_trailing_newline && - {"Arguments":{"/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","/ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss","/ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","/ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss"},"Objects":{"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss":{"Hash":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss","Size":0,"Type":"Directory","Links":[{"Name":"128","Hash":"QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe","Size":128,"Type":"File"},{"Name":"a","Hash":"QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN","Size":6,"Type":"File"}]},"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":{"Hash":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","Size":1024,"Type":"File","Links":null}}} - EOF - printf "%s\n" "$(cat expected_json_ls_duplicates_file_trailing_newline)" >expected_json_ls_duplicates_file && - test_cmp expected_json_ls_duplicates_file actual_json_ls_duplicates_file - ' + test_expect_success "'ipfs add -r testData' succeeds" ' + mkdir -p testData testData/d1 testData/d2 && + echo "test" >testData/f1 && + echo "data" >testData/f2 && + echo "hello" >testData/d1/a && + random 128 42 >testData/d1/128 && + echo "world" >testData/d2/a && + random 1024 42 >testData/d2/1024 && + ipfs add -r testData >actual_add + ' + + test_expect_success "'ipfs add' output looks good" ' + cat <<-\EOF >expected_add && +added QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe testData/d1/128 +added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN testData/d1/a +added QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd testData/d2/1024 +added QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL testData/d2/a +added QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH testData/f1 +added QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M testData/f2 +added QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss testData/d1 +added QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy testData/d2 +added QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj testData +EOF + test_cmp expected_add actual_add + ' + + test_expect_success "'ipfs file ls ' succeeds" ' + ipfs file ls QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy >actual_ls_one_directory + ' + + test_expect_success "'ipfs file ls ' output looks good" ' + cat <<-\EOF >expected_ls_one_directory && +1024 +a +EOF + test_cmp expected_ls_one_directory actual_ls_one_directory + ' + + test_expect_success "'ipfs file ls ' succeeds" ' + ipfs file ls QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls_three_directories + ' + + test_expect_success "'ipfs file ls ' output looks good" ' + cat <<-\EOF >expected_ls_three_directories && +QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy: +1024 +a + +QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss: +128 +a + +QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj: +d1 +d2 +f1 +f2 +EOF + test_cmp expected_ls_three_directories actual_ls_three_directories + ' + + test_expect_success "'ipfs file ls ' succeeds" ' + ipfs file ls /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe >actual_ls_file + ' + + test_expect_success "'ipfs file ls ' output looks good" ' + cat <<-\EOF >expected_ls_file && +/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 +QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe +EOF + test_cmp expected_ls_file actual_ls_file + ' + + test_expect_success "'ipfs file ls ' succeeds" ' + ipfs file ls /ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1 /ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 /ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd >actual_ls_duplicates_file + ' + + test_expect_success "'ipfs file ls ' output looks good" ' + cat <<-\EOF >expected_ls_duplicates_file && +/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 +/ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd + +/ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss: +/ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1: +128 +a +EOF + test_cmp expected_ls_duplicates_file actual_ls_duplicates_file + ' + + test_expect_success "'ipfs --encoding=json file ls ' succeeds" ' + ipfs --encoding=json file ls /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 >actual_json_ls_file + ' + + test_expect_success "'ipfs --encoding=json file ls ' output looks good" ' + cat <<-\EOF >expected_json_ls_file_trailing_newline && +{"Arguments":{"/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd"},"Objects":{"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":{"Hash":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","Size":1024,"Type":"File","Links":null}}} +EOF + printf "%s\n" "$(cat expected_json_ls_file_trailing_newline)" >expected_json_ls_file && + test_cmp expected_json_ls_file actual_json_ls_file + ' + + test_expect_success "'ipfs --encoding=json file ls ' succeeds" ' + ipfs --encoding=json file ls /ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1 /ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 /ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd >actual_json_ls_duplicates_file + ' + + test_expect_success "'ipfs --encoding=json file ls ' output looks good" ' + cat <<-\EOF >expected_json_ls_duplicates_file_trailing_newline && +{"Arguments":{"/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","/ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss","/ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","/ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss"},"Objects":{"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss":{"Hash":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss","Size":0,"Type":"Directory","Links":[{"Name":"128","Hash":"QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe","Size":128,"Type":"File"},{"Name":"a","Hash":"QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN","Size":6,"Type":"File"}]},"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":{"Hash":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","Size":1024,"Type":"File","Links":null}}} +EOF + printf "%s\n" "$(cat expected_json_ls_duplicates_file_trailing_newline)" >expected_json_ls_duplicates_file && + test_cmp expected_json_ls_duplicates_file actual_json_ls_duplicates_file + ' } diff --git a/test/sharness/t0210-tar.sh b/test/sharness/t0210-tar.sh index 48e3c9dd857..40e10329bf3 100755 --- a/test/sharness/t0210-tar.sh +++ b/test/sharness/t0210-tar.sh @@ -11,39 +11,39 @@ test_description="Test tar commands" test_init_ipfs test_expect_success "create some random files" ' - mkdir foo && - random 10000 > foo/a && - random 12345 > foo/b && - mkdir foo/bar && - random 5432 > foo/bar/baz && - ln -s ../a foo/bar/link && - echo "exit" > foo/script && - chmod +x foo/script + mkdir foo && + random 10000 > foo/a && + random 12345 > foo/b && + mkdir foo/bar && + random 5432 > foo/bar/baz && + ln -s ../a foo/bar/link && + echo "exit" > foo/script && + chmod +x foo/script ' test_expect_success "tar those random files up" ' - tar cf files.tar foo/ + tar cf files.tar foo/ ' test_expect_success "'ipfs tar add' succeeds" ' - TAR_HASH=$(ipfs tar add files.tar) + TAR_HASH=$(ipfs tar add files.tar) ' test_expect_success "'ipfs tar cat' succeeds" ' - mkdir output && - ipfs tar cat $TAR_HASH > output/out.tar + mkdir output && + ipfs tar cat $TAR_HASH > output/out.tar ' test_expect_success "can extract tar" ' - tar xf output/out.tar -C output/ + tar xf output/out.tar -C output/ ' test_expect_success "files look right" ' - diff foo/a output/foo/a && - diff foo/b output/foo/b && - diff foo/bar/baz output/foo/bar/baz && - [ -L output/foo/bar/link ] && - [ -x foo/script ] + diff foo/a output/foo/a && + diff foo/b output/foo/b && + diff foo/bar/baz output/foo/bar/baz && + [ -L output/foo/bar/link ] && + [ -x foo/script ] ' test_done diff --git a/test/sharness/t0220-bitswap.sh b/test/sharness/t0220-bitswap.sh index c1b0616eba5..38d9eb00f9b 100755 --- a/test/sharness/t0220-bitswap.sh +++ b/test/sharness/t0220-bitswap.sh @@ -12,69 +12,69 @@ test_init_ipfs test_launch_ipfs_daemon test_expect_success "'ipfs bitswap stat' succeeds" ' - ipfs bitswap stat >stat_out + ipfs bitswap stat >stat_out ' test_expect_success "'ipfs bitswap stat' output looks good" ' - cat >expected <expected && bitswap status - provides buffer: 0 / 256 - blocks received: 0 - blocks sent: 0 - data received: 0 - data sent: 0 - dup blocks received: 0 - dup data received: 0 B - wantlist [0 keys] - partners [0] + provides buffer: 0 / 256 + blocks received: 0 + blocks sent: 0 + data received: 0 + data sent: 0 + dup blocks received: 0 + dup data received: 0 B + wantlist [0 keys] + partners [0] EOF - test_cmp expected stat_out + test_cmp expected stat_out ' test_expect_success "ipfs peer id looks good" ' - PEERID=$(ipfs config Identity.PeerID) && - test_check_peerid "$PEERID" + PEERID=$(ipfs config Identity.PeerID) && + test_check_peerid "$PEERID" ' test_expect_success "'ipfs bitswap wantlist -p' works" ' - ipfs bitswap wantlist -p "$PEERID" >wantlist_p_out + ipfs bitswap wantlist -p "$PEERID" >wantlist_p_out ' test_expect_success "'ipfs bitswap wantlist -p' output looks good" ' - test_must_be_empty wantlist_p_out + test_must_be_empty wantlist_p_out ' test_expect_success "hash was removed from wantlist" ' - ipfs bitswap wantlist > wantlist_out && - test_must_be_empty wantlist_out + ipfs bitswap wantlist > wantlist_out && + test_must_be_empty wantlist_out ' test_expect_success "'ipfs bitswap stat' succeeds" ' - ipfs bitswap stat >stat_out + ipfs bitswap stat >stat_out ' test_expect_success "'ipfs bitswap stat' output looks good" ' - cat >expected <expected && bitswap status - provides buffer: 0 / 256 - blocks received: 0 - blocks sent: 0 - data received: 0 - data sent: 0 - dup blocks received: 0 - dup data received: 0 B - wantlist [0 keys] - partners [0] + provides buffer: 0 / 256 + blocks received: 0 + blocks sent: 0 + data received: 0 + data sent: 0 + dup blocks received: 0 + dup data received: 0 B + wantlist [0 keys] + partners [0] EOF - test_cmp expected stat_out + test_cmp expected stat_out ' test_expect_success "'ipfs bitswap wantlist -p' works" ' - ipfs bitswap wantlist -p "$PEERID" >wantlist_p_out + ipfs bitswap wantlist -p "$PEERID" >wantlist_p_out ' test_expect_success "'ipfs bitswap wantlist -p' output looks good" ' - test_cmp wantlist_out wantlist_p_out + test_cmp wantlist_out wantlist_p_out ' test_kill_ipfs_daemon diff --git a/test/sharness/t0230-channel-streaming-http-content-type.sh b/test/sharness/t0230-channel-streaming-http-content-type.sh index 7f32143f1a6..f956dc138d0 100755 --- a/test/sharness/t0230-channel-streaming-http-content-type.sh +++ b/test/sharness/t0230-channel-streaming-http-content-type.sh @@ -12,55 +12,55 @@ test_init_ipfs test_ls_cmd() { - test_expect_success "Text encoded channel-streaming command succeeds" ' - mkdir -p testdir && - echo "hello test" >testdir/test.txt && - ipfs add -r testdir && - curl -i "http://$API_ADDR/api/v0/refs?arg=QmTcJAn3JP8ZMAKS6WS75q8sbTyojWKbxcUHgLYGWur4Ym&stream-channels=true&encoding=text" >actual_output - ' + test_expect_success "Text encoded channel-streaming command succeeds" ' + mkdir -p testdir && + echo "hello test" >testdir/test.txt && + ipfs add -r testdir && + curl -i "http://$API_ADDR/api/v0/refs?arg=QmTcJAn3JP8ZMAKS6WS75q8sbTyojWKbxcUHgLYGWur4Ym&stream-channels=true&encoding=text" >actual_output + ' - test_expect_success "Text encoded channel-streaming command output looks good" ' - printf "HTTP/1.1 200 OK\r\n" >expected_output && - printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output && - printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output && - printf "Content-Type: text/plain\r\n" >>expected_output && - printf "Server: go-ipfs/%s\r\n" $(ipfs version -n) >>expected_output && - printf "Trailer: X-Stream-Error\r\n" >>expected_output && - printf "Vary: Origin\r\n" >>expected_output && - printf "X-Chunked-Output: 1\r\n" >>expected_output && - printf "Transfer-Encoding: chunked\r\n" >>expected_output && - printf "\r\n" >>expected_output && - echo QmRmPLc1FsPAn8F8F9DQDEYADNX5ER2sgqiokEvqnYknVW >>expected_output && - cat actual_output | grep -vE Date > cleaned_output && - test_cmp expected_output cleaned_output - ' + test_expect_success "Text encoded channel-streaming command output looks good" ' + printf "HTTP/1.1 200 OK\r\n" >expected_output && + printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output && + printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output && + printf "Content-Type: text/plain\r\n" >>expected_output && + printf "Server: go-ipfs/%s\r\n" $(ipfs version -n) >>expected_output && + printf "Trailer: X-Stream-Error\r\n" >>expected_output && + printf "Vary: Origin\r\n" >>expected_output && + printf "X-Chunked-Output: 1\r\n" >>expected_output && + printf "Transfer-Encoding: chunked\r\n" >>expected_output && + printf "\r\n" >>expected_output && + echo QmRmPLc1FsPAn8F8F9DQDEYADNX5ER2sgqiokEvqnYknVW >>expected_output && + cat actual_output | grep -vE Date > cleaned_output && + test_cmp expected_output cleaned_output + ' - test_expect_success "JSON encoded channel-streaming command succeeds" ' - mkdir -p testdir && - echo "hello test" >testdir/test.txt && - ipfs add -r testdir && - curl -i "http://$API_ADDR/api/v0/refs?arg=QmTcJAn3JP8ZMAKS6WS75q8sbTyojWKbxcUHgLYGWur4Ym&stream-channels=true&encoding=json" >actual_output - ' + test_expect_success "JSON encoded channel-streaming command succeeds" ' + mkdir -p testdir && + echo "hello test" >testdir/test.txt && + ipfs add -r testdir && + curl -i "http://$API_ADDR/api/v0/refs?arg=QmTcJAn3JP8ZMAKS6WS75q8sbTyojWKbxcUHgLYGWur4Ym&stream-channels=true&encoding=json" >actual_output + ' - test_expect_success "JSON encoded channel-streaming command output looks good" ' - printf "HTTP/1.1 200 OK\r\n" >expected_output && - printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output && - printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output && - printf "Content-Type: application/json\r\n" >>expected_output && - printf "Server: go-ipfs/%s\r\n" $(ipfs version -n) >>expected_output && - printf "Trailer: X-Stream-Error\r\n" >>expected_output && - printf "Vary: Origin\r\n" >>expected_output && - printf "X-Chunked-Output: 1\r\n" >>expected_output && - printf "Transfer-Encoding: chunked\r\n" >>expected_output && - printf "\r\n" >>expected_output && - cat <<-\EOF >>expected_output && - {"Ref":"QmRmPLc1FsPAn8F8F9DQDEYADNX5ER2sgqiokEvqnYknVW","Err":""} - EOF - printf "\n" >> expected_output && - perl -pi -e '"'"'chomp if eof'"'"' expected_output && - cat actual_output | grep -vE Date > cleaned_output && - test_cmp expected_output cleaned_output - ' + test_expect_success "JSON encoded channel-streaming command output looks good" ' + printf "HTTP/1.1 200 OK\r\n" >expected_output && + printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output && + printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output && + printf "Content-Type: application/json\r\n" >>expected_output && + printf "Server: go-ipfs/%s\r\n" $(ipfs version -n) >>expected_output && + printf "Trailer: X-Stream-Error\r\n" >>expected_output && + printf "Vary: Origin\r\n" >>expected_output && + printf "X-Chunked-Output: 1\r\n" >>expected_output && + printf "Transfer-Encoding: chunked\r\n" >>expected_output && + printf "\r\n" >>expected_output && + cat <<-\EOF >>expected_output && +{"Ref":"QmRmPLc1FsPAn8F8F9DQDEYADNX5ER2sgqiokEvqnYknVW","Err":""} +EOF + printf "\n" >> expected_output && + perl -pi -e '"'"'chomp if eof'"'"' expected_output && + cat actual_output | grep -vE Date > cleaned_output && + test_cmp expected_output cleaned_output + ' } # should work online (only) diff --git a/test/sharness/t0231-channel-streaming.sh b/test/sharness/t0231-channel-streaming.sh index eca88e95800..c759a7b2744 100755 --- a/test/sharness/t0231-channel-streaming.sh +++ b/test/sharness/t0231-channel-streaming.sh @@ -11,23 +11,23 @@ test_description="Test output of streaming json commands" test_init_ipfs get_api_port() { - cat "$IPFS_PATH/api" | awk -F/ '{ print $5 }' + cat "$IPFS_PATH/api" | awk -F/ '{ print $5 }' } test_ls_cmd() { - test_expect_success "make a file with multiple refs" ' - HASH=$(random 1000000 | ipfs add -q) - ' - - test_expect_success "can get refs through curl" ' - PORT=$(get_api_port) && - curl http://localhost:$PORT/api/v0/refs/$HASH > output - ' - - # make sure newlines are printed between each object - test_expect_success "output looks good" ' - test_expect_code 1 grep "}{" output > /dev/null - ' + test_expect_success "make a file with multiple refs" ' + HASH=$(random 1000000 | ipfs add -q) + ' + + test_expect_success "can get refs through curl" ' + PORT=$(get_api_port) && + curl http://localhost:$PORT/api/v0/refs/$HASH > output + ' + + # make sure newlines are printed between each object + test_expect_success "output looks good" ' + test_expect_code 1 grep "}{" output > /dev/null + ' } # should work online (only) diff --git a/test/sharness/t0235-cli-request.sh b/test/sharness/t0235-cli-request.sh index cb7e7481edf..98e052d5395 100755 --- a/test/sharness/t0235-cli-request.sh +++ b/test/sharness/t0235-cli-request.sh @@ -11,22 +11,22 @@ test_description="test http requests made by cli" test_init_ipfs test_expect_success "can make http request against nc server" ' - nc -ld 5005 > nc_out & - NCPID=$! - go-sleep 0.5s && kill "$NCPID" & - ipfs cat /ipfs/Qmabcdef --api /ip4/127.0.0.1/tcp/5005 || true + nc -ld 5005 > nc_out & + NCPID=$! + go-sleep 0.5s && kill "$NCPID" & + ipfs cat /ipfs/Qmabcdef --api /ip4/127.0.0.1/tcp/5005 || true ' test_expect_success "output does not contain multipart info" ' - test_expect_code 1 grep multipart nc_out + test_expect_code 1 grep multipart nc_out ' test_expect_success "request looks good" ' - grep "POST /api/v0/cat" nc_out + grep "POST /api/v0/cat" nc_out ' test_expect_success "api flag does not appear in request" ' - test_expect_code 1 grep "api=/ip4" nc_out + test_expect_code 1 grep "api=/ip4" nc_out ' test_done diff --git a/test/sharness/t0240-republisher.sh b/test/sharness/t0240-republisher.sh index 0d0f3661f23..8e1bd7593b0 100755 --- a/test/sharness/t0240-republisher.sh +++ b/test/sharness/t0240-republisher.sh @@ -11,64 +11,64 @@ test_description="Test ipfs repo operations" export DEBUG=true setup_iptb() { - num_nodes="$1" - bound=$(expr "$num_nodes" - 1) - - test_expect_success "iptb init" ' - iptb init -n $num_nodes --bootstrap none --port 0 - ' - - for i in $(test_seq 0 "$bound") - do - test_expect_success "set configs up for node $i" ' - ipfsi "$i" config Ipns.RepublishPeriod 20s && - ipfsi "$i" config --json Ipns.ResolveCacheSize 0 - ' - done - - startup_cluster "$num_nodes" + num_nodes="$1" + bound=$(expr "$num_nodes" - 1) + + test_expect_success "iptb init" ' + iptb init -n $num_nodes --bootstrap none --port 0 + ' + + for i in $(test_seq 0 "$bound") + do + test_expect_success "set configs up for node $i" ' + ipfsi "$i" config Ipns.RepublishPeriod 20s && + ipfsi "$i" config --json Ipns.ResolveCacheSize 0 + ' + done + + startup_cluster "$num_nodes" } teardown_iptb() { - test_expect_success "shut down nodes" ' - iptb kill - ' + test_expect_success "shut down nodes" ' + iptb kill + ' } verify_can_resolve() { - num_nodes="$1" - bound=$(expr "$num_nodes" - 1) - name="$2" - expected="$3" - msg="$4" - - for node in $(test_seq 0 "$bound") - do - test_expect_success "$msg: node $node can resolve entry" ' - ipfsi "$node" name resolve "$name" > resolve - ' - - test_expect_success "$msg: output for node $node looks right" ' - printf "/ipfs/$expected\n" > expected && - test_cmp expected resolve - ' - done + num_nodes="$1" + bound=$(expr "$num_nodes" - 1) + name="$2" + expected="$3" + msg="$4" + + for node in $(test_seq 0 "$bound") + do + test_expect_success "$msg: node $node can resolve entry" ' + ipfsi "$node" name resolve "$name" > resolve + ' + + test_expect_success "$msg: output for node $node looks right" ' + printf "/ipfs/$expected\n" > expected && + test_cmp expected resolve + ' + done } verify_cannot_resolve() { - num_nodes="$1" - bound=$(expr "$num_nodes" - 1) - name="$2" - msg="$3" - - for node in $(test_seq 0 "$bound") - do - test_expect_success "$msg: resolution fails on node $node" ' - # TODO: this should work without the timeout option - # but it currently hangs for some reason every so often - test_expect_code 1 ipfsi "$node" name resolve --timeout=300ms "$name" - ' - done + num_nodes="$1" + bound=$(expr "$num_nodes" - 1) + name="$2" + msg="$3" + + for node in $(test_seq 0 "$bound") + do + test_expect_success "$msg: resolution fails on node $node" ' + # TODO: this should work without the timeout option + # but it currently hangs for some reason every so often + test_expect_code 1 ipfsi "$node" name resolve --timeout=300ms "$name" + ' + done } num_test_nodes=4 @@ -76,12 +76,12 @@ num_test_nodes=4 setup_iptb "$num_test_nodes" test_expect_success "publish succeeds" ' - HASH=$(echo "foobar" | ipfsi 1 add -q) && - ipfsi 1 name publish -t 5s $HASH + HASH=$(echo "foobar" | ipfsi 1 add -q) && + ipfsi 1 name publish -t 5s $HASH ' test_expect_success "get id succeeds" ' - id=$(ipfsi 1 id -f "") + id=$(ipfsi 1 id -f "") ' verify_can_resolve "$num_test_nodes" "$id" "$HASH" "just after publishing" @@ -101,8 +101,8 @@ KEY2=`ipfsi 1 key gen beepboop --type ed25519` ' test_expect_success "publish with new key succeeds" ' - HASH=$(echo "barfoo" | ipfsi 1 add -q) && - ipfsi 1 name publish -t 5s -k "$KEY2" $HASH + HASH=$(echo "barfoo" | ipfsi 1 add -q) && + ipfsi 1 name publish -t 5s -k "$KEY2" $HASH ' verify_can_resolve "$num_test_nodes" "$KEY2" "$HASH" "new key just after publishing" diff --git a/test/sharness/t0250-files-api.sh b/test/sharness/t0250-files-api.sh index 01b587c0cf6..54d8c9e7c31 100755 --- a/test/sharness/t0250-files-api.sh +++ b/test/sharness/t0250-files-api.sh @@ -11,541 +11,541 @@ test_description="test the unix files api" test_init_ipfs create_files() { - FILE1=$(echo foo | ipfs add "$@" -q) && - FILE2=$(echo bar | ipfs add "$@" -q) && - FILE3=$(echo baz | ipfs add "$@" -q) && - mkdir -p stuff_test && - echo cats > stuff_test/a && - echo dogs > stuff_test/b && - echo giraffes > stuff_test/c && - DIR1=$(ipfs add -r "$@" -q stuff_test | tail -n1) + FILE1=$(echo foo | ipfs add "$@" -q) && + FILE2=$(echo bar | ipfs add "$@" -q) && + FILE3=$(echo baz | ipfs add "$@" -q) && + mkdir -p stuff_test && + echo cats > stuff_test/a && + echo dogs > stuff_test/b && + echo giraffes > stuff_test/c && + DIR1=$(ipfs add -r "$@" -q stuff_test | tail -n1) } verify_path_exists() { - # simply running ls on a file should be a good 'check' - ipfs files ls $1 + # simply running ls on a file should be a good 'check' + ipfs files ls $1 } verify_dir_contents() { - dir=$1 - shift - rm -f expected - touch expected - for e in $@ - do - echo $e >> expected - done - - test_expect_success "can list dir" ' - ipfs files ls $dir > output - ' - - test_expect_success "dir entries look good" ' - test_sort_cmp output expected - ' + dir=$1 + shift + rm -f expected + touch expected + for e in $@ + do + echo $e >> expected + done + + test_expect_success "can list dir" ' + ipfs files ls $dir > output + ' + + test_expect_success "dir entries look good" ' + test_sort_cmp output expected + ' } test_sharding() { - test_expect_success "make a directory" ' - ipfs files mkdir /foo - ' - - test_expect_success "can make 100 files in a directory" ' - printf "" > list_exp_raw - for i in `seq 100` - do - echo $i | ipfs files write --create /foo/file$i - echo file$i >> list_exp_raw - done - ' - - test_expect_success "listing works" ' - ipfs files ls /foo |sort > list_out && - sort list_exp_raw > list_exp && - test_cmp list_exp list_out - ' - - test_expect_success "can read a file from sharded directory" ' - ipfs files read /foo/file65 > file_out && - echo "65" > file_exp && - test_cmp file_out file_exp - ' - - test_expect_success "can pin a file from sharded directory" ' - ipfs files stat --hash /foo/file42 > pin_file_hash && - ipfs pin add < pin_file_hash > pin_hash - ' - - test_expect_success "can unpin a file from sharded directory" ' - read -r _ HASH _ < pin_hash && - ipfs pin rm $HASH - ' - - test_expect_success "output object was really sharded" ' - ipfs files stat --hash /foo > expected_foo_hash && - echo QmPkwLJTYZRGPJ8Lazr9qPdrLmswPtUjaDbEpmR9jEh1se > actual_foo_hash && - test_cmp expected_foo_hash actual_foo_hash - ' + test_expect_success "make a directory" ' + ipfs files mkdir /foo + ' + + test_expect_success "can make 100 files in a directory" ' + printf "" > list_exp_raw + for i in `seq 100` + do + echo $i | ipfs files write --create /foo/file$i + echo file$i >> list_exp_raw + done + ' + + test_expect_success "listing works" ' + ipfs files ls /foo |sort > list_out && + sort list_exp_raw > list_exp && + test_cmp list_exp list_out + ' + + test_expect_success "can read a file from sharded directory" ' + ipfs files read /foo/file65 > file_out && + echo "65" > file_exp && + test_cmp file_out file_exp + ' + + test_expect_success "can pin a file from sharded directory" ' + ipfs files stat --hash /foo/file42 > pin_file_hash && + ipfs pin add < pin_file_hash > pin_hash + ' + + test_expect_success "can unpin a file from sharded directory" ' + read -r _ HASH _ < pin_hash && + ipfs pin rm $HASH + ' + + test_expect_success "output object was really sharded" ' + ipfs files stat --hash /foo > expected_foo_hash && + echo QmPkwLJTYZRGPJ8Lazr9qPdrLmswPtUjaDbEpmR9jEh1se > actual_foo_hash && + test_cmp expected_foo_hash actual_foo_hash + ' } test_files_api() { - ROOT_HASH=$1 - - test_expect_success "can mkdir in root" ' - ipfs files mkdir /cats - ' - - test_expect_success "'files ls' lists root by default" ' - ipfs files ls >actual && - echo "cats" >expected && - test_cmp expected actual - ' - - test_expect_success "directory was created" ' - verify_path_exists /cats - ' - - test_expect_success "directory is empty" ' - verify_dir_contents /cats - ' - # we do verification of stat formatting now as we depend on it - - test_expect_success "stat works" ' - ipfs files stat / >stat - ' - - test_expect_success "hash is first line of stat" ' - ipfs ls $(head -1 stat) | grep "cats" - ' - - test_expect_success "stat --hash gives only hash" ' - ipfs files stat --hash / >actual && - head -n1 stat >expected && - test_cmp expected actual - ' - - test_expect_success "stat with multiple format options should fail" ' - test_must_fail ipfs files stat --hash --size / - ' - - test_expect_success "compare hash option with format" ' - ipfs files stat --hash / >expected && - ipfs files stat --format='"'"''"'"' / >actual && - test_cmp expected actual - ' - test_expect_success "compare size option with format" ' - ipfs files stat --size / >expected && - ipfs files stat --format='"'"''"'"' / >actual && - test_cmp expected actual - ' - - test_expect_success "check root hash" ' - ipfs files stat --hash / > roothash - ' - - test_expect_success "cannot mkdir /" ' - test_expect_code 1 ipfs files mkdir / - ' - - test_expect_success "check root hash was not changed" ' - ipfs files stat --hash / > roothashafter && - test_cmp roothash roothashafter - ' - - test_expect_success "can put files into directory" ' - ipfs files cp /ipfs/$FILE1 /cats/file1 - ' - - test_expect_success "file shows up in directory" ' - verify_dir_contents /cats file1 - ' - - test_expect_success "file has correct hash and size in directory" ' - echo "file1 $FILE1 4" > ls_l_expected && - ipfs files ls -l /cats > ls_l_actual && - test_cmp ls_l_expected ls_l_actual - ' - - test_expect_success "can read file" ' - ipfs files read /cats/file1 > file1out - ' - - test_expect_success "output looks good" ' - echo foo > expected && - test_cmp expected file1out - ' - - test_expect_success "can put another file into root" ' - ipfs files cp /ipfs/$FILE2 /file2 - ' - - test_expect_success "file shows up in root" ' - verify_dir_contents / file2 cats - ' - - test_expect_success "can read file" ' - ipfs files read /file2 > file2out - ' - - test_expect_success "output looks good" ' - echo bar > expected && - test_cmp expected file2out - ' - - test_expect_success "can make deep directory" ' - ipfs files mkdir -p /cats/this/is/a/dir - ' - - test_expect_success "directory was created correctly" ' - verify_path_exists /cats/this/is/a/dir && - verify_dir_contents /cats this file1 && - verify_dir_contents /cats/this is && - verify_dir_contents /cats/this/is a && - verify_dir_contents /cats/this/is/a dir && - verify_dir_contents /cats/this/is/a/dir - ' - - test_expect_success "can copy file into new dir" ' - ipfs files cp /ipfs/$FILE3 /cats/this/is/a/dir/file3 - ' - - test_expect_success "can read file" ' - ipfs files read /cats/this/is/a/dir/file3 > output - ' - - test_expect_success "output looks good" ' - echo baz > expected && - test_cmp expected output - ' - - test_expect_success "file shows up in dir" ' - verify_dir_contents /cats/this/is/a/dir file3 - ' - - test_expect_success "can remove file" ' - ipfs files rm /cats/this/is/a/dir/file3 - ' - - test_expect_success "file no longer appears" ' - verify_dir_contents /cats/this/is/a/dir - ' - - test_expect_success "can remove dir" ' - ipfs files rm -r /cats/this/is/a/dir - ' - - test_expect_success "dir no longer appears" ' - verify_dir_contents /cats/this/is/a - ' - - test_expect_success "can remove file from root" ' - ipfs files rm /file2 - ' - - test_expect_success "file no longer appears" ' - verify_dir_contents / cats - ' - - test_expect_success "check root hash" ' - ipfs files stat --hash / > roothash - ' - - test_expect_success "cannot remove root" ' - test_expect_code 1 ipfs files rm -r / - ' - - test_expect_success "check root hash was not changed" ' - ipfs files stat --hash / > roothashafter && - test_cmp roothash roothashafter - ' - - # test read options - - test_expect_success "read from offset works" ' - ipfs files read -o 1 /cats/file1 > output - ' - - test_expect_success "output looks good" ' - echo oo > expected && - test_cmp expected output - ' - - test_expect_success "read with size works" ' - ipfs files read -n 2 /cats/file1 > output - ' - - test_expect_success "output looks good" ' - printf fo > expected && - test_cmp expected output - ' - - test_expect_success "cannot read from negative offset" ' - test_expect_code 1 ipfs files read --offset -3 /cats/file1 - ' - - test_expect_success "read from offset 0 works" ' - ipfs files read --offset 0 /cats/file1 > output - ' - - test_expect_success "output looks good" ' - echo foo > expected && - test_cmp expected output - ' - - test_expect_success "read last byte works" ' - ipfs files read --offset 2 /cats/file1 > output - ' - - test_expect_success "output looks good" ' - echo o > expected && - test_cmp expected output - ' - - test_expect_success "offset past end of file fails" ' - test_expect_code 1 ipfs files read --offset 5 /cats/file1 - ' - - test_expect_success "cannot read negative count bytes" ' - test_expect_code 1 ipfs read --count -1 /cats/file1 - ' - - test_expect_success "reading zero bytes prints nothing" ' - ipfs files read --count 0 /cats/file1 > output - ' - - test_expect_success "output looks good" ' - printf "" > expected && - test_cmp expected output - ' - - test_expect_success "count > len(file) prints entire file" ' - ipfs files read --count 200 /cats/file1 > output - ' - - test_expect_success "output looks good" ' - echo foo > expected && - test_cmp expected output - ' - - # test write - - test_expect_success "can write file" ' - echo "ipfs rocks" > tmpfile && - cat tmpfile | ipfs files write --create /cats/ipfs - ' - - test_expect_success "file was created" ' - verify_dir_contents /cats ipfs file1 this - ' - - test_expect_success "can read file we just wrote" ' - ipfs files read /cats/ipfs > output - ' - - test_expect_success "can write to offset" ' - echo "is super cool" | ipfs files write -o 5 /cats/ipfs - ' - - test_expect_success "file looks correct" ' - echo "ipfs is super cool" > expected && - ipfs files read /cats/ipfs > output && - test_cmp expected output - ' - - test_expect_success "cant write to negative offset" ' - ipfs files stat --hash /cats/ipfs > filehash && - test_expect_code 1 ipfs files write --offset -1 /cats/ipfs < output - ' - - test_expect_success "verify file was not changed" ' - ipfs files stat --hash /cats/ipfs > afterhash && - test_cmp filehash afterhash - ' - - test_expect_success "write new file for testing" ' - echo foobar | ipfs files write --create /fun - ' - - test_expect_success "write to offset past end works" ' - echo blah | ipfs files write --offset 50 /fun - ' - - test_expect_success "can read file" ' - ipfs files read /fun > sparse_output - ' - - test_expect_success "output looks good" ' - echo foobar > sparse_expected && - echo blah | dd of=sparse_expected bs=50 seek=1 && - test_cmp sparse_expected sparse_output - ' - - test_expect_success "cleanup" ' - ipfs files rm /fun - ' - - test_expect_success "cannot write to directory" ' - ipfs files stat --hash /cats > dirhash && - test_expect_code 1 ipfs files write /cats < output - ' - - test_expect_success "verify dir was not changed" ' - ipfs files stat --hash /cats > afterdirhash && - test_cmp dirhash afterdirhash - ' - - test_expect_success "cannot write to nonexistant path" ' - test_expect_code 1 ipfs files write /cats/bar/ < output - ' - - test_expect_success "no new paths were created" ' - verify_dir_contents /cats file1 ipfs this - ' - - test_expect_success "write 'no-flush' succeeds" ' - echo "testing" | ipfs files write -f=false -e /cats/walrus - ' - - test_expect_success "root hash not bubbled up yet" ' - test -z "$ONLINE" || - (ipfs refs local > refsout && - test_expect_code 1 grep $ROOT_HASH refsout) - ' - - test_expect_success "changes bubbled up to root on inspection" ' - ipfs files stat --hash / > root_hash - ' - - test_expect_success "root hash looks good" ' - export EXP_ROOT_HASH="$ROOT_HASH" && - echo $EXP_ROOT_HASH > root_hash_exp && - test_cmp root_hash_exp root_hash - ' - - test_expect_success "flush root succeeds" ' - ipfs files flush / - ' - - # test mv - test_expect_success "can mv dir" ' - ipfs files mv /cats/this/is /cats/ - ' - - test_expect_success "mv worked" ' - verify_dir_contents /cats file1 ipfs this is walrus && - verify_dir_contents /cats/this - ' - - test_expect_success "cleanup, remove 'cats'" ' - ipfs files rm -r /cats - ' - - test_expect_success "cleanup looks good" ' - verify_dir_contents / - ' - - # test truncating - test_expect_success "create a new file" ' - echo "some content" | ipfs files write --create /cats - ' - - test_expect_success "truncate and write over that file" ' - echo "fish" | ipfs files write --truncate /cats - ' - - test_expect_success "output looks good" ' - ipfs files read /cats > file_out && - echo "fish" > file_exp && - test_cmp file_out file_exp - ' - - test_expect_success "cleanup" ' - ipfs files rm /cats - ' - - # test flush flags - test_expect_success "mkdir --flush works" ' - ipfs files mkdir --flush --parents /flushed/deep - ' - - test_expect_success "mkdir --flush works a second time" ' - ipfs files mkdir --flush --parents /flushed/deep - ' - - test_expect_success "dir looks right" ' - verify_dir_contents / flushed - ' - - test_expect_success "child dir looks right" ' - verify_dir_contents /flushed deep - ' - - test_expect_success "cleanup" ' - ipfs files rm -r /flushed - ' - - test_expect_success "child dir looks right" ' - verify_dir_contents / - ' - - # test for https://github.com/ipfs/go-ipfs/issues/2654 - test_expect_success "create and remove dir" ' - ipfs files mkdir /test_dir && - ipfs files rm -r "/test_dir" - ' - - test_expect_success "create test file" ' - echo "content" | ipfs files write -e "/test_file" - ' - - test_expect_success "copy test file onto test dir" ' - ipfs files cp "/test_file" "/test_dir" - ' - - test_expect_success "test /test_dir" ' - ipfs files stat "/test_dir" | grep -q "^Type: file" - ' - - test_expect_success "clean up /test_dir and /test_file" ' - ipfs files rm -r /test_dir && - ipfs files rm -r /test_file - ' - - test_expect_success "make a directory and a file" ' - ipfs files mkdir /adir && - echo "blah" | ipfs files write --create /foobar - ' - - test_expect_success "copy a file into a directory" ' - ipfs files cp /foobar /adir/ - ' - - test_expect_success "file made it into directory" ' - ipfs files ls /adir | grep foobar - ' - - test_expect_success "clean up" ' - ipfs files rm -r /foobar && - ipfs files rm -r /adir - ' - - test_expect_success "root mfs entry is empty" ' - verify_dir_contents / - ' - - test_expect_success "repo gc" ' - ipfs repo gc - ' + ROOT_HASH=$1 + + test_expect_success "can mkdir in root" ' + ipfs files mkdir /cats + ' + + test_expect_success "'files ls' lists root by default" ' + ipfs files ls >actual && + echo "cats" >expected && + test_cmp expected actual + ' + + test_expect_success "directory was created" ' + verify_path_exists /cats + ' + + test_expect_success "directory is empty" ' + verify_dir_contents /cats + ' + # we do verification of stat formatting now as we depend on it + + test_expect_success "stat works" ' + ipfs files stat / >stat + ' + + test_expect_success "hash is first line of stat" ' + ipfs ls $(head -1 stat) | grep "cats" + ' + + test_expect_success "stat --hash gives only hash" ' + ipfs files stat --hash / >actual && + head -n1 stat >expected && + test_cmp expected actual + ' + + test_expect_success "stat with multiple format options should fail" ' + test_must_fail ipfs files stat --hash --size / + ' + + test_expect_success "compare hash option with format" ' + ipfs files stat --hash / >expected && + ipfs files stat --format='"'"''"'"' / >actual && + test_cmp expected actual + ' + test_expect_success "compare size option with format" ' + ipfs files stat --size / >expected && + ipfs files stat --format='"'"''"'"' / >actual && + test_cmp expected actual + ' + + test_expect_success "check root hash" ' + ipfs files stat --hash / > roothash + ' + + test_expect_success "cannot mkdir /" ' + test_expect_code 1 ipfs files mkdir / + ' + + test_expect_success "check root hash was not changed" ' + ipfs files stat --hash / > roothashafter && + test_cmp roothash roothashafter + ' + + test_expect_success "can put files into directory" ' + ipfs files cp /ipfs/$FILE1 /cats/file1 + ' + + test_expect_success "file shows up in directory" ' + verify_dir_contents /cats file1 + ' + + test_expect_success "file has correct hash and size in directory" ' + echo "file1 $FILE1 4" > ls_l_expected && + ipfs files ls -l /cats > ls_l_actual && + test_cmp ls_l_expected ls_l_actual + ' + + test_expect_success "can read file" ' + ipfs files read /cats/file1 > file1out + ' + + test_expect_success "output looks good" ' + echo foo > expected && + test_cmp expected file1out + ' + + test_expect_success "can put another file into root" ' + ipfs files cp /ipfs/$FILE2 /file2 + ' + + test_expect_success "file shows up in root" ' + verify_dir_contents / file2 cats + ' + + test_expect_success "can read file" ' + ipfs files read /file2 > file2out + ' + + test_expect_success "output looks good" ' + echo bar > expected && + test_cmp expected file2out + ' + + test_expect_success "can make deep directory" ' + ipfs files mkdir -p /cats/this/is/a/dir + ' + + test_expect_success "directory was created correctly" ' + verify_path_exists /cats/this/is/a/dir && + verify_dir_contents /cats this file1 && + verify_dir_contents /cats/this is && + verify_dir_contents /cats/this/is a && + verify_dir_contents /cats/this/is/a dir && + verify_dir_contents /cats/this/is/a/dir + ' + + test_expect_success "can copy file into new dir" ' + ipfs files cp /ipfs/$FILE3 /cats/this/is/a/dir/file3 + ' + + test_expect_success "can read file" ' + ipfs files read /cats/this/is/a/dir/file3 > output + ' + + test_expect_success "output looks good" ' + echo baz > expected && + test_cmp expected output + ' + + test_expect_success "file shows up in dir" ' + verify_dir_contents /cats/this/is/a/dir file3 + ' + + test_expect_success "can remove file" ' + ipfs files rm /cats/this/is/a/dir/file3 + ' + + test_expect_success "file no longer appears" ' + verify_dir_contents /cats/this/is/a/dir + ' + + test_expect_success "can remove dir" ' + ipfs files rm -r /cats/this/is/a/dir + ' + + test_expect_success "dir no longer appears" ' + verify_dir_contents /cats/this/is/a + ' + + test_expect_success "can remove file from root" ' + ipfs files rm /file2 + ' + + test_expect_success "file no longer appears" ' + verify_dir_contents / cats + ' + + test_expect_success "check root hash" ' + ipfs files stat --hash / > roothash + ' + + test_expect_success "cannot remove root" ' + test_expect_code 1 ipfs files rm -r / + ' + + test_expect_success "check root hash was not changed" ' + ipfs files stat --hash / > roothashafter && + test_cmp roothash roothashafter + ' + + # test read options + + test_expect_success "read from offset works" ' + ipfs files read -o 1 /cats/file1 > output + ' + + test_expect_success "output looks good" ' + echo oo > expected && + test_cmp expected output + ' + + test_expect_success "read with size works" ' + ipfs files read -n 2 /cats/file1 > output + ' + + test_expect_success "output looks good" ' + printf fo > expected && + test_cmp expected output + ' + + test_expect_success "cannot read from negative offset" ' + test_expect_code 1 ipfs files read --offset -3 /cats/file1 + ' + + test_expect_success "read from offset 0 works" ' + ipfs files read --offset 0 /cats/file1 > output + ' + + test_expect_success "output looks good" ' + echo foo > expected && + test_cmp expected output + ' + + test_expect_success "read last byte works" ' + ipfs files read --offset 2 /cats/file1 > output + ' + + test_expect_success "output looks good" ' + echo o > expected && + test_cmp expected output + ' + + test_expect_success "offset past end of file fails" ' + test_expect_code 1 ipfs files read --offset 5 /cats/file1 + ' + + test_expect_success "cannot read negative count bytes" ' + test_expect_code 1 ipfs read --count -1 /cats/file1 + ' + + test_expect_success "reading zero bytes prints nothing" ' + ipfs files read --count 0 /cats/file1 > output + ' + + test_expect_success "output looks good" ' + printf "" > expected && + test_cmp expected output + ' + + test_expect_success "count > len(file) prints entire file" ' + ipfs files read --count 200 /cats/file1 > output + ' + + test_expect_success "output looks good" ' + echo foo > expected && + test_cmp expected output + ' + + # test write + + test_expect_success "can write file" ' + echo "ipfs rocks" > tmpfile && + cat tmpfile | ipfs files write --create /cats/ipfs + ' + + test_expect_success "file was created" ' + verify_dir_contents /cats ipfs file1 this + ' + + test_expect_success "can read file we just wrote" ' + ipfs files read /cats/ipfs > output + ' + + test_expect_success "can write to offset" ' + echo "is super cool" | ipfs files write -o 5 /cats/ipfs + ' + + test_expect_success "file looks correct" ' + echo "ipfs is super cool" > expected && + ipfs files read /cats/ipfs > output && + test_cmp expected output + ' + + test_expect_success "cant write to negative offset" ' + ipfs files stat --hash /cats/ipfs > filehash && + test_expect_code 1 ipfs files write --offset -1 /cats/ipfs < output + ' + + test_expect_success "verify file was not changed" ' + ipfs files stat --hash /cats/ipfs > afterhash && + test_cmp filehash afterhash + ' + + test_expect_success "write new file for testing" ' + echo foobar | ipfs files write --create /fun + ' + + test_expect_success "write to offset past end works" ' + echo blah | ipfs files write --offset 50 /fun + ' + + test_expect_success "can read file" ' + ipfs files read /fun > sparse_output + ' + + test_expect_success "output looks good" ' + echo foobar > sparse_expected && + echo blah | dd of=sparse_expected bs=50 seek=1 && + test_cmp sparse_expected sparse_output + ' + + test_expect_success "cleanup" ' + ipfs files rm /fun + ' + + test_expect_success "cannot write to directory" ' + ipfs files stat --hash /cats > dirhash && + test_expect_code 1 ipfs files write /cats < output + ' + + test_expect_success "verify dir was not changed" ' + ipfs files stat --hash /cats > afterdirhash && + test_cmp dirhash afterdirhash + ' + + test_expect_success "cannot write to nonexistant path" ' + test_expect_code 1 ipfs files write /cats/bar/ < output + ' + + test_expect_success "no new paths were created" ' + verify_dir_contents /cats file1 ipfs this + ' + + test_expect_success "write 'no-flush' succeeds" ' + echo "testing" | ipfs files write -f=false -e /cats/walrus + ' + + test_expect_success "root hash not bubbled up yet" ' + test -z "$ONLINE" || + (ipfs refs local > refsout && + test_expect_code 1 grep $ROOT_HASH refsout) + ' + + test_expect_success "changes bubbled up to root on inspection" ' + ipfs files stat --hash / > root_hash + ' + + test_expect_success "root hash looks good" ' + export EXP_ROOT_HASH="$ROOT_HASH" && + echo $EXP_ROOT_HASH > root_hash_exp && + test_cmp root_hash_exp root_hash + ' + + test_expect_success "flush root succeeds" ' + ipfs files flush / + ' + + # test mv + test_expect_success "can mv dir" ' + ipfs files mv /cats/this/is /cats/ + ' + + test_expect_success "mv worked" ' + verify_dir_contents /cats file1 ipfs this is walrus && + verify_dir_contents /cats/this + ' + + test_expect_success "cleanup, remove 'cats'" ' + ipfs files rm -r /cats + ' + + test_expect_success "cleanup looks good" ' + verify_dir_contents / + ' + + # test truncating + test_expect_success "create a new file" ' + echo "some content" | ipfs files write --create /cats + ' + + test_expect_success "truncate and write over that file" ' + echo "fish" | ipfs files write --truncate /cats + ' + + test_expect_success "output looks good" ' + ipfs files read /cats > file_out && + echo "fish" > file_exp && + test_cmp file_out file_exp + ' + + test_expect_success "cleanup" ' + ipfs files rm /cats + ' + + # test flush flags + test_expect_success "mkdir --flush works" ' + ipfs files mkdir --flush --parents /flushed/deep + ' + + test_expect_success "mkdir --flush works a second time" ' + ipfs files mkdir --flush --parents /flushed/deep + ' + + test_expect_success "dir looks right" ' + verify_dir_contents / flushed + ' + + test_expect_success "child dir looks right" ' + verify_dir_contents /flushed deep + ' + + test_expect_success "cleanup" ' + ipfs files rm -r /flushed + ' + + test_expect_success "child dir looks right" ' + verify_dir_contents / + ' + + # test for https://github.com/ipfs/go-ipfs/issues/2654 + test_expect_success "create and remove dir" ' + ipfs files mkdir /test_dir && + ipfs files rm -r "/test_dir" + ' + + test_expect_success "create test file" ' + echo "content" | ipfs files write -e "/test_file" + ' + + test_expect_success "copy test file onto test dir" ' + ipfs files cp "/test_file" "/test_dir" + ' + + test_expect_success "test /test_dir" ' + ipfs files stat "/test_dir" | grep -q "^Type: file" + ' + + test_expect_success "clean up /test_dir and /test_file" ' + ipfs files rm -r /test_dir && + ipfs files rm -r /test_file + ' + + test_expect_success "make a directory and a file" ' + ipfs files mkdir /adir && + echo "blah" | ipfs files write --create /foobar + ' + + test_expect_success "copy a file into a directory" ' + ipfs files cp /foobar /adir/ + ' + + test_expect_success "file made it into directory" ' + ipfs files ls /adir | grep foobar + ' + + test_expect_success "clean up" ' + ipfs files rm -r /foobar && + ipfs files rm -r /adir + ' + + test_expect_success "root mfs entry is empty" ' + verify_dir_contents / + ' + + test_expect_success "repo gc" ' + ipfs repo gc + ' } # test offline and online test_expect_success "can create some files for testing" ' - create_files + create_files ' test_files_api QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt test_expect_success "can create some files for testing with raw-leaves" ' - create_files --raw-leaves + create_files --raw-leaves ' test_files_api QmTpKiKcAj4sbeesN6vrs5w3QeVmd4QmGpxRL81hHut4dZ @@ -553,19 +553,19 @@ test_launch_ipfs_daemon --offline ONLINE=1 # set online flag so tests can easily tell test_expect_success "can create some files for testing" ' - create_files + create_files ' test_files_api QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt test_expect_success "can create some files for testing with raw-leaves" ' - create_files --raw-leaves + create_files --raw-leaves ' test_files_api QmTpKiKcAj4sbeesN6vrs5w3QeVmd4QmGpxRL81hHut4dZ test_kill_ipfs_daemon --offline test_expect_success "enable sharding in config" ' - ipfs config --json Experimental.ShardingEnabled true + ipfs config --json Experimental.ShardingEnabled true ' test_launch_ipfs_daemon --offline diff --git a/test/sharness/t0251-files-flushing.sh b/test/sharness/t0251-files-flushing.sh index 629a93016a4..193845e7ad9 100755 --- a/test/sharness/t0251-files-flushing.sh +++ b/test/sharness/t0251-files-flushing.sh @@ -11,41 +11,41 @@ test_description="test the unix files api flushing" test_init_ipfs verify_path_exists() { - # simply running ls on a file should be a good 'check' - ipfs files ls $1 + # simply running ls on a file should be a good 'check' + ipfs files ls $1 } verify_dir_contents() { - dir=$1 - shift - rm -f expected - touch expected - for e in $@ - do - echo $e >> expected - done - - test_expect_success "can list dir" ' - ipfs files ls $dir > output - ' - - test_expect_success "dir entries look good" ' - test_sort_cmp output expected - ' + dir=$1 + shift + rm -f expected + touch expected + for e in $@ + do + echo $e >> expected + done + + test_expect_success "can list dir" ' + ipfs files ls $dir > output + ' + + test_expect_success "dir entries look good" ' + test_sort_cmp output expected + ' } test_launch_ipfs_daemon test_expect_success "can copy a file in" ' - HASH=$(echo "foo" | ipfs add -q) && - ipfs files cp /ipfs/$HASH /file + HASH=$(echo "foo" | ipfs add -q) && + ipfs files cp /ipfs/$HASH /file ' test_kill_ipfs_daemon test_launch_ipfs_daemon test_expect_success "file is still there" ' - verify_path_exists /file + verify_path_exists /file ' test_kill_ipfs_daemon diff --git a/test/sharness/t0252-files-gc.sh b/test/sharness/t0252-files-gc.sh index 80801ee1890..10928c4247a 100755 --- a/test/sharness/t0252-files-gc.sh +++ b/test/sharness/t0252-files-gc.sh @@ -11,66 +11,66 @@ test_description="test how the unix files api interacts with the gc" test_init_ipfs test_expect_success "object not removed after gc" ' - echo "hello world" > hello.txt && - cat hello.txt | ipfs files write --create /hello.txt && - ipfs repo gc && - ipfs cat QmVib14uvPnCP73XaCDpwugRuwfTsVbGyWbatHAmLSdZUS + echo "hello world" > hello.txt && + cat hello.txt | ipfs files write --create /hello.txt && + ipfs repo gc && + ipfs cat QmVib14uvPnCP73XaCDpwugRuwfTsVbGyWbatHAmLSdZUS ' test_expect_success "/hello.txt still accessible after gc" ' - ipfs files read /hello.txt > hello-actual && - test_cmp hello.txt hello-actual + ipfs files read /hello.txt > hello-actual && + test_cmp hello.txt hello-actual ' ADIR_HASH=QmbCgoMYVuZq8m1vK31JQx9DorwQdLMF1M3sJ7kygLLqnW FILE1_HASH=QmX4eaSJz39mNhdu5ACUwTDpyA6y24HmrQNnAape6u3buS test_expect_success "gc okay after adding incomplete node -- prep" ' - ipfs files mkdir /adir && - echo "file1" | ipfs files write --create /adir/file1 && - echo "file2" | ipfs files write --create /adir/file2 && - ipfs pin add --recursive=false $ADIR_HASH && - ipfs files rm -r /adir && - ipfs repo gc && # will remove /adir/file1 and /adir/file2 but not /adir - test_must_fail ipfs cat $FILE1_HASH && - ipfs files cp /ipfs/$ADIR_HASH /adir && - ipfs pin rm $ADIR_HASH + ipfs files mkdir /adir && + echo "file1" | ipfs files write --create /adir/file1 && + echo "file2" | ipfs files write --create /adir/file2 && + ipfs pin add --recursive=false $ADIR_HASH && + ipfs files rm -r /adir && + ipfs repo gc && # will remove /adir/file1 and /adir/file2 but not /adir + test_must_fail ipfs cat $FILE1_HASH && + ipfs files cp /ipfs/$ADIR_HASH /adir && + ipfs pin rm $ADIR_HASH ' test_expect_success "gc okay after adding incomplete node" ' - ipfs refs $ADIR_HASH && - ipfs repo gc && - ipfs refs $ADIR_HASH + ipfs refs $ADIR_HASH && + ipfs repo gc && + ipfs refs $ADIR_HASH ' test_expect_success "add directory with direct pin" ' - mkdir mydir/ && - echo "hello world!" > mydir/hello.txt && - FILE_UNPINNED=$(ipfs add --pin=false -q -r mydir/hello.txt) && - DIR_PINNED=$(ipfs add --pin=false -q -r mydir | tail -n1) && - ipfs add --pin=false -r mydir && - ipfs pin add --recursive=false $DIR_PINNED && - ipfs cat $FILE_UNPINNED + mkdir mydir/ && + echo "hello world!" > mydir/hello.txt && + FILE_UNPINNED=$(ipfs add --pin=false -q -r mydir/hello.txt) && + DIR_PINNED=$(ipfs add --pin=false -q -r mydir | tail -n1) && + ipfs add --pin=false -r mydir && + ipfs pin add --recursive=false $DIR_PINNED && + ipfs cat $FILE_UNPINNED ' test_expect_success "run gc and make sure directory contents are removed" ' - ipfs repo gc && - test_must_fail ipfs cat $FILE_UNPINNED + ipfs repo gc && + test_must_fail ipfs cat $FILE_UNPINNED ' test_expect_success "add incomplete directory and make sure gc is okay" ' - ipfs files cp /ipfs/$DIR_PINNED /mydir && - ipfs repo gc && - test_must_fail ipfs cat $FILE_UNPINNED + ipfs files cp /ipfs/$DIR_PINNED /mydir && + ipfs repo gc && + test_must_fail ipfs cat $FILE_UNPINNED ' test_expect_success "add back directory contents and run gc" ' - ipfs add --pin=false mydir/hello.txt && - ipfs repo gc + ipfs add --pin=false mydir/hello.txt && + ipfs repo gc ' test_expect_success "make sure directory contents are not removed" ' - ipfs cat $FILE_UNPINNED + ipfs cat $FILE_UNPINNED ' test_done diff --git a/test/sharness/t0260-sharding-flag.sh b/test/sharness/t0260-sharding-flag.sh index 7bb75ab6690..8be494be605 100755 --- a/test/sharness/t0260-sharding-flag.sh +++ b/test/sharness/t0260-sharding-flag.sh @@ -9,20 +9,20 @@ test_description="Test global enable sharding flag" . lib/test-lib.sh test_expect_success "set up test data" ' - mkdir testdata - for i in `seq 2000` - do - echo $i > testdata/file$i - done + mkdir testdata + for i in `seq 2000` + do + echo $i > testdata/file$i + done ' test_add_large_dir() { - exphash="$1" - test_expect_success "ipfs add on very large directory succeeds" ' - ipfs add -r -q testdata | tail -n1 > sharddir_out && - echo "$exphash" > sharddir_exp && - test_cmp sharddir_exp sharddir_out - ' + exphash="$1" + test_expect_success "ipfs add on very large directory succeeds" ' + ipfs add -r -q testdata | tail -n1 > sharddir_out && + echo "$exphash" > sharddir_exp && + test_cmp sharddir_exp sharddir_out + ' } test_init_ipfs @@ -37,7 +37,7 @@ test_add_large_dir "$UNSHARDED" test_kill_ipfs_daemon test_expect_success "enable sharding" ' - ipfs config --json Experimental.ShardingEnabled true + ipfs config --json Experimental.ShardingEnabled true ' SHARDED="QmSCJD1KYLhVVHqBK3YyXuoEqHt7vggyJhzoFYbT8v1XYL" @@ -50,29 +50,29 @@ test_add_large_dir "$SHARDED" test_kill_ipfs_daemon test_expect_success "sharded and unsharded output look the same" ' - ipfs ls "$SHARDED" | sort > sharded_out && - ipfs ls "$UNSHARDED" | sort > unsharded_out && - test_cmp sharded_out unsharded_out + ipfs ls "$SHARDED" | sort > sharded_out && + ipfs ls "$UNSHARDED" | sort > unsharded_out && + test_cmp sharded_out unsharded_out ' test_expect_success "ipfs cat error output the same" ' - test_expect_code 1 ipfs cat "$SHARDED" 2> sharded_err && - test_expect_code 1 ipfs cat "$UNSHARDED" 2> unsharded_err && - test_cmp sharded_err unsharded_err + test_expect_code 1 ipfs cat "$SHARDED" 2> sharded_err && + test_expect_code 1 ipfs cat "$UNSHARDED" 2> unsharded_err && + test_cmp sharded_err unsharded_err ' test_add_large_dir_v1() { - exphash="$1" - test_expect_success "ipfs add (CIDv1) on very large directory succeeds" ' - ipfs add -r -q --cid-version=1 testdata | tail -n1 > sharddir_out && - echo "$exphash" > sharddir_exp && - test_cmp sharddir_exp sharddir_out - ' - - test_expect_success "can access a path under the dir" ' - ipfs cat "$exphash/file20" > file20_out && - test_cmp testdata/file20 file20_out - ' + exphash="$1" + test_expect_success "ipfs add (CIDv1) on very large directory succeeds" ' + ipfs add -r -q --cid-version=1 testdata | tail -n1 > sharddir_out && + echo "$exphash" > sharddir_exp && + test_cmp sharddir_exp sharddir_out + ' + + test_expect_success "can access a path under the dir" ' + ipfs cat "$exphash/file20" > file20_out && + test_cmp testdata/file20 file20_out + ' } # this hash implies both the directory and the leaf entries are CIDv1 diff --git a/test/sharness/t0270-filestore.sh b/test/sharness/t0270-filestore.sh index 7a54bfe44b2..04615db04b7 100755 --- a/test/sharness/t0270-filestore.sh +++ b/test/sharness/t0270-filestore.sh @@ -10,73 +10,73 @@ test_description="Test out the filestore nocopy functionality" test_expect_success "create a dataset" ' - random-files -seed=483 -depth=3 -dirs=4 -files=6 -filesize=1000000 somedir > /dev/null + random-files -seed=483 -depth=3 -dirs=4 -files=6 -filesize=1000000 somedir > /dev/null ' EXPHASH="QmW4JLyeTxEWGwa4mkE9mHzdtAkyhMX2ToGFEKZNjCiJud" get_repo_size() { - disk_usage "$IPFS_PATH" + disk_usage "$IPFS_PATH" } assert_repo_size_less_than() { - expval="$1" + expval="$1" - test_expect_success "check repo size" ' - test "$(get_repo_size)" -lt "$expval" || - { echo should be bellow "$expval" && test_fsh get_repo_size; } - ' + test_expect_success "check repo size" ' + test "$(get_repo_size)" -lt "$expval" || + { echo should be bellow "$expval" && test_fsh get_repo_size; } + ' } assert_repo_size_greater_than() { - expval="$1" + expval="$1" - test_expect_success "check repo size" ' - test "$(get_repo_size)" -gt "$expval" || - { echo should be above "$expval" && test_fsh get_repo_size; } - ' + test_expect_success "check repo size" ' + test "$(get_repo_size)" -gt "$expval" || + { echo should be above "$expval" && test_fsh get_repo_size; } + ' } test_filestore_adds() { - test_expect_success "nocopy add succeeds" ' - HASH=$(ipfs add --raw-leaves --nocopy -r -q somedir | tail -n1) - ' + test_expect_success "nocopy add succeeds" ' + HASH=$(ipfs add --raw-leaves --nocopy -r -q somedir | tail -n1) + ' - test_expect_success "nocopy add has right hash" ' - test "$HASH" = "$EXPHASH" - ' + test_expect_success "nocopy add has right hash" ' + test "$HASH" = "$EXPHASH" + ' - assert_repo_size_less_than 1000000 + assert_repo_size_less_than 1000000 - test_expect_success "normal add with fscache doesnt duplicate data" ' - ipfs add --raw-leaves --fscache -r -q somedir > /dev/null - ' + test_expect_success "normal add with fscache doesnt duplicate data" ' + ipfs add --raw-leaves --fscache -r -q somedir > /dev/null + ' - assert_repo_size_less_than 1000000 + assert_repo_size_less_than 1000000 - test_expect_success "normal add without fscache duplicates data" ' - ipfs add --raw-leaves -r -q somedir > /dev/null - ' + test_expect_success "normal add without fscache duplicates data" ' + ipfs add --raw-leaves -r -q somedir > /dev/null + ' - assert_repo_size_greater_than 1000000 + assert_repo_size_greater_than 1000000 } init_ipfs_filestore() { - test_expect_success "clean up old node" ' - rm -rf "$IPFS_PATH" mountdir ipfs ipns - ' + test_expect_success "clean up old node" ' + rm -rf "$IPFS_PATH" mountdir ipfs ipns + ' - test_init_ipfs + test_init_ipfs - test_expect_success "nocopy add errors and has right message" ' - test_must_fail ipfs add --nocopy -r somedir 2> add_out && - grep "filestore is not enabled" add_out - ' + test_expect_success "nocopy add errors and has right message" ' + test_must_fail ipfs add --nocopy -r somedir 2> add_out && + grep "filestore is not enabled" add_out + ' - test_expect_success "enable filestore config setting" ' - ipfs config --json Experimental.FilestoreEnabled true - ' + test_expect_success "enable filestore config setting" ' + ipfs config --json Experimental.FilestoreEnabled true + ' } init_ipfs_filestore @@ -84,7 +84,7 @@ init_ipfs_filestore test_filestore_adds test_debug ' - echo "pwd=$(pwd)"; echo "IPFS_PATH=$IPFS_PATH" + echo "pwd=$(pwd)"; echo "IPFS_PATH=$IPFS_PATH" ' diff --git a/test/sharness/t0271-filestore-utils.sh b/test/sharness/t0271-filestore-utils.sh index ae20d221d7a..c93f51e9a1c 100755 --- a/test/sharness/t0271-filestore-utils.sh +++ b/test/sharness/t0271-filestore-utils.sh @@ -9,30 +9,30 @@ test_description="Test out the filestore nocopy functionality" . lib/test-lib.sh test_init_filestore() { - test_expect_success "clean up old node" ' - rm -rf "$IPFS_PATH" mountdir ipfs ipns - ' + test_expect_success "clean up old node" ' + rm -rf "$IPFS_PATH" mountdir ipfs ipns + ' - test_init_ipfs + test_init_ipfs - test_expect_success "enable filestore config setting" ' - ipfs config --json Experimental.FilestoreEnabled true - ' + test_expect_success "enable filestore config setting" ' + ipfs config --json Experimental.FilestoreEnabled true + ' } test_init_dataset() { - test_expect_success "create a dataset" ' - rm -r somedir - mkdir somedir && - random 1000 1 > somedir/file1 && - random 10000 2 > somedir/file2 && - random 1000000 3 > somedir/file3 - ' + test_expect_success "create a dataset" ' + rm -r somedir + mkdir somedir && + random 1000 1 > somedir/file1 && + random 10000 2 > somedir/file2 && + random 1000000 3 > somedir/file3 + ' } test_init() { - test_init_filestore - test_init_dataset + test_init_filestore + test_init_dataset } EXPHASH="QmRueCuPMYYvdxWz1vWncF7wzCScEx4qasZXo5aVBb1R4V" @@ -64,105 +64,105 @@ EOF sort < verify_expect_file_order > verify_expect_key_order test_filestore_adds() { - test_expect_success "nocopy add succeeds" ' - HASH=$(ipfs add --raw-leaves --nocopy -r -q somedir | tail -n1) - ' - - test_expect_success "nocopy add has right hash" ' - test "$HASH" = "$EXPHASH" - ' - - test_expect_success "'ipfs filestore ls' output looks good'" ' - ipfs filestore ls | sort > ls_actual && - test_cmp ls_expect_key_order ls_actual - ' - - test_expect_success "'ipfs filestore ls --file-order' output looks good'" ' - ipfs filestore ls --file-order > ls_actual && - test_cmp ls_expect_file_order ls_actual - ' - - test_expect_success "'ipfs filestore ls HASH' works" ' - ipfs filestore ls $FILE1_HASH > ls_actual && - grep -q somedir/file1 ls_actual - ' - - test_expect_success "can retrieve multi-block file" ' - ipfs cat $FILE3_HASH > file3.data && - test_cmp somedir/file3 file3.data - ' + test_expect_success "nocopy add succeeds" ' + HASH=$(ipfs add --raw-leaves --nocopy -r -q somedir | tail -n1) + ' + + test_expect_success "nocopy add has right hash" ' + test "$HASH" = "$EXPHASH" + ' + + test_expect_success "'ipfs filestore ls' output looks good'" ' + ipfs filestore ls | sort > ls_actual && + test_cmp ls_expect_key_order ls_actual + ' + + test_expect_success "'ipfs filestore ls --file-order' output looks good'" ' + ipfs filestore ls --file-order > ls_actual && + test_cmp ls_expect_file_order ls_actual + ' + + test_expect_success "'ipfs filestore ls HASH' works" ' + ipfs filestore ls $FILE1_HASH > ls_actual && + grep -q somedir/file1 ls_actual + ' + + test_expect_success "can retrieve multi-block file" ' + ipfs cat $FILE3_HASH > file3.data && + test_cmp somedir/file3 file3.data + ' } # check that the filestore is in a clean state test_filestore_state() { - test_expect_success "ipfs filestore verify' output looks good'" ' - ipfs filestore verify | LC_ALL=C sort > verify_actual - test_cmp verify_expect_key_order verify_actual - ' + test_expect_success "ipfs filestore verify' output looks good'" ' + ipfs filestore verify | LC_ALL=C sort > verify_actual + test_cmp verify_expect_key_order verify_actual + ' } test_filestore_verify() { - test_filestore_state - - test_expect_success "ipfs filestore verify --file-order' output looks good'" ' - ipfs filestore verify --file-order > verify_actual - test_cmp verify_expect_file_order verify_actual - ' - - test_expect_success "'ipfs filestore verify HASH' works" ' - ipfs filestore verify $FILE1_HASH > verify_actual && - grep -q somedir/file1 verify_actual - ' - - test_expect_success "rename a file" ' - mv somedir/file1 somedir/file1.bk - ' - - test_expect_success "can not retrieve block after backing file moved" ' - test_must_fail ipfs cat $FILE1_HASH - ' - - test_expect_success "'ipfs filestore verify' shows file as missing" ' - ipfs filestore verify > verify_actual && - grep no-file verify_actual | grep -q somedir/file1 - ' - - test_expect_success "move file back" ' - mv somedir/file1.bk somedir/file1 - ' - - test_expect_success "block okay now" ' - ipfs cat $FILE1_HASH > file1.data && - test_cmp somedir/file1 file1.data - ' - - test_expect_success "change first bit of file" ' - dd if=/dev/zero of=somedir/file3 bs=1024 count=1 - ' - - test_expect_success "can not retrieve block after backing file changed" ' - test_must_fail ipfs cat $FILE3_HASH - ' - - test_expect_success "'ipfs filestore verify' shows file as changed" ' - ipfs filestore verify > verify_actual && - grep changed verify_actual | grep -q somedir/file3 - ' - - # reset the state for the next test - test_init_dataset + test_filestore_state + + test_expect_success "ipfs filestore verify --file-order' output looks good'" ' + ipfs filestore verify --file-order > verify_actual + test_cmp verify_expect_file_order verify_actual + ' + + test_expect_success "'ipfs filestore verify HASH' works" ' + ipfs filestore verify $FILE1_HASH > verify_actual && + grep -q somedir/file1 verify_actual + ' + + test_expect_success "rename a file" ' + mv somedir/file1 somedir/file1.bk + ' + + test_expect_success "can not retrieve block after backing file moved" ' + test_must_fail ipfs cat $FILE1_HASH + ' + + test_expect_success "'ipfs filestore verify' shows file as missing" ' + ipfs filestore verify > verify_actual && + grep no-file verify_actual | grep -q somedir/file1 + ' + + test_expect_success "move file back" ' + mv somedir/file1.bk somedir/file1 + ' + + test_expect_success "block okay now" ' + ipfs cat $FILE1_HASH > file1.data && + test_cmp somedir/file1 file1.data + ' + + test_expect_success "change first bit of file" ' + dd if=/dev/zero of=somedir/file3 bs=1024 count=1 + ' + + test_expect_success "can not retrieve block after backing file changed" ' + test_must_fail ipfs cat $FILE3_HASH + ' + + test_expect_success "'ipfs filestore verify' shows file as changed" ' + ipfs filestore verify > verify_actual && + grep changed verify_actual | grep -q somedir/file3 + ' + + # reset the state for the next test + test_init_dataset } test_filestore_dups() { - # make sure the filestore is in a clean state - test_filestore_state - - test_expect_success "'ipfs filestore dups'" ' - ipfs add --raw-leaves somedir/file1 && - ipfs filestore dups > dups_actual && - echo "$FILE1_HASH" > dups_expect - test_cmp dups_expect dups_actual - ' + # make sure the filestore is in a clean state + test_filestore_state + + test_expect_success "'ipfs filestore dups'" ' + ipfs add --raw-leaves somedir/file1 && + ipfs filestore dups > dups_actual && + echo "$FILE1_HASH" > dups_expect + test_cmp dups_expect dups_actual + ' } # diff --git a/test/sharness/t0280-plugin-git.sh b/test/sharness/t0280-plugin-git.sh index f09efed66d4..a93dfdebab3 100755 --- a/test/sharness/t0280-plugin-git.sh +++ b/test/sharness/t0280-plugin-git.sh @@ -10,40 +10,40 @@ test_description="Test git plugin" # if in travis CI, dont test mount (no fuse) if ! test_have_prereq PLUGIN; then - skip_all='skipping git plugin tests, plugins not available' + skip_all='skipping git plugin tests, plugins not available' - test_done + test_done fi test_init_ipfs test_expect_success "copy plugin" ' - mkdir -p "$IPFS_PATH/plugins" && - cp ../plugins/git.so "$IPFS_PATH/plugins/" + mkdir -p "$IPFS_PATH/plugins" && + cp ../plugins/git.so "$IPFS_PATH/plugins/" ' # from https://github.com/ipfs/go-ipld-git/blob/master/make-test-repo.sh test_expect_success "prepare test data" ' - tar xzf ../t0280-plugin-git-data/git.tar.gz + tar xzf ../t0280-plugin-git-data/git.tar.gz ' test_dag_git() { - test_expect_success "add objects via dag put" ' - find objects -type f -exec ipfs dag put --format=git --input-enc=zlib {} \; -exec echo \; > hashes - ' - - test_expect_success "successfully get added objects" ' - cat hashes | xargs -i ipfs dag get -- {} > /dev/null - ' - - test_expect_success "path traversals work" ' - echo \"YmxvYiA3ACcsLnB5Zgo=\" > file1 && - ipfs dag get z8mWaJh5RLq16Zwgtd8gZxd63P4hgwNNx/object/parents/0/tree/dir2/hash/f3/hash > out1 - ' - - test_expect_success "outputs look correct" ' - test_cmp file1 out1 - ' + test_expect_success "add objects via dag put" ' + find objects -type f -exec ipfs dag put --format=git --input-enc=zlib {} \; -exec echo \; > hashes + ' + + test_expect_success "successfully get added objects" ' + cat hashes | xargs -i ipfs dag get -- {} > /dev/null + ' + + test_expect_success "path traversals work" ' + echo \"YmxvYiA3ACcsLnB5Zgo=\" > file1 && + ipfs dag get z8mWaJh5RLq16Zwgtd8gZxd63P4hgwNNx/object/parents/0/tree/dir2/hash/f3/hash > out1 + ' + + test_expect_success "outputs look correct" ' + test_cmp file1 out1 + ' } # should work offline diff --git a/test/sharness/t0300-docker-image.sh b/test/sharness/t0300-docker-image.sh index 644a368c72b..9cf07f1fea3 100755 --- a/test/sharness/t0300-docker-image.sh +++ b/test/sharness/t0300-docker-image.sh @@ -10,21 +10,21 @@ test_description="Test docker image" # if in travis CI on OSX, docker is not available if ! test_have_prereq DOCKER; then - skip_all='skipping docker tests, docker not available' + skip_all='skipping docker tests, docker not available' - test_done + test_done fi test_expect_success "'docker --version' works" ' - docker --version >actual + docker --version >actual ' test_expect_success "'docker --version' output looks good" ' - egrep "^Docker version" actual + egrep "^Docker version" actual ' test_expect_success "current user is in the 'docker' group" ' - groups | egrep "\bdocker\b" + groups | egrep "\bdocker\b" ' TEST_TRASH_DIR=$(pwd) @@ -33,52 +33,52 @@ TEST_TESTS_DIR=$(dirname "$TEST_SCRIPTS_DIR") APP_ROOT_DIR=$(dirname "$TEST_TESTS_DIR") test_expect_success "docker image build succeeds" ' - docker_build "$TEST_TESTS_DIR/../Dockerfile.fast" "$APP_ROOT_DIR" >actual || - test_fsh echo "TEST_TESTS_DIR: $TEST_TESTS_DIR" || - test_fsh echo "APP_ROOT_DIR : $APP_ROOT_DIR" || - test_fsh cat actual + docker_build "$TEST_TESTS_DIR/../Dockerfile.fast" "$APP_ROOT_DIR" >actual || + test_fsh echo "TEST_TESTS_DIR: $TEST_TESTS_DIR" || + test_fsh echo "APP_ROOT_DIR : $APP_ROOT_DIR" || + test_fsh cat actual ' test_expect_success "docker image build output looks good" ' - SUCCESS_LINE=$(egrep "^Successfully built" actual) && - IMAGE_ID=$(expr "$SUCCESS_LINE" : "^Successfully built \(.*\)") || - test_fsh cat actual + SUCCESS_LINE=$(egrep "^Successfully built" actual) && + IMAGE_ID=$(expr "$SUCCESS_LINE" : "^Successfully built \(.*\)") || + test_fsh cat actual ' test_expect_success "docker image runs" ' - DOC_ID=$(docker_run "$IMAGE_ID") + DOC_ID=$(docker_run "$IMAGE_ID") ' test_expect_success "docker image gateway is up" ' - docker_exec "$DOC_ID" "wget --retry-connrefused --waitretry=1 --timeout=30 -t 30 \ - -q -O - http://localhost:8080/version >/dev/null" + docker_exec "$DOC_ID" "wget --retry-connrefused --waitretry=1 --timeout=30 -t 30 \ + -q -O - http://localhost:8080/version >/dev/null" ' test_expect_success "docker image API is up" ' - docker_exec "$DOC_ID" "wget --retry-connrefused --waitretry=1 --timeout=30 -t 30 \ - -q -O - http://localhost:5001/api/v0/version >/dev/null" + docker_exec "$DOC_ID" "wget --retry-connrefused --waitretry=1 --timeout=30 -t 30 \ + -q -O - http://localhost:5001/api/v0/version >/dev/null" ' test_expect_success "simple ipfs add/cat can be run in docker container" ' - expected="Hello Worlds" && - HASH=$(docker_exec "$DOC_ID" "echo $(cat expected) | ipfs add | cut -d' ' -f2") && - docker_exec "$DOC_ID" "ipfs cat $HASH" >actual && - test_cmp expected actual + expected="Hello Worlds" && + HASH=$(docker_exec "$DOC_ID" "echo $(cat expected) | ipfs add | cut -d' ' -f2") && + docker_exec "$DOC_ID" "ipfs cat $HASH" >actual && + test_cmp expected actual ' read testcode <actual ; \ - test -s actual ; \ - docker exec -i "$DOC_ID" ipfs version --enc json \ - | sed 's/^.*"Commit":"\\\([^"]*\\\)".*$/\\\1/g' >expected ; \ - test -s expected ; \ - test_cmp expected actual + docker exec -i "$DOC_ID" wget --retry-connrefused --waitretry=1 --timeout=30 -t 30 \ + -q -O - http://localhost:8080/version | grep Commit | cut -d" " -f2 >actual ; \ + test -s actual ; \ + docker exec -i "$DOC_ID" ipfs version --enc json \ + | sed 's/^.*"Commit":"\\\([^"]*\\\)".*$/\\\1/g' >expected ; \ + test -s expected ; \ + test_cmp expected actual EOF test_expect_success "version CurrentCommit is set" "$testcode" test_expect_success "stop docker container" ' - docker_stop "$DOC_ID" + docker_stop "$DOC_ID" ' test_done diff --git a/test/sharness/t0301-docker-migrate.sh b/test/sharness/t0301-docker-migrate.sh index e6c9a078923..56c2b57848d 100755 --- a/test/sharness/t0301-docker-migrate.sh +++ b/test/sharness/t0301-docker-migrate.sh @@ -10,9 +10,9 @@ test_description="Test docker image migration" # if in travis CI on OSX, docker is not available if ! test_have_prereq DOCKER; then - skip_all='skipping docker tests, docker not available' + skip_all='skipping docker tests, docker not available' - test_done + test_done fi TEST_TRASH_DIR=$(pwd) @@ -21,55 +21,55 @@ TEST_TESTS_DIR=$(dirname "$TEST_SCRIPTS_DIR") APP_ROOT_DIR=$(dirname "$TEST_TESTS_DIR") test_expect_success "docker image build succeeds" ' - docker_build "$TEST_TESTS_DIR/../Dockerfile.fast" "$APP_ROOT_DIR" >actual && - IMAGE_ID=$(tail -n1 actual | cut -d " " -f 3) + docker_build "$TEST_TESTS_DIR/../Dockerfile.fast" "$APP_ROOT_DIR" >actual && + IMAGE_ID=$(tail -n1 actual | cut -d " " -f 3) ' test_init_ipfs test_expect_success "make repo be version 4" ' - echo 4 > "$IPFS_PATH/version" + echo 4 > "$IPFS_PATH/version" ' test_expect_success "setup http response" ' - echo "HTTP/1.1 200 OK" > vers_resp && - echo "Content-Length: 7" >> vers_resp && - echo "" >> vers_resp && - echo "v1.1.1" >> vers_resp + echo "HTTP/1.1 200 OK" > vers_resp && + echo "Content-Length: 7" >> vers_resp && + echo "" >> vers_resp && + echo "v1.1.1" >> vers_resp ' pretend_server() { - cat vers_resp | nc -l -i 1 -p 17233 + cat vers_resp | nc -l -i 1 -p 17233 } test_expect_success "startup fake dists server" ' - pretend_server > dist_serv_out & - echo $! > netcat_pid + pretend_server > dist_serv_out & + echo $! > netcat_pid ' test_expect_success "docker image runs" ' - DOC_ID=$(docker run -d -v "$IPFS_PATH":/data/ipfs --net=host -e IPFS_DIST_PATH="http://localhost:17233" "$IMAGE_ID" --migrate) + DOC_ID=$(docker run -d -v "$IPFS_PATH":/data/ipfs --net=host -e IPFS_DIST_PATH="http://localhost:17233" "$IMAGE_ID" --migrate) ' test_expect_success "docker container tries to pull migrations from netcat" ' - sleep 4 && - cat dist_serv_out + sleep 4 && + cat dist_serv_out ' test_expect_success "see logs" ' - docker logs $DOC_ID + docker logs $DOC_ID ' test_expect_success "stop docker container" ' - docker_stop "$DOC_ID" + docker_stop "$DOC_ID" ' test_expect_success "kill the net cat" ' - kill $(cat netcat_pid) || true + kill $(cat netcat_pid) || true ' test_expect_success "correct version was requested" ' - grep "/fs-repo-migrations/v1.1.1/fs-repo-migrations_v1.1.1_linux-musl-amd64.tar.gz" dist_serv_out > /dev/null + grep "/fs-repo-migrations/v1.1.1/fs-repo-migrations_v1.1.1_linux-musl-amd64.tar.gz" dist_serv_out > /dev/null ' test_done diff --git a/test/sharness/t0400-api-security.sh b/test/sharness/t0400-api-security.sh index 277fa0953e8..ccf92527413 100755 --- a/test/sharness/t0400-api-security.sh +++ b/test/sharness/t0400-api-security.sh @@ -17,15 +17,15 @@ test_init_ipfs test_launch_ipfs_daemon test_expect_success "Gateway on API unavailable" ' - HASH=$(echo "testing" | ipfs add -q) - test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 404 Not Found" + HASH=$(echo "testing" | ipfs add -q) + test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 404 Not Found" ' test_kill_ipfs_daemon test_launch_ipfs_daemon --unrestricted-api test_expect_success "Gateway on --unrestricted-api API available" ' - HASH=$(echo "testing" | ipfs add -q) - test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 200 OK" + HASH=$(echo "testing" | ipfs add -q) + test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 200 OK" ' test_kill_ipfs_daemon diff --git a/test/sharness/t0410-api-add.sh b/test/sharness/t0410-api-add.sh index 24491d2d44f..d0d6b75c15c 100755 --- a/test/sharness/t0410-api-add.sh +++ b/test/sharness/t0410-api-add.sh @@ -14,7 +14,7 @@ test_init_ipfs test_launch_ipfs_daemon test_expect_success "API Add response includes size field" ' - echo "hi" | curl -s -F file=@- "http://localhost:$API_PORT/api/v0/add" | grep "\"Size\": *\"11\"" + echo "hi" | curl -s -F file=@- "http://localhost:$API_PORT/api/v0/add" | grep "\"Size\": *\"11\"" ' test_kill_ipfs_daemon diff --git a/test/sharness/t0500-issues-and-regressions-offline.sh b/test/sharness/t0500-issues-and-regressions-offline.sh index bfab467e53e..78eb1812593 100755 --- a/test/sharness/t0500-issues-and-regressions-offline.sh +++ b/test/sharness/t0500-issues-and-regressions-offline.sh @@ -7,36 +7,36 @@ test_description="Tests for various fixed issues and regressions." # Tests go here test_expect_success "ipfs init with occupied input works - #2748" ' - export IPFS_PATH="ipfs_path" - echo "" | go-timeout 10 ipfs init && - rm -rf ipfs_path + export IPFS_PATH="ipfs_path" + echo "" | go-timeout 10 ipfs init && + rm -rf ipfs_path ' test_init_ipfs test_expect_success "ipfs cat --help succeeds when input remains open" ' - yes | go-timeout 1 ipfs cat --help + yes | go-timeout 1 ipfs cat --help ' test_expect_success "ipfs pin ls --help succeeds when input remains open" ' - yes | go-timeout 1 ipfs pin ls --help + yes | go-timeout 1 ipfs pin ls --help ' test_expect_success "ipfs add on 1MB from stdin woks" ' - random 1048576 42 | ipfs add -q > 1MB.hash + random 1048576 42 | ipfs add -q > 1MB.hash ' test_expect_success "'ipfs refs -r -e \$(cat 1MB.hash)' succeeds" ' - ipfs refs -r -e $(cat 1MB.hash) > refs-e.out + ipfs refs -r -e $(cat 1MB.hash) > refs-e.out ' test_expect_success "output of 'ipfs refs -e' links to separate blocks" ' - grep "$(cat 1MB.hash) ->" refs-e.out + grep "$(cat 1MB.hash) ->" refs-e.out ' test_expect_success "output of 'ipfs refs -e' contains all first level links" ' - grep "$(cat 1MB.hash) ->" refs-e.out | sed -e '\''s/.* -> //'\'' | sort > refs-s.out && - ipfs refs "$(cat 1MB.hash)" | sort > refs-one.out && - test_cmp refs-s.out refs-one.out + grep "$(cat 1MB.hash) ->" refs-e.out | sed -e '\''s/.* -> //'\'' | sort > refs-s.out && + ipfs refs "$(cat 1MB.hash)" | sort > refs-one.out && + test_cmp refs-s.out refs-one.out ' test_done diff --git a/test/sharness/t0600-issues-and-regressions-online.sh b/test/sharness/t0600-issues-and-regressions-online.sh index b097ff81694..e49d8c66362 100755 --- a/test/sharness/t0600-issues-and-regressions-online.sh +++ b/test/sharness/t0600-issues-and-regressions-online.sh @@ -11,52 +11,52 @@ test_launch_ipfs_daemon # Tests go here test_expect_success "commands command with flag flags works via HTTP API - #2301" ' - curl "http://$API_ADDR/api/v0/commands?flags" | grep "verbose" + curl "http://$API_ADDR/api/v0/commands?flags" | grep "verbose" ' test_expect_success "ipfs refs local over HTTP API returns NDJOSN not flat - #2803" ' - echo "Hello World" | ipfs add && - curl "http://$API_ADDR/api/v0/refs/local" | grep "Ref" | grep "Err" + echo "Hello World" | ipfs add && + curl "http://$API_ADDR/api/v0/refs/local" | grep "Ref" | grep "Err" ' test_expect_success "args expecting stdin dont crash when not given" ' - curl "$API_ADDR/api/v0/bootstrap/add" > result + curl "$API_ADDR/api/v0/bootstrap/add" > result ' test_expect_success "no panic traces on daemon" ' - test_must_fail grep "nil pointer dereference" daemon_err + test_must_fail grep "nil pointer dereference" daemon_err ' test_expect_success "metrics work" ' - curl "$API_ADDR/debug/metrics/prometheus" > pro_data && - grep "ipfs_bs_cache_arc_hits_total" < pro_data || - test_fsh cat pro_data + curl "$API_ADDR/debug/metrics/prometheus" > pro_data && + grep "ipfs_bs_cache_arc_hits_total" < pro_data || + test_fsh cat pro_data ' test_expect_success "pin add api looks right - #3753" ' - HASH=$(echo "foo" | ipfs add -q) && - curl "http://$API_ADDR/api/v0/pin/add/$HASH" > pinadd_out && - echo "{\"Pins\":[\"QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6\"]}" > pinadd_exp && - test_cmp pinadd_out pinadd_exp + HASH=$(echo "foo" | ipfs add -q) && + curl "http://$API_ADDR/api/v0/pin/add/$HASH" > pinadd_out && + echo "{\"Pins\":[\"QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6\"]}" > pinadd_exp && + test_cmp pinadd_out pinadd_exp ' test_expect_success "pin add api looks right - #3753" ' - curl "http://$API_ADDR/api/v0/pin/rm/$HASH" > pinrm_out && - echo "{\"Pins\":[\"QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6\"]}" > pinrm_exp && - test_cmp pinrm_out pinrm_exp + curl "http://$API_ADDR/api/v0/pin/rm/$HASH" > pinrm_out && + echo "{\"Pins\":[\"QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6\"]}" > pinrm_exp && + test_cmp pinrm_out pinrm_exp ' test_expect_success "no daemon crash on improper file argument - #4003" ' - FNC=$(echo $API_ADDR | awk -F: '\''{ printf "%s %s", $1, $2 }'\'') && - printf "POST /api/v0/add?pin=true HTTP/1.1\r\nHost: $API_ADDR\r\nContent-Type: multipart/form-data; boundary=Pyw9xQLtiLPE6XcI\r\nContent-Length: 22\r\n\r\n\r\n--Pyw9xQLtiLPE6XcI\r\n" | nc -v $FNC | grep -m1 "200 OK" + FNC=$(echo $API_ADDR | awk -F: '\''{ printf "%s %s", $1, $2 }'\'') && + printf "POST /api/v0/add?pin=true HTTP/1.1\r\nHost: $API_ADDR\r\nContent-Type: multipart/form-data; boundary=Pyw9xQLtiLPE6XcI\r\nContent-Length: 22\r\n\r\n\r\n--Pyw9xQLtiLPE6XcI\r\n" | nc -v $FNC | grep -m1 "200 OK" ' test_kill_ipfs_daemon test_expect_success "ipfs daemon --offline --mount fails - #2995" ' - test_expect_code 1 ipfs daemon --offline --mount 2>daemon_err && - grep "mount is not currently supported in offline mode" daemon_err || - test_fsh cat daemon_err + test_expect_code 1 ipfs daemon --offline --mount 2>daemon_err && + grep "mount is not currently supported in offline mode" daemon_err || + test_fsh cat daemon_err ' test_done diff --git a/test/sharness/x0601-pin-fail-test.sh b/test/sharness/x0601-pin-fail-test.sh index decdd34b56c..de89735cbd1 100755 --- a/test/sharness/x0601-pin-fail-test.sh +++ b/test/sharness/x0601-pin-fail-test.sh @@ -13,22 +13,22 @@ test_init_ipfs test_launch_ipfs_daemon test_expect_success "pre-test setup" ' - printf "" > pins && - ipfs pin ls --type=recursive -q > rec_pins_before + printf "" > pins && + ipfs pin ls --type=recursive -q > rec_pins_before ' for i in `seq 9000` do - test_expect_success "ipfs add (and pin) a file" ' - echo $i | ipfs add -q >> pins - ' + test_expect_success "ipfs add (and pin) a file" ' + echo $i | ipfs add -q >> pins + ' done test_expect_success "get pinset afterwards" ' - ipfs pin ls --type=recursive -q | sort > rec_pins_after && - cat pins rec_pins_before | sort | uniq > exp_pins_after && - test_cmp rec_pins_after exp_pins_after + ipfs pin ls --type=recursive -q | sort > rec_pins_after && + cat pins rec_pins_before | sort | uniq > exp_pins_after && + test_cmp rec_pins_after exp_pins_after ' test_kill_ipfs_daemon