sharness: use tabs for indent

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
Łukasz Magiera 2017-09-06 20:50:39 +02:00
parent 8063ccd5d3
commit 83f001bd96
38 changed files with 1121 additions and 1121 deletions

View File

@ -17,7 +17,7 @@ test_expect_success "ipfs version succeeds" '
'
test_expect_success "ipfs --version success" '
ipfs --version
ipfs --version
'
test_expect_success "ipfs version output looks good" '
@ -26,10 +26,10 @@ test_expect_success "ipfs version output looks good" '
'
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
'
@ -79,7 +79,7 @@ test_expect_failure "All ipfs root commands are mentioned in base helptext" '
cut -d" " -f 2 commands.txt | grep -v ipfs | sort -u | \
while read cmd
do
grep " $cmd" help.txt > /dev/null ||
grep " $cmd" help.txt > /dev/null ||
{ echo missing $cmd from helptext; echo 1 > fail; }
done

View File

@ -40,14 +40,14 @@ test_expect_success "cleanup dir with bad perms" '
# test no repo error message
# this applies to `ipfs add sth`, `ipfs refs <hash>`
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

View File

@ -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; }
# 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"
'
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
'
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"
'
# 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
'
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
@ -42,115 +42,115 @@ test_config_cmd_set() {
# set it as astring instead of proper json. We leverage the
# unmarshalling that has to happen.
CONFIG_SET_JSON_TEST='{
"MDNS": {
"Enabled": true,
"Interval": 10
}
"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_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' 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 "'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 "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'" '
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
'
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
# 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 "'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 "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 "'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 "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 "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 "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 "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 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' 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 "'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 "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 "'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_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

View File

@ -30,7 +30,7 @@ test_expect_success "ipfs config succeeds" '
'
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" '

View File

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

View File

@ -18,12 +18,12 @@ 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 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
@ -35,22 +35,22 @@ test_expect_success "'ipfs mount' output looks good" '
'
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" '
@ -58,8 +58,8 @@ test_expect_success "mount directories cannot be removed while active" '
'
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" '
@ -67,7 +67,7 @@ test_expect_success "mount directories can be removed after shutdown" '
'
test_expect_success 'stop iptb' '
iptb stop
iptb stop
'
test_done

View File

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

View File

@ -18,112 +18,112 @@ test_add_cat_file() {
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 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 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 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 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 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 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 "ipfs cat /ipfs/file succeeds" '
ipfs cat /ipfs/$HASH >actual
'
test_expect_success "output looks good" '
test_cmp expected 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 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 -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 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 --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 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 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 "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 "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_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 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 "'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 succeeds" '
cat "ipfs/$EXP_HASH" >actual
'
test_expect_success FUSE "cat ipfs/bigfile looks good" '
test_cmp mountdir/bigfile actual
'
test_expect_success FUSE "cat ipfs/bigfile looks good" '
test_cmp mountdir/bigfile actual
'
}
test_add_cat_raw() {
@ -142,85 +142,85 @@ test_add_cat_raw() {
}
test_add_cat_expensive() {
ADD_FLAGS="$1"
HASH="$2"
ADD_FLAGS="$1"
HASH="$2"
test_expect_success EXPENSIVE "generate 100MB file using go-random" '
random 104857600 42 >mountdir/bigfile
'
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 "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 $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 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 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 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 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 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_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
'
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_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
@ -250,7 +250,7 @@ test_expect_success "ipfs cat succeeds with stdin opened (issue #1141)" '
'
test_expect_success "ipfs cat output looks good" '
cat mountdir/hello.txt >expected &&
cat mountdir/hello.txt >expected &&
test_cmp expected actual
'
@ -320,69 +320,69 @@ test_expect_success "ipfs cat with built input output looks good" '
'
add_directory() {
EXTRA_ARGS=$1
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 -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 --quieter returns only one correct hash" '
echo "$PLANETS" > expected &&
test_cmp expected 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 "cleanup" '
rm -r mountdir/planets
'
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"
@ -422,21 +422,21 @@ test_expect_success "'ipfs add -rn' succeeds" '
test_expect_success "'ipfs add -rn' output looks good" '
MOONS="QmVKvomp91nMih5j6hYBA8KjbiaYvEetU2Q7KvtZkLe9nQ" &&
EUROPA="Qmbjg7zWdqdMaK2BucPncJQDxiALExph5k3NkQv5RHpccu" &&
JUPITER="QmS5mZddhFPLWFX3w6FzAy9QxyYkaxvUpsWCtZ3r7jub9J" &&
SATURN="QmaMagZT4rTE7Nonw8KGSK4oe1bh533yhZrCo1HihSG8FK" &&
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 &&
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"
@ -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 ""

View File

@ -55,7 +55,7 @@ test_add_skip() {
added QmT4uMRDCN7EMpFeqwvKkboszbqeW1kWVGrBxBuCGqZcQc .vimrc
EOF
ipfs add mountdir/dotfiles/.vimrc >actual
cat actual
cat actual
test_cmp expected actual
'

View File

@ -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 "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_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 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_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 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) 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) 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_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 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_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 <many> succeeds" '
ipfs add -w -r m/t_1wp-8a2/h3qpecj0 \
m/ha6f0x7su6/gnz66h m/t_1wp-8a2/_jo7 m/4r93 >actual
'
# test files and directory
test_expect_success "ipfs add -w -r <many> 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 <many> is correct" '
echo "$add_w_d2" >expected &&
test_sort_cmp expected actual
'
test_expect_success "ipfs add -w -r <many> 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 -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_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 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 (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 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 "ipfs add -w -r (dir) --cid-version=1 is correct" '
echo "$add_w_d1_v1" >expected &&
test_sort_cmp expected actual
'
}
test_init_ipfs

View File

@ -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,45 +128,45 @@ 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" '

View File

@ -61,7 +61,7 @@ test_object_cmd() {
'
test_expect_success "'ipfs object put file.json' succeeds" '
ipfs object put ../t0051-object-data/testPut.json > actual_putOut
ipfs object put ../t0051-object-data/testPut.json > actual_putOut
'
test_expect_success "'ipfs object put file.json' output looks good" '
@ -71,7 +71,7 @@ test_object_cmd() {
'
test_expect_success "'ipfs object put file.xml' succeeds" '
ipfs object put ../t0051-object-data/testPut.xml --inputenc=xml > actual_putOut
ipfs object put ../t0051-object-data/testPut.xml --inputenc=xml > actual_putOut
'
test_expect_success "'ipfs object put file.xml' output looks good" '
@ -307,21 +307,21 @@ test_object_cmd() {
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

View File

@ -14,48 +14,48 @@ 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
@ -86,9 +86,9 @@ test_expect_success "nc is available" '
# 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 ||
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
'
@ -106,11 +106,11 @@ test_expect_success "output looks good" '
# 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)" '
@ -121,9 +121,9 @@ test_expect_success "'ipfs daemon' should be able to run with a pipe attached to
'
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

View File

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

View File

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

View File

@ -49,14 +49,14 @@ test_expect_success "'ipfs pin rm' output looks good" '
'
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" '
@ -136,7 +136,7 @@ test_expect_success "pin something directly" '
DIRECTPIN=`ipfs add -q awesome` &&
echo "unpinned $DIRECTPIN" >expected9 &&
ipfs pin rm -r "$DIRECTPIN" >actual9 &&
test_cmp expected9 actual9 &&
test_cmp expected9 actual9 &&
echo "pinned $DIRECTPIN directly" >expected10 &&
ipfs pin add -r=false "$DIRECTPIN" >actual10 &&
@ -220,34 +220,34 @@ test_expect_success "'ipfs refs --unique --recursive (bigger)'" '
'
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" '
@ -255,7 +255,7 @@ test_expect_success "repo version came out correct" '
'
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

View File

@ -17,13 +17,13 @@ test_pin_flag() {
if ipfs pin ls --type="$ptype" "$object" >actual
then
test "$expect" = "true" && return
test_fsh cat actual
return
test "$expect" = "true" && return
test_fsh cat actual
return
else
test "$expect" = "false" && return
test_fsh cat actual
return
test "$expect" = "false" && return
test_fsh cat actual
return
fi
}
@ -41,8 +41,8 @@ test_pin() {
[ "$?" = "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
test_pin_flag "$object" "indirect" $i || return 1
test_pin_flag "$object" "direct" $d || return 1
return 0
}
@ -108,10 +108,10 @@ test_expect_success "objects are there" '
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 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
@ -152,16 +152,16 @@ test_expect_success "'ipfs repo gc' succeeds" '
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_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 &&
ipfs ls "$HASH_DIR3" >>actual45 &&
ipfs ls "$HASH_DIR4" >>actual45 &&
ipfs ls "$HASH_DIR2" >>actual45 &&
ipfs ls "$HASH_DIR1" >>actual45 &&
test_cmp expected45 actual45
'
@ -178,27 +178,27 @@ test_expect_success "none are pinned any more" '
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_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_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_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_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 &&
@ -220,12 +220,12 @@ test_expect_success "'ipfs repo gc' succeeds" '
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_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 ls "$HASH_DIR4" >>actual8 &&
ipfs ls "$HASH_DIR2" >>actual8 &&
ipfs object links "$HASH_DIR1" >>actual8 &&
test_cmp expected8 actual8
'
@ -275,9 +275,9 @@ test_expect_success "test add nopin dir" '
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

View File

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

View File

@ -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,9 +64,9 @@ 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" '
@ -75,45 +75,45 @@ test_expect_success "'ipfs repo fsck' output looks good with no daemon" '
# 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

View File

@ -11,20 +11,20 @@ test_description="Test get command"
test_init_ipfs
test_ipfs_get_flag() {
ext="$1"; shift
tar_flag="$1"; shift
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 succeeds" '
ipfs get "$HASH" '"$flag"' >actual
'
test_expect_success "ipfs get $flag output looks good" '
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" '
test_expect_success "ipfs get $flag archive output is valid" '
tar "$tar_flag" "$HASH$ext" &&
test_cmp "$HASH" data &&
rm "$HASH$ext" &&
@ -78,11 +78,11 @@ test_get_cmd() {
test_cmp "$HASH2" data
'
test_ipfs_get_flag ".tar" "-xf" -a
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
test_ipfs_get_flag ".tar.gz" "-zxf" -a -C -l 9
test_ipfs_get_flag ".tar.gz" "-zxf" -a -C -l 9
test_expect_success "ipfs get succeeds (directory)" '
mkdir -p dir &&

View File

@ -55,9 +55,9 @@ test_expect_success "resolve output looks good" '
'
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

View File

@ -22,65 +22,65 @@ 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) ||
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" '
@ -124,35 +124,35 @@ test_expect_success "HEAD 'index.html' has no content" '
# 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

View File

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

View File

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

View File

@ -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
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' succeeds" '
ipfs bootstrap >list_actual
'
test_expect_success "'ipfs bootstrap' output looks good" '
test_cmp list_expected 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' succeeds" '
ipfs bootstrap list >list2_actual
'
test_expect_success "'ipfs bootstrap list' output looks good" '
test_cmp list_expected 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
# 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_bootstrap_list_cmd
test_expect_success "'ipfs bootstrap add' succeeds" '
ipfs bootstrap add "$BP1" "$BP2" "$BP3" >add_actual
'
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_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_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' 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_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_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' 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_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_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 --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_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_bootstrap_list_cmd
test_expect_success "'ipfs bootstrap add' accepts args from stdin" '
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_expect_success "output looks good" '
test_cmp add_stdin_actual bpeers
'
'
test_bootstrap_list_cmd $BP1 $BP2 $BP3 $BP4
test_bootstrap_list_cmd $BP1 $BP2 $BP3 $BP4
test_expect_success "'ipfs bootstrap rm' accepts args from stdin" '
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_expect_success "output looks good" '
test_cmp rm_stdin_actual bpeers
'
'
test_bootstrap_list_cmd
test_bootstrap_list_cmd
}
# should work offline

View File

@ -22,15 +22,15 @@ test_expect_success "setup iptb nodes" '
'
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() {

View File

@ -51,7 +51,7 @@ 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
@ -67,32 +67,32 @@ 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 &&
grep -v "/ip4/1.2.3.4/tcp/1234" actual &&
ipfs id -f"<addrs>" | xargs -n1 echo >actual &&
grep -v "/ip4/1.2.3.4/tcp/1234" 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 &&
grep -v "/ip4/1.2.3.4/tcp/1234" actual &&
ipfs id -f"<addrs>" | xargs -n1 echo >actual &&
grep -v "/ip4/1.2.3.4/tcp/1234" actual
grep -v "/ip4/1.2.3.4/tcp/1234" actual
'
test_kill_ipfs_daemon

View File

@ -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 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 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 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 multiple commands are suggested" '
grep "Did you mean any of these?" actual &&
grep "ls" actual &&
grep "id" actual ||
test_fsh cat actual
'
}

View File

@ -7,27 +7,27 @@ 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 <peerID>
test_expect_success 'findpeer' '
ipfsi 1 dht findpeer $PEERID_0 | sort >actual &&
ipfsi 0 id -f "<addrs>" | cut -d / -f 1-5 | sort >expected &&
test_cmp actual expected
ipfsi 1 dht findpeer $PEERID_0 | sort >actual &&
ipfsi 0 id -f "<addrs>" | cut -d / -f 1-5 | sort >expected &&
test_cmp actual expected
'
# ipfs dht put <key> <value>
test_expect_success 'put' '
ipfsi 1 dht put planet pluto | sort >putted &&
[ -s putted ] ||
ipfsi 1 dht put planet pluto | sort >putted &&
[ -s putted ] ||
test_fsh cat putted
'
@ -45,9 +45,9 @@ test_expect_success 'findprovs' '
# ipfs dht get <key>
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 ||
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
'
@ -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 ] ||
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

View File

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

View File

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

View File

@ -7,14 +7,14 @@ 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
@ -58,7 +58,7 @@ test_expect_success "wait until echo > wait executed" '
'
test_expect_success 'stop iptb' '
iptb stop
iptb stop
'
test_done

View File

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

View File

@ -16,7 +16,7 @@ test_ls_cmd() {
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
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" '
@ -39,7 +39,7 @@ test_ls_cmd() {
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
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" '

View File

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

View File

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

View File

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

View File

@ -47,8 +47,8 @@ test_expect_success "pin add api looks right - #3753" '
'
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