@cryptotaxi247 / kubo / commits / 6a40c37b9

sharness: 2 space indent

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Sep 7, 2017 at 22:57 UTC 6a40c37b9498c52ccd7ecb4e18ebb14ce3d9ef13
83 files changed +4806 -4806
test/sharness/lib/install-sharness.sh
+19 -19
@@ -9,41 +9,41 @@
9 version=5eee9b51b5621cec95a64018f0cc779963b230d2
10 urlprefix=https://github.com/mlafeldt/sharness.git
11 if test ! -n "$clonedir" ; then
12 - clonedir=lib
12 + clonedir=lib
13 fi
14 sharnessdir=sharness
15
16 if test -f "$clonedir/$sharnessdir/SHARNESS_VERSION_$version"
17 then
18 - # There is the right version file. Great, we are done!
19 - exit 0
18 + # There is the right version file. Great, we are done!
19 + exit 0
20 fi
21
22 die() {
23 - echo >&2 "$@"
24 - exit 1
23 + echo >&2 "$@"
24 + exit 1
25 }
26
27 checkout_version() {
28 - git checkout "$version" || die "Could not checkout '$version'"
29 - rm -f SHARNESS_VERSION_* || die "Could not remove 'SHARNESS_VERSION_*'"
30 - touch "SHARNESS_VERSION_$version" || die "Could not create 'SHARNESS_VERSION_$version'"
31 - echo "Sharness version $version is checked out!"
28 + git checkout "$version" || die "Could not checkout '$version'"
29 + rm -f SHARNESS_VERSION_* || die "Could not remove 'SHARNESS_VERSION_*'"
30 + touch "SHARNESS_VERSION_$version" || die "Could not create 'SHARNESS_VERSION_$version'"
31 + echo "Sharness version $version is checked out!"
32 }
33
34 if test -d "$clonedir/$sharnessdir/.git"
35 then
36 - # We need to update sharness!
37 - cd "$clonedir/$sharnessdir" || die "Could not cd into '$clonedir/$sharnessdir' directory"
38 - git fetch || die "Could not fetch to update sharness"
39 - checkout_version
36 + # We need to update sharness!
37 + cd "$clonedir/$sharnessdir" || die "Could not cd into '$clonedir/$sharnessdir' directory"
38 + git fetch || die "Could not fetch to update sharness"
39 + checkout_version
40 else
41 - # We need to clone sharness!
42 - mkdir -p "$clonedir" || die "Could not create '$clonedir' directory"
43 - cd "$clonedir" || die "Could not cd into '$clonedir' directory"
41 + # We need to clone sharness!
42 + mkdir -p "$clonedir" || die "Could not create '$clonedir' directory"
43 + cd "$clonedir" || die "Could not cd into '$clonedir' directory"
44
45 - git clone "$urlprefix" || die "Could not clone '$urlprefix'"
46 - cd "$sharnessdir" || die "Could not cd into '$sharnessdir' directory"
47 - checkout_version
45 + git clone "$urlprefix" || die "Could not clone '$urlprefix'"
46 + cd "$sharnessdir" || die "Could not cd into '$sharnessdir' directory"
47 + checkout_version
48 fi
49 exit 0
test/sharness/lib/iptb-lib.sh
+29 -29
@@ -6,42 +6,42 @@
6 export IPTB_ROOT="$(pwd)/.iptb"
7
8 ipfsi() {
9 - dir="$1"
10 - shift
11 - IPFS_PATH="$IPTB_ROOT/$dir" ipfs "$@"
9 + dir="$1"
10 + shift
11 + IPFS_PATH="$IPTB_ROOT/$dir" ipfs "$@"
12 }
13
14 check_has_connection() {
15 - node="$1"
16 - ipfsi "$node" swarm peers >"swarm_peers_$node" &&
17 - grep "ipfs" "swarm_peers_$node" >/dev/null
15 + node="$1"
16 + ipfsi "$node" swarm peers >"swarm_peers_$node" &&
17 + grep "ipfs" "swarm_peers_$node" >/dev/null
18 }
19
20 startup_cluster() {
21 - num_nodes="$1"
22 - shift
23 - other_args="$@"
24 - bound=$(expr "$num_nodes" - 1)
21 + num_nodes="$1"
22 + shift
23 + other_args="$@"
24 + bound=$(expr "$num_nodes" - 1)
25
26 - if test -n "$other_args"; then
27 - test_expect_success "start up nodes with additional args" '
28 - iptb start --args $other_args
29 - '
30 - else
31 - test_expect_success "start up nodes" '
32 - iptb start
33 - '
34 - fi
26 + if test -n "$other_args"; then
27 + test_expect_success "start up nodes with additional args" '
28 + iptb start --args $other_args
29 + '
30 + else
31 + test_expect_success "start up nodes" '
32 + iptb start
33 + '
34 + fi
35
36 - test_expect_success "connect nodes to eachother" '
37 - iptb connect [1-$bound] 0
38 - '
36 + test_expect_success "connect nodes to eachother" '
37 + iptb connect [1-$bound] 0
38 + '
39
40 - for i in $(test_seq 0 "$bound")
41 - do
42 - test_expect_success "node $i is connected" '
43 - check_has_connection "$i" ||
44 - test_fsh cat "swarm_peers_$i"
45 - '
46 - done
40 + for i in $(test_seq 0 "$bound")
41 + do
42 + test_expect_success "node $i is connected" '
43 + check_has_connection "$i" ||
44 + test_fsh cat "swarm_peers_$i"
45 + '
46 + done
47 }
test/sharness/lib/test-aggregate-results.sh
+3 -3
@@ -9,9 +9,9 @@
9 SHARNESS_AGGREGATE="lib/sharness/aggregate-results.sh"
10
11 test -f "$SHARNESS_AGGREGATE" || {
12 - echo >&2 "Cannot find: $SHARNESS_AGGREGATE"
13 - echo >&2 "Please check Sharness installation."
14 - exit 1
12 + echo >&2 "Cannot find: $SHARNESS_AGGREGATE"
13 + echo >&2 "Please check Sharness installation."
14 + exit 1
15 }
16
17 ls test-results/t*-*.sh.*.counts | "$SHARNESS_AGGREGATE"
test/sharness/lib/test-lib.sh
+237 -237
@@ -10,16 +10,16 @@
10
11 # add current directory to path, for ipfs tool.
12 if test "$MAKE_SKIP_PATH" != "1"; then
13 - BIN=$(cd .. && echo `pwd`/bin)
14 - BIN2=$(cd ../.. && echo `pwd`/cmd/ipfs)
15 - PATH=${BIN2}:${BIN}:${PATH}
16 -
17 - # assert the `ipfs` we're using is the right one.
18 - if test `which ipfs` != ${BIN2}/ipfs; then
19 - echo >&2 "Cannot find the tests' local ipfs tool."
20 - echo >&2 "Please check test and ipfs tool installation."
21 - exit 1
22 - fi
13 + BIN=$(cd .. && echo `pwd`/bin)
14 + BIN2=$(cd ../.. && echo `pwd`/cmd/ipfs)
15 + PATH=${BIN2}:${BIN}:${PATH}
16 +
17 + # assert the `ipfs` we're using is the right one.
18 + if test `which ipfs` != ${BIN2}/ipfs; then
19 + echo >&2 "Cannot find the tests' local ipfs tool."
20 + echo >&2 "Please check test and ipfs tool installation."
21 + exit 1
22 + fi
23 fi
24
25 # set sharness verbosity. we set the env var directly as
@@ -33,9 +33,9 @@ test "$TEST_VERBOSE" = 1 && verbose=t
33 SHARNESS_LIB="lib/sharness/sharness.sh"
34
35 . "$SHARNESS_LIB" || {
36 - echo >&2 "Cannot source: $SHARNESS_LIB"
37 - echo >&2 "Please check Sharness installation."
38 - exit 1
36 + echo >&2 "Cannot source: $SHARNESS_LIB"
37 + echo >&2 "Please check Sharness installation."
38 + exit 1
39 }
40
41 # Please put go-ipfs specific shell functions below
@@ -52,11 +52,11 @@ test "$TEST_NO_PLUGIN" != 1 && test "$TEST_OS" = "LINUX" && test_set_prereq PLUG
52 expr "$TEST_OS" : "CYGWIN_NT" >/dev/null || test_set_prereq STD_ERR_MSG
53
54 if test "$TEST_VERBOSE" = 1; then
55 - echo '# TEST_VERBOSE='"$TEST_VERBOSE"
56 - echo '# TEST_NO_FUSE='"$TEST_NO_FUSE"
57 - echo '# TEST_NO_PLUGIN='"$TEST_NO_PLUGIN"
58 - echo '# TEST_EXPENSIVE='"$TEST_EXPENSIVE"
59 - echo '# TEST_OS='"$TEST_OS"
55 + echo '# TEST_VERBOSE='"$TEST_VERBOSE"
56 + echo '# TEST_NO_FUSE='"$TEST_NO_FUSE"
57 + echo '# TEST_NO_PLUGIN='"$TEST_NO_PLUGIN"
58 + echo '# TEST_EXPENSIVE='"$TEST_EXPENSIVE"
59 + echo '# TEST_OS='"$TEST_OS"
60 fi
61
62 # source our generic test lib
@@ -66,46 +66,46 @@ fi
66 . ../lib/iptb-lib.sh
67
68 test_cmp_repeat_10_sec() {
69 - for i in $(test_seq 1 100)
70 - do
71 - test_cmp "$1" "$2" >/dev/null && return
72 - go-sleep 100ms
73 - done
74 - test_cmp "$1" "$2"
69 + for i in $(test_seq 1 100)
70 + do
71 + test_cmp "$1" "$2" >/dev/null && return
72 + go-sleep 100ms
73 + done
74 + test_cmp "$1" "$2"
75 }
76
77 test_run_repeat_60_sec() {
78 - for i in $(test_seq 1 600)
79 - do
80 - (test_eval_ "$1") && return
81 - go-sleep 100ms
82 - done
83 - return 1 # failed
78 + for i in $(test_seq 1 600)
79 + do
80 + (test_eval_ "$1") && return
81 + go-sleep 100ms
82 + done
83 + return 1 # failed
84 }
85
86 test_wait_output_n_lines_60_sec() {
87 - for i in $(test_seq 1 600)
88 - do
89 - test $(cat "$1" | wc -l | tr -d " ") -ge $2 && return
90 - go-sleep 100ms
91 - done
92 - actual=$(cat "$1" | wc -l | tr -d " ")
93 - test_fsh "expected $2 lines of output. got $actual"
87 + for i in $(test_seq 1 600)
88 + do
89 + test $(cat "$1" | wc -l | tr -d " ") -ge $2 && return
90 + go-sleep 100ms
91 + done
92 + actual=$(cat "$1" | wc -l | tr -d " ")
93 + test_fsh "expected $2 lines of output. got $actual"
94 }
95
96 test_wait_open_tcp_port_10_sec() {
97 - for i in $(test_seq 1 100)
98 - do
99 - # this is not a perfect check, but it's portable.
100 - # cant count on ss. not installed everywhere.
101 - # cant count on netstat using : or . as port delim. differ across platforms.
102 - echo $(netstat -aln | egrep "^tcp.*LISTEN" | egrep "[.:]$1" | wc -l) -gt 0
103 - if [ $(netstat -aln | egrep "^tcp.*LISTEN" | egrep "[.:]$1" | wc -l) -gt 0 ]; then
104 - return 0
105 - fi
106 - go-sleep 100ms
107 - done
108 - return 1
97 + for i in $(test_seq 1 100)
98 + do
99 + # this is not a perfect check, but it's portable.
100 + # cant count on ss. not installed everywhere.
101 + # cant count on netstat using : or . as port delim. differ across platforms.
102 + echo $(netstat -aln | egrep "^tcp.*LISTEN" | egrep "[.:]$1" | wc -l) -gt 0
103 + if [ $(netstat -aln | egrep "^tcp.*LISTEN" | egrep "[.:]$1" | wc -l) -gt 0 ]; then
104 + return 0
105 + fi
106 + go-sleep 100ms
107 + done
108 + return 1
109 }
110
111
@@ -114,271 +114,271 @@ test_wait_open_tcp_port_10_sec() {
114 # was setting really weird things and am not sure why.
115 test_config_set() {
116
117 - # grab flags (like --bool in "ipfs config --bool")
118 - test_cfg_flags="" # unset in case.
119 - test "$#" = 3 && { test_cfg_flags=$1; shift; }
117 + # grab flags (like --bool in "ipfs config --bool")
118 + test_cfg_flags="" # unset in case.
119 + test "$#" = 3 && { test_cfg_flags=$1; shift; }
120
121 - test_cfg_key=$1
122 - test_cfg_val=$2
121 + test_cfg_key=$1
122 + test_cfg_val=$2
123
124 - # when verbose, tell the user what config values are being set
125 - test_cfg_cmd="ipfs config $test_cfg_flags \"$test_cfg_key\" \"$test_cfg_val\""
126 - test "$TEST_VERBOSE" = 1 && echo "$test_cfg_cmd"
124 + # when verbose, tell the user what config values are being set
125 + test_cfg_cmd="ipfs config $test_cfg_flags \"$test_cfg_key\" \"$test_cfg_val\""
126 + test "$TEST_VERBOSE" = 1 && echo "$test_cfg_cmd"
127
128 - # ok try setting the config key/val pair.
129 - ipfs config $test_cfg_flags "$test_cfg_key" "$test_cfg_val"
130 - echo "$test_cfg_val" >cfg_set_expected
131 - ipfs config "$test_cfg_key" >cfg_set_actual
132 - test_cmp cfg_set_expected cfg_set_actual
128 + # ok try setting the config key/val pair.
129 + ipfs config $test_cfg_flags "$test_cfg_key" "$test_cfg_val"
130 + echo "$test_cfg_val" >cfg_set_expected
131 + ipfs config "$test_cfg_key" >cfg_set_actual
132 + test_cmp cfg_set_expected cfg_set_actual
133 }
134
135 test_init_ipfs() {
136
137
138 - # we set the Addresses.API config variable.
139 - # the cli client knows to use it, so only need to set.
140 - # todo: in the future, use env?
138 + # we set the Addresses.API config variable.
139 + # the cli client knows to use it, so only need to set.
140 + # todo: in the future, use env?
141
142 - test_expect_success "ipfs init succeeds" '
143 - export IPFS_PATH="$(pwd)/.ipfs" &&
144 - ipfs init --profile=test -b=1024 > /dev/null
145 - '
142 + test_expect_success "ipfs init succeeds" '
143 + export IPFS_PATH="$(pwd)/.ipfs" &&
144 + ipfs init --profile=test -b=1024 > /dev/null
145 + '
146
147 - test_expect_success "prepare config -- mounting" '
148 - mkdir mountdir ipfs ipns &&
149 - test_config_set Mounts.IPFS "$(pwd)/ipfs" &&
150 - test_config_set Mounts.IPNS "$(pwd)/ipns" ||
151 - test_fsh cat "\"$IPFS_PATH/config\""
152 - '
147 + test_expect_success "prepare config -- mounting" '
148 + mkdir mountdir ipfs ipns &&
149 + test_config_set Mounts.IPFS "$(pwd)/ipfs" &&
150 + test_config_set Mounts.IPNS "$(pwd)/ipns" ||
151 + test_fsh cat "\"$IPFS_PATH/config\""
152 + '
153
154 }
155
156 test_config_ipfs_gateway_writable() {
157 - test_expect_success "prepare config -- gateway writable" '
158 - test_config_set --bool Gateway.Writable true ||
159 - test_fsh cat "\"$IPFS_PATH/config\""
160 - '
157 + test_expect_success "prepare config -- gateway writable" '
158 + test_config_set --bool Gateway.Writable true ||
159 + test_fsh cat "\"$IPFS_PATH/config\""
160 + '
161 }
162
163 test_wait_for_file() {
164 - loops=$1
165 - delay=$2
166 - file=$3
167 - fwaitc=0
168 - while ! test -f "$file"
169 - do
170 - if test $fwaitc -ge $loops
171 - then
172 - echo "Error: timed out waiting for file: $file"
173 - return 1
174 - fi
175 -
176 - go-sleep $delay
177 - fwaitc=`expr $fwaitc + 1`
178 - done
164 + loops=$1
165 + delay=$2
166 + file=$3
167 + fwaitc=0
168 + while ! test -f "$file"
169 + do
170 + if test $fwaitc -ge $loops
171 + then
172 + echo "Error: timed out waiting for file: $file"
173 + return 1
174 + fi
175 +
176 + go-sleep $delay
177 + fwaitc=`expr $fwaitc + 1`
178 + done
179 }
180
181 test_set_address_vars() {
182 - daemon_output="$1"
183 -
184 - test_expect_success "set up address variables" '
185 - API_MADDR=$(cat "$IPFS_PATH/api") &&
186 - API_ADDR=$(convert_tcp_maddr $API_MADDR) &&
187 - API_PORT=$(port_from_maddr $API_MADDR) &&
188 -
189 - GWAY_MADDR=$(sed -n "s/^Gateway (.*) server listening on //p" "$daemon_output") &&
190 - GWAY_ADDR=$(convert_tcp_maddr $GWAY_MADDR) &&
191 - GWAY_PORT=$(port_from_maddr $GWAY_MADDR)
192 - '
193 -
194 - if ipfs swarm addrs local >/dev/null 2>&1; then
195 - test_expect_success "set swarm address vars" '
196 - ipfs swarm addrs local > addrs_out &&
197 - SWARM_MADDR=$(grep "127.0.0.1" addrs_out) &&
198 - SWARM_PORT=$(port_from_maddr $SWARM_MADDR)
199 - '
200 - fi
182 + daemon_output="$1"
183 +
184 + test_expect_success "set up address variables" '
185 + API_MADDR=$(cat "$IPFS_PATH/api") &&
186 + API_ADDR=$(convert_tcp_maddr $API_MADDR) &&
187 + API_PORT=$(port_from_maddr $API_MADDR) &&
188 +
189 + GWAY_MADDR=$(sed -n "s/^Gateway (.*) server listening on //p" "$daemon_output") &&
190 + GWAY_ADDR=$(convert_tcp_maddr $GWAY_MADDR) &&
191 + GWAY_PORT=$(port_from_maddr $GWAY_MADDR)
192 + '
193 +
194 + if ipfs swarm addrs local >/dev/null 2>&1; then
195 + test_expect_success "set swarm address vars" '
196 + ipfs swarm addrs local > addrs_out &&
197 + SWARM_MADDR=$(grep "127.0.0.1" addrs_out) &&
198 + SWARM_PORT=$(port_from_maddr $SWARM_MADDR)
199 + '
200 + fi
201 }
202
203 test_launch_ipfs_daemon() {
204
205 - args="$@"
205 + args="$@"
206
207 - test "$TEST_ULIMIT_PRESET" != 1 && ulimit -n 2048
207 + test "$TEST_ULIMIT_PRESET" != 1 && ulimit -n 2048
208
209 - test_expect_success "'ipfs daemon' succeeds" '
210 - ipfs daemon $args >actual_daemon 2>daemon_err &
211 - '
209 + test_expect_success "'ipfs daemon' succeeds" '
210 + ipfs daemon $args >actual_daemon 2>daemon_err &
211 + '
212
213 - # wait for api file to show up
214 - test_expect_success "api file shows up" '
215 - test_wait_for_file 20 100ms "$IPFS_PATH/api"
216 - '
213 + # wait for api file to show up
214 + test_expect_success "api file shows up" '
215 + test_wait_for_file 20 100ms "$IPFS_PATH/api"
216 + '
217
218 - test_set_address_vars actual_daemon
218 + test_set_address_vars actual_daemon
219
220 - # we say the daemon is ready when the API server is ready.
221 - test_expect_success "'ipfs daemon' is ready" '
222 - IPFS_PID=$! &&
223 - pollEndpoint -ep=/version -host=$API_MADDR -v -tout=1s -tries=60 2>poll_apierr > poll_apiout ||
224 - test_fsh cat actual_daemon || test_fsh cat daemon_err || test_fsh cat poll_apierr || test_fsh cat poll_apiout
225 - '
220 + # we say the daemon is ready when the API server is ready.
221 + test_expect_success "'ipfs daemon' is ready" '
222 + IPFS_PID=$! &&
223 + pollEndpoint -ep=/version -host=$API_MADDR -v -tout=1s -tries=60 2>poll_apierr > poll_apiout ||
224 + test_fsh cat actual_daemon || test_fsh cat daemon_err || test_fsh cat poll_apierr || test_fsh cat poll_apiout
225 + '
226 }
227
228 do_umount() {
229 - if [ "$(uname -s)" = "Linux" ]; then
230 - fusermount -u "$1"
231 - else
232 - umount "$1"
233 - fi
229 + if [ "$(uname -s)" = "Linux" ]; then
230 + fusermount -u "$1"
231 + else
232 + umount "$1"
233 + fi
234 }
235
236 test_mount_ipfs() {
237
238 - # make sure stuff is unmounted first.
239 - test_expect_success FUSE "'ipfs mount' succeeds" '
240 - do_umount "$(pwd)/ipfs" || true &&
241 - do_umount "$(pwd)/ipns" || true &&
242 - ipfs mount >actual
243 - '
238 + # make sure stuff is unmounted first.
239 + test_expect_success FUSE "'ipfs mount' succeeds" '
240 + do_umount "$(pwd)/ipfs" || true &&
241 + do_umount "$(pwd)/ipns" || true &&
242 + ipfs mount >actual
243 + '
244
245 - test_expect_success FUSE "'ipfs mount' output looks good" '
246 - echo "IPFS mounted at: $(pwd)/ipfs" >expected &&
247 - echo "IPNS mounted at: $(pwd)/ipns" >>expected &&
248 - test_cmp expected actual
249 - '
245 + test_expect_success FUSE "'ipfs mount' output looks good" '
246 + echo "IPFS mounted at: $(pwd)/ipfs" >expected &&
247 + echo "IPNS mounted at: $(pwd)/ipns" >>expected &&
248 + test_cmp expected actual
249 + '
250
251 }
252
253 test_launch_ipfs_daemon_and_mount() {
254
255 - test_init_ipfs
256 - test_launch_ipfs_daemon
257 - test_mount_ipfs
255 + test_init_ipfs
256 + test_launch_ipfs_daemon
257 + test_mount_ipfs
258
259 }
260
261 test_kill_repeat_10_sec() {
262 - # try to shut down once + wait for graceful exit
263 - kill $1
264 - for i in $(test_seq 1 100)
265 - do
266 - go-sleep 100ms
267 - ! kill -0 $1 2>/dev/null && return
268 - done
269 -
270 - # if not, try once more, which will skip graceful exit
271 - kill $1
272 - go-sleep 1s
273 - ! kill -0 $1 2>/dev/null && return
274 -
275 - # ok, no hope. kill it to prevent it messing with other tests
276 - kill -9 $1 2>/dev/null
277 - return 1
262 + # try to shut down once + wait for graceful exit
263 + kill $1
264 + for i in $(test_seq 1 100)
265 + do
266 + go-sleep 100ms
267 + ! kill -0 $1 2>/dev/null && return
268 + done
269 +
270 + # if not, try once more, which will skip graceful exit
271 + kill $1
272 + go-sleep 1s
273 + ! kill -0 $1 2>/dev/null && return
274 +
275 + # ok, no hope. kill it to prevent it messing with other tests
276 + kill -9 $1 2>/dev/null
277 + return 1
278 }
279
280 test_kill_ipfs_daemon() {
281
282 - test_expect_success "'ipfs daemon' is still running" '
283 - kill -0 $IPFS_PID
284 - '
282 + test_expect_success "'ipfs daemon' is still running" '
283 + kill -0 $IPFS_PID
284 + '
285
286 - test_expect_success "'ipfs daemon' can be killed" '
287 - test_kill_repeat_10_sec $IPFS_PID
288 - '
286 + test_expect_success "'ipfs daemon' can be killed" '
287 + test_kill_repeat_10_sec $IPFS_PID
288 + '
289 }
290
291 test_curl_resp_http_code() {
292 - curl -I "$1" >curl_output || {
293 - echo "curl error with url: '$1'"
294 - echo "curl output was:"
295 - cat curl_output
296 - return 1
297 - }
298 - shift &&
299 - RESP=$(head -1 curl_output) &&
300 - while test "$#" -gt 0
301 - do
302 - expr "$RESP" : "$1" >/dev/null && return
303 - shift
304 - done
305 - echo "curl response didn't match!"
306 - echo "curl response was: '$RESP'"
307 - echo "curl output was:"
308 - cat curl_output
309 - return 1
292 + curl -I "$1" >curl_output || {
293 + echo "curl error with url: '$1'"
294 + echo "curl output was:"
295 + cat curl_output
296 + return 1
297 + }
298 + shift &&
299 + RESP=$(head -1 curl_output) &&
300 + while test "$#" -gt 0
301 + do
302 + expr "$RESP" : "$1" >/dev/null && return
303 + shift
304 + done
305 + echo "curl response didn't match!"
306 + echo "curl response was: '$RESP'"
307 + echo "curl output was:"
308 + cat curl_output
309 + return 1
310 }
311
312 test_must_be_empty() {
313 - if test -s "$1"
314 - then
315 - echo "'$1' is not empty, it contains:"
316 - cat "$1"
317 - return 1
318 - fi
313 + if test -s "$1"
314 + then
315 + echo "'$1' is not empty, it contains:"
316 + cat "$1"
317 + return 1
318 + fi
319 }
320
321 test_should_contain() {
322 - test "$#" = 2 || error "bug in the test script: not 2 parameters to test_should_contain"
323 - if ! grep -q "$1" "$2"
324 - then
325 - echo "'$2' does not contain '$1', it contains:"
326 - cat "$2"
327 - return 1
328 - fi
322 + test "$#" = 2 || error "bug in the test script: not 2 parameters to test_should_contain"
323 + if ! grep -q "$1" "$2"
324 + then
325 + echo "'$2' does not contain '$1', it contains:"
326 + cat "$2"
327 + return 1
328 + fi
329 }
330
331 test_str_contains() {
332 - find=$1
333 - shift
334 - echo "$@" | egrep "\b$find\b" >/dev/null
332 + find=$1
333 + shift
334 + echo "$@" | egrep "\b$find\b" >/dev/null
335 }
336
337 disk_usage() {
338 - # normalize du across systems
339 - case $(uname -s) in
340 - Linux)
341 - DU="du -sb"
342 - M=1
343 - ;;
344 - FreeBSD)
345 - DU="du -s -A -B 1"
346 - M=512
347 - ;;
348 - Darwin | DragonFly | *)
349 - DU="du -s"
350 - M=512
351 - ;;
352 - esac
353 - expr $($DU "$1" | awk "{print \$1}") "*" "$M"
338 + # normalize du across systems
339 + case $(uname -s) in
340 + Linux)
341 + DU="du -sb"
342 + M=1
343 + ;;
344 + FreeBSD)
345 + DU="du -s -A -B 1"
346 + M=512
347 + ;;
348 + Darwin | DragonFly | *)
349 + DU="du -s"
350 + M=512
351 + ;;
352 + esac
353 + expr $($DU "$1" | awk "{print \$1}") "*" "$M"
354 }
355
356 # output a file's permission in human readable format
357 generic_stat() {
358 - # normalize stat across systems
359 - case $(uname -s) in
360 - Linux)
361 - _STAT="stat -c %A"
362 - ;;
363 - FreeBSD | Darwin | DragonFly)
364 - _STAT="stat -f %Sp"
365 - ;;
366 - esac
367 - $_STAT "$1" || echo "failed" # Avoid returning nothing.
358 + # normalize stat across systems
359 + case $(uname -s) in
360 + Linux)
361 + _STAT="stat -c %A"
362 + ;;
363 + FreeBSD | Darwin | DragonFly)
364 + _STAT="stat -f %Sp"
365 + ;;
366 + esac
367 + $_STAT "$1" || echo "failed" # Avoid returning nothing.
368 }
369
370 test_check_peerid() {
371 - peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") &&
372 - test "$peeridlen" = "46" || {
373 - echo "Bad peerid '$1' with len '$peeridlen'"
374 - return 1
375 - }
371 + peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") &&
372 + test "$peeridlen" = "46" || {
373 + echo "Bad peerid '$1' with len '$peeridlen'"
374 + return 1
375 + }
376 }
377
378 convert_tcp_maddr() {
379 - echo $1 | awk -F'/' '{ printf "%s:%s", $3, $5 }'
379 + echo $1 | awk -F'/' '{ printf "%s:%s", $3, $5 }'
380 }
381
382 port_from_maddr() {
383 - echo $1 | awk -F'/' '{ print $NF }'
383 + echo $1 | awk -F'/' '{ print $NF }'
384 }
test/sharness/t0010-basic-commands.sh
+58 -58
@@ -9,107 +9,107 @@ test_description="Test installation and some basic commands"
9 . lib/test-lib.sh
10
11 test_expect_success "current dir is writable" '
12 - echo "It works!" >test.txt
12 + echo "It works!" >test.txt
13 '
14
15 test_expect_success "ipfs version succeeds" '
16 - ipfs version >version.txt
16 + ipfs version >version.txt
17 '
18
19 test_expect_success "ipfs --version success" '
20 - ipfs --version
20 + ipfs --version
21 '
22
23 test_expect_success "ipfs version output looks good" '
24 - egrep "^ipfs version [0-9]+\.[0-9]+\.[0-9]" version.txt >/dev/null ||
25 - test_fsh cat version.txt
24 + egrep "^ipfs version [0-9]+\.[0-9]+\.[0-9]" version.txt >/dev/null ||
25 + test_fsh cat version.txt
26 '
27
28 test_expect_success "ipfs versions matches ipfs --version" '
29 - ipfs version > version.txt &&
30 - ipfs --version > version2.txt &&
31 - diff version2.txt version.txt ||
32 - test_fsh ipfs --version
29 + ipfs version > version.txt &&
30 + ipfs --version > version2.txt &&
31 + diff version2.txt version.txt ||
32 + test_fsh ipfs --version
33
34 '
35
36 test_expect_success "ipfs version --all has all required fields" '
37 - ipfs version --all > version_all.txt &&
38 - grep "go-ipfs version" version_all.txt &&
39 - grep "Repo version" version_all.txt &&
40 - grep "System version" version_all.txt &&
41 - grep "Golang version" version_all.txt
37 + ipfs version --all > version_all.txt &&
38 + grep "go-ipfs version" version_all.txt &&
39 + grep "Repo version" version_all.txt &&
40 + grep "System version" version_all.txt &&
41 + grep "Golang version" version_all.txt
42 '
43
44 test_expect_success "ipfs help succeeds" '
45 - ipfs help >help.txt
45 + ipfs help >help.txt
46 '
47
48 test_expect_success "ipfs help output looks good" '
49 - egrep -i "^Usage" help.txt >/dev/null &&
50 - egrep "ipfs <command>" help.txt >/dev/null ||
51 - test_fsh cat help.txt
49 + egrep -i "^Usage" help.txt >/dev/null &&
50 + egrep "ipfs <command>" help.txt >/dev/null ||
51 + test_fsh cat help.txt
52 '
53
54 test_expect_success "'ipfs commands' succeeds" '
55 - ipfs commands >commands.txt
55 + ipfs commands >commands.txt
56 '
57
58 test_expect_success "'ipfs commands' output looks good" '
59 - grep "ipfs add" commands.txt &&
60 - grep "ipfs daemon" commands.txt &&
61 - grep "ipfs update" commands.txt
59 + grep "ipfs add" commands.txt &&
60 + grep "ipfs daemon" commands.txt &&
61 + grep "ipfs update" commands.txt
62 '
63
64 test_expect_success "All commands accept --help" '
65 - echo 0 > fail
66 - while read -r cmd
67 - do
68 - $cmd --help </dev/null >/dev/null ||
69 - { echo $cmd doesnt accept --help; echo 1 > fail; }
70 - done <commands.txt
71 -
72 - if [ $(cat fail) = 1 ]; then
73 - return 1
74 - fi
65 + echo 0 > fail
66 + while read -r cmd
67 + do
68 + $cmd --help </dev/null >/dev/null ||
69 + { echo $cmd doesnt accept --help; echo 1 > fail; }
70 + done <commands.txt
71 +
72 + if [ $(cat fail) = 1 ]; then
73 + return 1
74 + fi
75 '
76
77 test_expect_failure "All ipfs root commands are mentioned in base helptext" '
78 - echo 0 > fail
79 - cut -d" " -f 2 commands.txt | grep -v ipfs | sort -u | \
80 - while read cmd
81 - do
82 - grep " $cmd" help.txt > /dev/null ||
83 - { echo missing $cmd from helptext; echo 1 > fail; }
84 - done
85 -
86 - if [ $(cat fail) = 1 ]; then
87 - return 1
88 - fi
78 + echo 0 > fail
79 + cut -d" " -f 2 commands.txt | grep -v ipfs | sort -u | \
80 + while read cmd
81 + do
82 + grep " $cmd" help.txt > /dev/null ||
83 + { echo missing $cmd from helptext; echo 1 > fail; }
84 + done
85 +
86 + if [ $(cat fail) = 1 ]; then
87 + return 1
88 + fi
89 '
90
91 test_expect_failure "All ipfs commands docs are 80 columns or less" '
92 - echo 0 > fail
93 - while read cmd
94 - do
95 - LENGTH="$($cmd --help | awk "{ print length }" | sort -nr | head -1)"
96 - [ $LENGTH -gt 80 ] &&
97 - { echo "$cmd" help text is longer than 79 chars "($LENGTH)"; echo 1 > fail; }
98 - done <commands.txt
99 -
100 - if [ $(cat fail) = 1 ]; then
101 - return 1
102 - fi
92 + echo 0 > fail
93 + while read cmd
94 + do
95 + LENGTH="$($cmd --help | awk "{ print length }" | sort -nr | head -1)"
96 + [ $LENGTH -gt 80 ] &&
97 + { echo "$cmd" help text is longer than 79 chars "($LENGTH)"; echo 1 > fail; }
98 + done <commands.txt
99 +
100 + if [ $(cat fail) = 1 ]; then
101 + return 1
102 + fi
103 '
104
105 test_expect_success "'ipfs commands --flags' succeeds" '
106 - ipfs commands --flags >commands.txt
106 + ipfs commands --flags >commands.txt
107 '
108
109 test_expect_success "'ipfs commands --flags' output looks good" '
110 - grep "ipfs pin add --recursive / ipfs pin add -r" commands.txt &&
111 - grep "ipfs id --format / ipfs id -f" commands.txt &&
112 - grep "ipfs repo gc --quiet / ipfs repo gc -q" commands.txt
110 + grep "ipfs pin add --recursive / ipfs pin add -r" commands.txt &&
111 + grep "ipfs id --format / ipfs id -f" commands.txt &&
112 + grep "ipfs repo gc --quiet / ipfs repo gc -q" commands.txt
113 '
114
115
test/sharness/t0015-basic-sh-functions.sh
+12 -12
@@ -9,12 +9,12 @@ test_description="Test some basic shell functions"
9 . lib/test-lib.sh
10
11 test_expect_success "shellquote works with simple stuff" '
12 - var=$(shellquote one two)
12 + var=$(shellquote one two)
13 '
14
15 test_expect_success "shellquote output looks good" '
16 - test "$var" = "'\''one'\'' '\''two'\''" ||
17 - test_fsh echo "var is \"$var\" instead of \"'\''one'\'' '\''two'\''\""
16 + test "$var" = "'\''one'\'' '\''two'\''" ||
17 + test_fsh echo "var is \"$var\" instead of \"'\''one'\'' '\''two'\''\""
18 '
19
20 # The following two printf statements are equivalent:
@@ -24,24 +24,24 @@ test_expect_success "shellquote output looks good" '
24 # We use the second one to simplify quoting.
25
26 test_expect_success "shellquote works with complex printf" '
27 - eval "$(shellquote printf "\047\042\146\157\157\134\012\142\141\162\012")" >actual
27 + eval "$(shellquote printf "\047\042\146\157\157\134\012\142\141\162\012")" >actual
28 '
29
30 test_expect_success "shellquote output looks good" '
31 - printf "\047\042\146\157\157\134\012\142\141\162\012" >expected &&
32 - test_cmp expected actual
31 + printf "\047\042\146\157\157\134\012\142\141\162\012" >expected &&
32 + test_cmp expected actual
33 '
34
35 test_expect_success "shellquote works with many different bytes" '
36 - bytes_sans_NUL=$(
37 - printf "\001\002\003\004\005\006\007\010\011\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044%%\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377"
38 - ) &&
39 - eval "$(shellquote printf "%s" "$bytes_sans_NUL")" >actual
36 + bytes_sans_NUL=$(
37 + printf "\001\002\003\004\005\006\007\010\011\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044%%\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377"
38 + ) &&
39 + eval "$(shellquote printf "%s" "$bytes_sans_NUL")" >actual
40 '
41
42 test_expect_success "shellquote output looks good" '
43 - printf "%s" "$bytes_sans_NUL" >expected &&
44 - test_cmp expected actual
43 + printf "%s" "$bytes_sans_NUL" >expected &&
44 + test_cmp expected actual
45 '
46
47 test_done
test/sharness/t0018-indent.sh
+3 -3
@@ -5,9 +5,9 @@ test_description="Test sharness test indent"
5 . lib/test-lib.sh
6
7 for file in $(find .. -name 't*.sh' -type f); do
8 - test_expect_success "indent in $file is not using spaces" '
9 - test_must_fail grep -P "^\\t* " $file
10 - '
8 + test_expect_success "indent in $file is not using tabs" '
9 + test_must_fail grep -P "^ *\t" $file
10 + '
11 done
12
13 test_done
test/sharness/t0020-init.sh
+70 -70
@@ -10,161 +10,161 @@ test_description="Test init command"
10
11 # test that ipfs fails to init if IPFS_PATH isnt writeable
12 test_expect_success "create dir and change perms succeeds" '
13 - export IPFS_PATH="$(pwd)/.badipfs" &&
14 - mkdir "$IPFS_PATH" &&
15 - chmod 000 "$IPFS_PATH"
13 + export IPFS_PATH="$(pwd)/.badipfs" &&
14 + mkdir "$IPFS_PATH" &&
15 + chmod 000 "$IPFS_PATH"
16 '
17
18 test_expect_success "ipfs init fails" '
19 - test_must_fail ipfs init 2> init_fail_out
19 + test_must_fail ipfs init 2> init_fail_out
20 '
21
22 # Under Windows/Cygwin the error message is different,
23 # so we use the STD_ERR_MSG prereq.
24 if test_have_prereq STD_ERR_MSG; then
25 - init_err_msg="Error: failed to take lock at $IPFS_PATH: permission denied"
25 + init_err_msg="Error: failed to take lock at $IPFS_PATH: permission denied"
26 else
27 - init_err_msg="Error: mkdir $IPFS_PATH: The system cannot find the path specified."
27 + init_err_msg="Error: mkdir $IPFS_PATH: The system cannot find the path specified."
28 fi
29
30 test_expect_success "ipfs init output looks good" '
31 - echo "$init_err_msg" >init_fail_exp &&
32 - test_cmp init_fail_exp init_fail_out
31 + echo "$init_err_msg" >init_fail_exp &&
32 + test_cmp init_fail_exp init_fail_out
33 '
34
35 test_expect_success "cleanup dir with bad perms" '
36 - chmod 775 "$IPFS_PATH" &&
37 - rmdir "$IPFS_PATH"
36 + chmod 775 "$IPFS_PATH" &&
37 + rmdir "$IPFS_PATH"
38 '
39
40 # test no repo error message
41 # this applies to `ipfs add sth`, `ipfs refs <hash>`
42 test_expect_success "ipfs cat fails" '
43 - export IPFS_PATH="$(pwd)/.ipfs" &&
44 - test_must_fail ipfs cat Qmaa4Rw81a3a1VEx4LxB7HADUAXvZFhCoRdBzsMZyZmqHD 2> cat_fail_out
43 + export IPFS_PATH="$(pwd)/.ipfs" &&
44 + test_must_fail ipfs cat Qmaa4Rw81a3a1VEx4LxB7HADUAXvZFhCoRdBzsMZyZmqHD 2> cat_fail_out
45 '
46
47 test_expect_success "ipfs cat no repo message looks good" '
48 - echo "Error: no IPFS repo found in $IPFS_PATH." > cat_fail_exp &&
49 - echo "please run: 'ipfs init'" >> cat_fail_exp &&
50 - test_path_cmp cat_fail_exp cat_fail_out
48 + echo "Error: no IPFS repo found in $IPFS_PATH." > cat_fail_exp &&
49 + echo "please run: 'ipfs init'" >> cat_fail_exp &&
50 + test_path_cmp cat_fail_exp cat_fail_out
51 '
52
53 # test that init succeeds
54 test_expect_success "ipfs init succeeds" '
55 - export IPFS_PATH="$(pwd)/.ipfs" &&
56 - echo "IPFS_PATH: \"$IPFS_PATH\"" &&
57 - BITS="2048" &&
58 - ipfs init --bits="$BITS" >actual_init ||
59 - test_fsh cat actual_init
55 + export IPFS_PATH="$(pwd)/.ipfs" &&
56 + echo "IPFS_PATH: \"$IPFS_PATH\"" &&
57 + BITS="2048" &&
58 + ipfs init --bits="$BITS" >actual_init ||
59 + test_fsh cat actual_init
60 '
61
62 test_expect_success ".ipfs/ has been created" '
63 - test -d ".ipfs" &&
64 - test -f ".ipfs/config" &&
65 - test -d ".ipfs/datastore" &&
66 - test -d ".ipfs/blocks" &&
67 - test ! -f ._check_writeable ||
68 - test_fsh ls -al .ipfs
63 + test -d ".ipfs" &&
64 + test -f ".ipfs/config" &&
65 + test -d ".ipfs/datastore" &&
66 + test -d ".ipfs/blocks" &&
67 + test ! -f ._check_writeable ||
68 + test_fsh ls -al .ipfs
69 '
70
71 test_expect_success "ipfs config succeeds" '
72 - echo /ipfs >expected_config &&
73 - ipfs config Mounts.IPFS >actual_config &&
74 - test_cmp expected_config actual_config
72 + echo /ipfs >expected_config &&
73 + ipfs config Mounts.IPFS >actual_config &&
74 + test_cmp expected_config actual_config
75 '
76
77 test_expect_success "ipfs peer id looks good" '
78 - PEERID=$(ipfs config Identity.PeerID) &&
79 - test_check_peerid "$PEERID"
78 + PEERID=$(ipfs config Identity.PeerID) &&
79 + test_check_peerid "$PEERID"
80 '
81
82 test_expect_success "ipfs init output looks good" '
83 - STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" &&
84 - echo "initializing IPFS node at $IPFS_PATH" >expected &&
85 - echo "generating $BITS-bit RSA keypair...done" >>expected &&
86 - echo "peer identity: $PEERID" >>expected &&
87 - echo "to get started, enter:" >>expected &&
88 - printf "\\n\\t$STARTFILE\\n\\n" >>expected &&
89 - test_cmp expected actual_init
83 + STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" &&
84 + echo "initializing IPFS node at $IPFS_PATH" >expected &&
85 + echo "generating $BITS-bit RSA keypair...done" >>expected &&
86 + echo "peer identity: $PEERID" >>expected &&
87 + echo "to get started, enter:" >>expected &&
88 + printf "\\n\\t$STARTFILE\\n\\n" >>expected &&
89 + test_cmp expected actual_init
90 '
91
92 test_expect_success "Welcome readme exists" '
93 - ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme
93 + ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme
94 '
95
96 test_expect_success "clean up ipfs dir" '
97 - rm -rf "$IPFS_PATH"
97 + rm -rf "$IPFS_PATH"
98 '
99
100 test_expect_success "'ipfs init --empty-repo' succeeds" '
101 - BITS="1024" &&
102 - ipfs init --bits="$BITS" --empty-repo >actual_init
101 + BITS="1024" &&
102 + ipfs init --bits="$BITS" --empty-repo >actual_init
103 '
104
105 test_expect_success "ipfs peer id looks good" '
106 - PEERID=$(ipfs config Identity.PeerID) &&
107 - test_check_peerid "$PEERID"
106 + PEERID=$(ipfs config Identity.PeerID) &&
107 + test_check_peerid "$PEERID"
108 '
109
110 test_expect_success "'ipfs init --empty-repo' output looks good" '
111 - echo "initializing IPFS node at $IPFS_PATH" >expected &&
112 - echo "generating $BITS-bit RSA keypair...done" >>expected &&
113 - echo "peer identity: $PEERID" >>expected &&
114 - test_cmp expected actual_init
111 + echo "initializing IPFS node at $IPFS_PATH" >expected &&
112 + echo "generating $BITS-bit RSA keypair...done" >>expected &&
113 + echo "peer identity: $PEERID" >>expected &&
114 + test_cmp expected actual_init
115 '
116
117 test_expect_success "Welcome readme doesn't exists" '
118 - test_must_fail ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme
118 + test_must_fail ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme
119 '
120
121 test_expect_success "ipfs id agent string contains correct version" '
122 - ipfs id -f "<aver>" | grep $(ipfs version -n)
122 + ipfs id -f "<aver>" | grep $(ipfs version -n)
123 '
124
125 test_expect_success "clean up ipfs dir" '
126 - rm -rf "$IPFS_PATH"
126 + rm -rf "$IPFS_PATH"
127 '
128
129 # test init profiles
130 test_expect_success "'ipfs init --profile' with invalid profile fails" '
131 - BITS="1024" &&
132 - test_must_fail ipfs init --bits="$BITS" --profile=nonexistent_profile 2> invalid_profile_out
133 - EXPECT="Error: invalid configuration profile: nonexistent_profile" &&
134 - grep "$EXPECT" invalid_profile_out
131 + BITS="1024" &&
132 + test_must_fail ipfs init --bits="$BITS" --profile=nonexistent_profile 2> invalid_profile_out
133 + EXPECT="Error: invalid configuration profile: nonexistent_profile" &&
134 + grep "$EXPECT" invalid_profile_out
135 '
136
137 test_expect_success "'ipfs init --profile' succeeds" '
138 - BITS="1024" &&
139 - ipfs init --bits="$BITS" --profile=server
138 + BITS="1024" &&
139 + ipfs init --bits="$BITS" --profile=server
140 '
141
142 test_expect_success "'ipfs config Swarm.AddrFilters' looks good" '
143 - ipfs config Swarm.AddrFilters > actual_config &&
144 - test $(cat actual_config | wc -l) = 17
143 + ipfs config Swarm.AddrFilters > actual_config &&
144 + test $(cat actual_config | wc -l) = 17
145 '
146
147 test_expect_success "clean up ipfs dir" '
148 - rm -rf "$IPFS_PATH"
148 + rm -rf "$IPFS_PATH"
149 '
150
151 test_expect_success "'ipfs init --profile=test' succeeds" '
152 - BITS="1024" &&
153 - ipfs init --bits="$BITS" --profile=test
152 + BITS="1024" &&
153 + ipfs init --bits="$BITS" --profile=test
154 '
155
156 test_expect_success "'ipfs config Bootstrap' looks good" '
157 - ipfs config Bootstrap > actual_config &&
158 - test $(cat actual_config) = "[]"
157 + ipfs config Bootstrap > actual_config &&
158 + test $(cat actual_config) = "[]"
159 '
160
161 test_expect_success "'ipfs config Addresses.API' looks good" '
162 - ipfs config Addresses.API > actual_config &&
163 - test $(cat actual_config) = "/ip4/127.0.0.1/tcp/0"
162 + ipfs config Addresses.API > actual_config &&
163 + test $(cat actual_config) = "/ip4/127.0.0.1/tcp/0"
164 '
165
166 test_expect_success "clean up ipfs dir" '
167 - rm -rf "$IPFS_PATH"
167 + rm -rf "$IPFS_PATH"
168 '
169
170 test_init_ipfs
@@ -172,9 +172,9 @@ test_init_ipfs
172 test_launch_ipfs_daemon
173
174 test_expect_success "ipfs init should not run while daemon is running" '
175 - test_must_fail ipfs init 2> daemon_running_err &&
176 - EXPECT="Error: ipfs daemon is running. please stop it to run this command" &&
177 - grep "$EXPECT" daemon_running_err
175 + test_must_fail ipfs init 2> daemon_running_err &&
176 + EXPECT="Error: ipfs daemon is running. please stop it to run this command" &&
177 + grep "$EXPECT" daemon_running_err
178 '
179
180 test_kill_ipfs_daemon
test/sharness/t0021-config.sh
+135 -135
@@ -7,33 +7,33 @@ test_description="Test config command"
7 # we use a function so that we can run it both offline + online
8 test_config_cmd_set() {
9
10 - # flags (like --bool in "ipfs config --bool")
11 - cfg_flags="" # unset in case.
12 - test "$#" = 3 && { cfg_flags=$1; shift; }
13 -
14 - cfg_key=$1
15 - cfg_val=$2
16 - test_expect_success "ipfs config succeeds" '
17 - ipfs config $cfg_flags "$cfg_key" "$cfg_val"
18 - '
19 -
20 - test_expect_success "ipfs config output looks good" '
21 - echo "$cfg_val" >expected &&
22 - ipfs config "$cfg_key" >actual &&
23 - test_cmp expected actual
24 - '
25 -
26 - # also test our lib function. it should work too.
27 - cfg_key="Lib.$cfg_key"
28 - test_expect_success "test_config_set succeeds" '
29 - test_config_set $cfg_flags "$cfg_key" "$cfg_val"
30 - '
31 -
32 - test_expect_success "test_config_set value looks good" '
33 - echo "$cfg_val" >expected &&
34 - ipfs config "$cfg_key" >actual &&
35 - test_cmp expected actual
36 - '
10 + # flags (like --bool in "ipfs config --bool")
11 + cfg_flags="" # unset in case.
12 + test "$#" = 3 && { cfg_flags=$1; shift; }
13 +
14 + cfg_key=$1
15 + cfg_val=$2
16 + test_expect_success "ipfs config succeeds" '
17 + ipfs config $cfg_flags "$cfg_key" "$cfg_val"
18 + '
19 +
20 + test_expect_success "ipfs config output looks good" '
21 + echo "$cfg_val" >expected &&
22 + ipfs config "$cfg_key" >actual &&
23 + test_cmp expected actual
24 + '
25 +
26 + # also test our lib function. it should work too.
27 + cfg_key="Lib.$cfg_key"
28 + test_expect_success "test_config_set succeeds" '
29 + test_config_set $cfg_flags "$cfg_key" "$cfg_val"
30 + '
31 +
32 + test_expect_success "test_config_set value looks good" '
33 + echo "$cfg_val" >expected &&
34 + ipfs config "$cfg_key" >actual &&
35 + test_cmp expected actual
36 + '
37 }
38
39 # this is a bit brittle. the problem is we need to test
@@ -41,116 +41,116 @@ test_config_cmd_set() {
41 # (i.e. just setting 'ipfs config --json foo "[1, 2, 3]"') may
42 # set it as astring instead of proper json. We leverage the
43 # unmarshalling that has to happen.
44 -CONFIG_SET_JSON_TEST=$(echo '{
45 - "MDNS": {
46 - "Enabled": true,
47 - "Interval": 10
48 - }
49 -}' | sed 's/\t/ /g')
44 +CONFIG_SET_JSON_TEST='{
45 + "MDNS": {
46 + "Enabled": true,
47 + "Interval": 10
48 + }
49 +}'
50
51 test_config_cmd() {
52 - test_config_cmd_set "beep" "boop"
53 - test_config_cmd_set "beep1" "boop2"
54 - test_config_cmd_set "beep1" "boop2"
55 - test_config_cmd_set "--bool" "beep2" "true"
56 - test_config_cmd_set "--bool" "beep2" "false"
57 - test_config_cmd_set "--json" "beep3" "true"
58 - test_config_cmd_set "--json" "beep3" "false"
59 - test_config_cmd_set "--json" "Discovery" "$CONFIG_SET_JSON_TEST"
60 - test_config_cmd_set "--json" "deep-not-defined.prop" "true"
61 - test_config_cmd_set "--json" "deep-null" "null"
62 - test_config_cmd_set "--json" "deep-null.prop" "true"
63 -
64 - test_expect_success "'ipfs config show' works" '
65 - ipfs config show >actual
66 - '
67 -
68 - test_expect_success "'ipfs config show' output looks good" '
69 - grep "\"beep\": \"boop\"," actual &&
70 - grep "\"beep1\": \"boop2\"," actual &&
71 - grep "\"beep2\": false," actual &&
72 - grep "\"beep3\": false," actual
73 - '
74 -
75 - test_expect_success "setup for config replace test" '
76 - cp "$IPFS_PATH/config" newconfig.json &&
77 - sed -i"~" -e /PrivKey/d -e s/10GB/11GB/ newconfig.json &&
78 - sed -i"~" -e '"'"'/PeerID/ {'"'"' -e '"'"' s/,$// '"'"' -e '"'"' } '"'"' newconfig.json
79 - '
80 -
81 - test_expect_success "run 'ipfs config replace'" '
82 - ipfs config replace - < newconfig.json
83 - '
84 -
85 - test_expect_success "check resulting config after 'ipfs config replace'" '
86 - sed -e /PrivKey/d "$IPFS_PATH/config" > replconfig.json &&
87 - sed -i"~" -e '"'"'/PeerID/ {'"'"' -e '"'"' s/,$// '"'"' -e '"'"' } '"'"' replconfig.json &&
88 - test_cmp replconfig.json newconfig.json
89 - '
90 -
91 - # SECURITY
92 - # Those tests are here to prevent exposing the PrivKey on the network
93 -
94 - test_expect_success "'ipfs config Identity' fails" '
95 - test_expect_code 1 ipfs config Identity 2> ident_out
96 - '
97 -
98 - test_expect_success "output looks good" '
99 - echo "Error: cannot show or change private key through API" > ident_exp &&
100 - test_cmp ident_exp ident_out
101 - '
102 -
103 - test_expect_success "'ipfs config Identity.PrivKey' fails" '
104 - test_expect_code 1 ipfs config Identity.PrivKey 2> ident_out
105 - '
106 -
107 - test_expect_success "output looks good" '
108 - test_cmp ident_exp ident_out
109 - '
110 -
111 - test_expect_success "lower cased PrivKey" '
112 - sed -i"~" -e '\''s/PrivKey/privkey/'\'' "$IPFS_PATH/config" &&
113 - test_expect_code 1 ipfs config Identity.privkey 2> ident_out
114 - '
115 -
116 - test_expect_success "output looks good" '
117 - test_cmp ident_exp ident_out
118 - '
119 -
120 - test_expect_success "fix it back" '
121 - sed -i"~" -e '\''s/privkey/PrivKey/'\'' "$IPFS_PATH/config"
122 - '
123 -
124 - test_expect_success "'ipfs config show' doesn't include privkey" '
125 - ipfs config show > show_config &&
126 - test_expect_code 1 grep PrivKey show_config
127 - '
128 -
129 - test_expect_success "'ipfs config replace' injects privkey back" '
130 - ipfs config replace show_config &&
131 - grep "\"PrivKey\":" "$IPFS_PATH/config" | grep -e ": \".\+\"" >/dev/null
132 - '
133 -
134 - test_expect_success "'ipfs config replace' with privkey errors out" '
135 - cp "$IPFS_PATH/config" real_config &&
136 - test_expect_code 1 ipfs config replace - < real_config 2> replace_out
137 - '
138 -
139 - test_expect_success "output looks good" '
140 - echo "Error: setting private key with API is not supported" > replace_expected
141 - test_cmp replace_out replace_expected
142 - '
143 -
144 - test_expect_success "'ipfs config replace' with lower case privkey errors out" '
145 - cp "$IPFS_PATH/config" real_config &&
146 - sed -i -e '\''s/PrivKey/privkey/'\'' real_config &&
147 - test_expect_code 1 ipfs config replace - < real_config 2> replace_out
148 - '
149 -
150 - test_expect_success "output looks good" '
151 - echo "Error: setting private key with API is not supported" > replace_expected
152 - test_cmp replace_out replace_expected
153 - '
52 + test_config_cmd_set "beep" "boop"
53 + test_config_cmd_set "beep1" "boop2"
54 + test_config_cmd_set "beep1" "boop2"
55 + test_config_cmd_set "--bool" "beep2" "true"
56 + test_config_cmd_set "--bool" "beep2" "false"
57 + test_config_cmd_set "--json" "beep3" "true"
58 + test_config_cmd_set "--json" "beep3" "false"
59 + test_config_cmd_set "--json" "Discovery" "$CONFIG_SET_JSON_TEST"
60 + test_config_cmd_set "--json" "deep-not-defined.prop" "true"
61 + test_config_cmd_set "--json" "deep-null" "null"
62 + test_config_cmd_set "--json" "deep-null.prop" "true"
63 +
64 + test_expect_success "'ipfs config show' works" '
65 + ipfs config show >actual
66 + '
67 +
68 + test_expect_success "'ipfs config show' output looks good" '
69 + grep "\"beep\": \"boop\"," actual &&
70 + grep "\"beep1\": \"boop2\"," actual &&
71 + grep "\"beep2\": false," actual &&
72 + grep "\"beep3\": false," actual
73 + '
74 +
75 + test_expect_success "setup for config replace test" '
76 + cp "$IPFS_PATH/config" newconfig.json &&
77 + sed -i"~" -e /PrivKey/d -e s/10GB/11GB/ newconfig.json &&
78 + sed -i"~" -e '"'"'/PeerID/ {'"'"' -e '"'"' s/,$// '"'"' -e '"'"' } '"'"' newconfig.json
79 + '
80 +
81 + test_expect_success "run 'ipfs config replace'" '
82 + ipfs config replace - < newconfig.json
83 + '
84 +
85 + test_expect_success "check resulting config after 'ipfs config replace'" '
86 + sed -e /PrivKey/d "$IPFS_PATH/config" > replconfig.json &&
87 + sed -i"~" -e '"'"'/PeerID/ {'"'"' -e '"'"' s/,$// '"'"' -e '"'"' } '"'"' replconfig.json &&
88 + test_cmp replconfig.json newconfig.json
89 + '
90 +
91 + # SECURITY
92 + # Those tests are here to prevent exposing the PrivKey on the network
93 +
94 + test_expect_success "'ipfs config Identity' fails" '
95 + test_expect_code 1 ipfs config Identity 2> ident_out
96 + '
97 +
98 + test_expect_success "output looks good" '
99 + echo "Error: cannot show or change private key through API" > ident_exp &&
100 + test_cmp ident_exp ident_out
101 + '
102 +
103 + test_expect_success "'ipfs config Identity.PrivKey' fails" '
104 + test_expect_code 1 ipfs config Identity.PrivKey 2> ident_out
105 + '
106 +
107 + test_expect_success "output looks good" '
108 + test_cmp ident_exp ident_out
109 + '
110 +
111 + test_expect_success "lower cased PrivKey" '
112 + sed -i"~" -e '\''s/PrivKey/privkey/'\'' "$IPFS_PATH/config" &&
113 + test_expect_code 1 ipfs config Identity.privkey 2> ident_out
114 + '
115 +
116 + test_expect_success "output looks good" '
117 + test_cmp ident_exp ident_out
118 + '
119 +
120 + test_expect_success "fix it back" '
121 + sed -i"~" -e '\''s/privkey/PrivKey/'\'' "$IPFS_PATH/config"
122 + '
123 +
124 + test_expect_success "'ipfs config show' doesn't include privkey" '
125 + ipfs config show > show_config &&
126 + test_expect_code 1 grep PrivKey show_config
127 + '
128 +
129 + test_expect_success "'ipfs config replace' injects privkey back" '
130 + ipfs config replace show_config &&
131 + grep "\"PrivKey\":" "$IPFS_PATH/config" | grep -e ": \".\+\"" >/dev/null
132 + '
133 +
134 + test_expect_success "'ipfs config replace' with privkey errors out" '
135 + cp "$IPFS_PATH/config" real_config &&
136 + test_expect_code 1 ipfs config replace - < real_config 2> replace_out
137 + '
138 +
139 + test_expect_success "output looks good" '
140 + echo "Error: setting private key with API is not supported" > replace_expected
141 + test_cmp replace_out replace_expected
142 + '
143 +
144 + test_expect_success "'ipfs config replace' with lower case privkey errors out" '
145 + cp "$IPFS_PATH/config" real_config &&
146 + sed -i -e '\''s/PrivKey/privkey/'\'' real_config &&
147 + test_expect_code 1 ipfs config replace - < real_config 2> replace_out
148 + '
149 +
150 + test_expect_success "output looks good" '
151 + echo "Error: setting private key with API is not supported" > replace_expected
152 + test_cmp replace_out replace_expected
153 + '
154 }
155
156 test_init_ipfs
test/sharness/t0022-init-default.sh
+15 -15
@@ -13,39 +13,39 @@ cfg_val="/ip4/0.0.0.0/tcp/5001"
13
14 # test that init succeeds
15 test_expect_success "ipfs init succeeds" '
16 - export IPFS_PATH="$(pwd)/.ipfs" &&
17 - echo "IPFS_PATH: \"$IPFS_PATH\"" &&
18 - BITS="2048" &&
19 - ipfs init --bits="$BITS" >actual_init ||
20 - test_fsh cat actual_init
16 + export IPFS_PATH="$(pwd)/.ipfs" &&
17 + echo "IPFS_PATH: \"$IPFS_PATH\"" &&
18 + BITS="2048" &&
19 + ipfs init --bits="$BITS" >actual_init ||
20 + test_fsh cat actual_init
21 '
22
23 test_expect_success ".ipfs/config has been created" '
24 - test -f "$IPFS_PATH"/config ||
25 - test_fsh ls -al .ipfs
24 + test -f "$IPFS_PATH"/config ||
25 + test_fsh ls -al .ipfs
26 '
27
28 test_expect_success "ipfs config succeeds" '
29 - ipfs config $cfg_flags "$cfg_key" "$cfg_val"
29 + ipfs config $cfg_flags "$cfg_key" "$cfg_val"
30 '
31
32 test_expect_success "ipfs read config succeeds" '
33 - IPFS_DEFAULT_CONFIG=$(cat "$IPFS_PATH"/config)
33 + IPFS_DEFAULT_CONFIG=$(cat "$IPFS_PATH"/config)
34 '
35
36 test_expect_success "clean up ipfs dir" '
37 - rm -rf "$IPFS_PATH"
37 + rm -rf "$IPFS_PATH"
38 '
39
40 test_expect_success "ipfs init default config succeeds" '
41 - echo $IPFS_DEFAULT_CONFIG | ipfs init - >actual_init ||
42 - test_fsh cat actual_init
41 + echo $IPFS_DEFAULT_CONFIG | ipfs init - >actual_init ||
42 + test_fsh cat actual_init
43 '
44
45 test_expect_success "ipfs config output looks good" '
46 - echo "$cfg_val" >expected &&
47 - ipfs config "$cfg_key" >actual &&
48 - test_cmp expected actual
46 + echo "$cfg_val" >expected &&
47 + ipfs config "$cfg_key" >actual &&
48 + test_cmp expected actual
49 '
50
51 test_done
test/sharness/t0023-shutdown.sh
+12 -12
@@ -13,28 +13,28 @@ test_init_ipfs
13 test_launch_ipfs_daemon
14
15 test_expect_success "shutdown succeeds" '
16 - ipfs shutdown
16 + ipfs shutdown
17 '
18
19 test_expect_success "daemon no longer running" '
20 - for i in $(test_seq 1 100)
21 - do
22 - go-sleep 100ms
23 - ! kill -0 $IPFS_PID 2>/dev/null && return
24 - done
20 + for i in $(test_seq 1 100)
21 + do
22 + go-sleep 100ms
23 + ! kill -0 $IPFS_PID 2>/dev/null && return
24 + done
25 '
26
27 test_launch_ipfs_daemon --offline
28
29 test_expect_success "shutdown succeeds" '
30 - ipfs shutdown
30 + ipfs shutdown
31 '
32
33 test_expect_success "daemon no longer running" '
34 - for i in $(test_seq 1 100)
35 - do
36 - go-sleep 100ms
37 - ! kill -0 $IPFS_PID 2>/dev/null && return
38 - done
34 + for i in $(test_seq 1 100)
35 + do
36 + go-sleep 100ms
37 + ! kill -0 $IPFS_PID 2>/dev/null && return
38 + done
39 '
40 test_done
test/sharness/t0024-datastore-config.sh
+3 -3
@@ -14,18 +14,18 @@ SPEC_NOSYNC=$(cat ../t0024-files/spec-nosync)
14 SPEC_NEWSHARDFUN=$(cat ../t0024-files/spec-newshardfun)
15
16 test_expect_success "change runtime value in spec config" '
17 - ipfs config --json Datastore.Spec "$SPEC_NOSYNC"
17 + ipfs config --json Datastore.Spec "$SPEC_NOSYNC"
18 '
19
20 test_launch_ipfs_daemon
21 test_kill_ipfs_daemon
22
23 test_expect_success "change on-disk value in spec config" '
24 - ipfs config --json Datastore.Spec "$SPEC_NEWSHARDFUN"
24 + ipfs config --json Datastore.Spec "$SPEC_NEWSHARDFUN"
25 '
26
27 test_expect_success "can not launch daemon after on-disk value change" '
28 - test_must_fail ipfs daemon
28 + test_must_fail ipfs daemon
29 '
30
31 test_done
test/sharness/t0030-mount.sh
+20 -20
@@ -10,64 +10,64 @@ test_description="Test mount command"
10
11 # if in travis CI, dont test mount (no fuse)
12 if ! test_have_prereq FUSE; then
13 - skip_all='skipping mount tests, fuse not available'
13 + skip_all='skipping mount tests, fuse not available'
14
15 - test_done
15 + test_done
16 fi
17
18 # start iptb + wait for peering
19 NUM_NODES=5
20 test_expect_success 'init iptb' '
21 - iptb init -n $NUM_NODES --bootstrap=none --port=0
21 + iptb init -n $NUM_NODES --bootstrap=none --port=0
22 '
23 startup_cluster $NUM_NODES
24
25
26 # test mount failure before mounting properly.
27 test_expect_success "'ipfs mount' fails when there is no mount dir" '
28 - tmp_ipfs_mount() { ipfsi 0 mount -f=not_ipfs -n=not_ipns >output 2>output.err; } &&
29 - test_must_fail tmp_ipfs_mount
28 + tmp_ipfs_mount() { ipfsi 0 mount -f=not_ipfs -n=not_ipns >output 2>output.err; } &&
29 + test_must_fail tmp_ipfs_mount
30 '
31
32 test_expect_success "'ipfs mount' output looks good" '
33 - test_must_be_empty output &&
34 - test_should_contain "not_ipns\|not_ipfs" output.err
33 + test_must_be_empty output &&
34 + test_should_contain "not_ipns\|not_ipfs" output.err
35 '
36
37 test_expect_success "setup and publish default IPNS value" '
38 - mkdir "$(pwd)/ipfs" "$(pwd)/ipns" &&
39 - ipfsi 0 name publish QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn
38 + mkdir "$(pwd)/ipfs" "$(pwd)/ipns" &&
39 + ipfsi 0 name publish QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn
40 '
41
42 # make sure stuff is unmounted first
43 # then mount properly
44 test_expect_success FUSE "'ipfs mount' succeeds" '
45 - do_umount "$(pwd)/ipfs" || true &&
46 - do_umount "$(pwd)/ipns" || true &&
47 - ipfsi 0 mount -f "$(pwd)/ipfs" -n "$(pwd)/ipns" >actual
45 + do_umount "$(pwd)/ipfs" || true &&
46 + do_umount "$(pwd)/ipns" || true &&
47 + ipfsi 0 mount -f "$(pwd)/ipfs" -n "$(pwd)/ipns" >actual
48 '
49
50 test_expect_success FUSE "'ipfs mount' output looks good" '
51 - echo "IPFS mounted at: $(pwd)/ipfs" >expected &&
52 - echo "IPNS mounted at: $(pwd)/ipns" >>expected &&
53 - test_cmp expected actual
51 + echo "IPFS mounted at: $(pwd)/ipfs" >expected &&
52 + echo "IPNS mounted at: $(pwd)/ipns" >>expected &&
53 + test_cmp expected actual
54 '
55
56 test_expect_success "mount directories cannot be removed while active" '
57 - test_must_fail rmdir ipfs ipns 2>/dev/null
57 + test_must_fail rmdir ipfs ipns 2>/dev/null
58 '
59
60 test_expect_success "unmount directories" '
61 - do_umount "$(pwd)/ipfs" &&
62 - do_umount "$(pwd)/ipns"
61 + do_umount "$(pwd)/ipfs" &&
62 + do_umount "$(pwd)/ipns"
63 '
64
65 test_expect_success "mount directories can be removed after shutdown" '
66 - rmdir ipfs ipns
66 + rmdir ipfs ipns
67 '
68
69 test_expect_success 'stop iptb' '
70 - iptb stop
70 + iptb stop
71 '
72
73 test_done
test/sharness/t0031-mount-publish.sh
+15 -15
@@ -7,9 +7,9 @@ test_description="Test mount command in conjunction with publishing"
7
8 # if in travis CI, dont test mount (no fuse)
9 if ! test_have_prereq FUSE; then
10 - skip_all='skipping mount tests, fuse not available'
10 + skip_all='skipping mount tests, fuse not available'
11
12 - test_done
12 + test_done
13 fi
14
15 test_init_ipfs
@@ -17,45 +17,45 @@ test_init_ipfs
17 # start iptb + wait for peering
18 NUM_NODES=3
19 test_expect_success 'init iptb' '
20 - iptb init -n $NUM_NODES -f --bootstrap=none --port=0 &&
21 - startup_cluster $NUM_NODES
20 + iptb init -n $NUM_NODES -f --bootstrap=none --port=0 &&
21 + startup_cluster $NUM_NODES
22 '
23
24 # pre-mount publish
25 HASH=$(echo 'hello warld' | ipfsi 0 add -q)
26 test_expect_success "can publish before mounting /ipns" '
27 - ipfsi 0 name publish '$HASH'
27 + ipfsi 0 name publish '$HASH'
28 '
29
30 # mount
31 IPFS_MOUNT_DIR="$PWD/ipfs"
32 IPNS_MOUNT_DIR="$PWD/ipns"
33 test_expect_success FUSE "'ipfs mount' succeeds" '
34 - ipfsi 0 mount -f "'"$IPFS_MOUNT_DIR"'" -n "'"$IPNS_MOUNT_DIR"'" >actual
34 + ipfsi 0 mount -f "'"$IPFS_MOUNT_DIR"'" -n "'"$IPNS_MOUNT_DIR"'" >actual
35 '
36 test_expect_success FUSE "'ipfs mount' output looks good" '
37 - echo "IPFS mounted at: $PWD/ipfs" >expected &&
38 - echo "IPNS mounted at: $PWD/ipns" >>expected &&
39 - test_cmp expected actual
37 + echo "IPFS mounted at: $PWD/ipfs" >expected &&
38 + echo "IPNS mounted at: $PWD/ipns" >>expected &&
39 + test_cmp expected actual
40 '
41
42 test_expect_success "cannot publish after mounting /ipns" '
43 - echo "Error: cannot manually publish while IPNS is mounted" >expected &&
44 - test_must_fail ipfsi 0 name publish '$HASH' 2>actual &&
45 - test_cmp expected actual
43 + echo "Error: cannot manually publish while IPNS is mounted" >expected &&
44 + test_must_fail ipfsi 0 name publish '$HASH' 2>actual &&
45 + test_cmp expected actual
46 '
47
48 test_expect_success "unmount /ipns out-of-band" '
49 - fusermount -u "'"$IPNS_MOUNT_DIR"'"
49 + fusermount -u "'"$IPNS_MOUNT_DIR"'"
50 '
51
52 test_expect_success "can publish after unmounting /ipns" '
53 - ipfsi 0 name publish '$HASH'
53 + ipfsi 0 name publish '$HASH'
54 '
55
56 # clean-up ipfs
57 test_expect_success "unmount /ipfs" '
58 - fusermount -u "'"$IPFS_MOUNT_DIR"'"
58 + fusermount -u "'"$IPFS_MOUNT_DIR"'"
59 '
60 iptb stop
61
test/sharness/t0040-add-and-cat.sh
+317 -317
@@ -9,380 +9,380 @@ test_description="Test add and cat commands"
9 . lib/test-lib.sh
10
11 test_add_cat_file() {
12 - test_expect_success "ipfs add --help works" '
13 - ipfs add --help 2> add_help_err > /dev/null
14 - '
15 -
16 - test_expect_success "stdin reading message doesnt show up" '
17 - test_expect_code 1 grep "ipfs: Reading from" add_help_err &&
18 - test_expect_code 1 grep "send Ctrl-d to stop." add_help_err
19 - '
20 -
21 - test_expect_success "ipfs add succeeds" '
22 - echo "Hello Worlds!" >mountdir/hello.txt &&
23 - ipfs add mountdir/hello.txt >actual
24 - '
25 -
26 - test_expect_success "ipfs add output looks good" '
27 - HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
28 - echo "added $HASH hello.txt" >expected &&
29 - test_cmp expected actual
30 - '
31 -
32 - test_expect_success "ipfs add --only-hash succeeds" '
33 - ipfs add --only-hash mountdir/hello.txt > oh_actual
34 - '
35 -
36 - test_expect_success "ipfs add --only-hash output looks good" '
37 - test_cmp expected oh_actual
38 - '
39 -
40 - test_expect_success "ipfs cat succeeds" '
41 - ipfs cat "$HASH" >actual
42 - '
43 -
44 - test_expect_success "ipfs cat output looks good" '
45 - echo "Hello Worlds!" >expected &&
46 - test_cmp expected actual
47 - '
48 -
49 - test_expect_success "ipfs cat /ipfs/file succeeds" '
50 - ipfs cat /ipfs/$HASH >actual
51 - '
52 -
53 - test_expect_success "output looks good" '
54 - test_cmp expected actual
55 - '
56 -
57 - test_expect_success "ipfs add -t succeeds" '
58 - ipfs add -t mountdir/hello.txt >actual
59 - '
60 -
61 - test_expect_success "ipfs add -t output looks good" '
62 - HASH="QmUkUQgxXeggyaD5Ckv8ZqfW8wHBX6cYyeiyqvVZYzq5Bi" &&
63 - echo "added $HASH hello.txt" >expected &&
64 - test_cmp expected actual
65 - '
66 -
67 - test_expect_success "ipfs add --chunker size-32 succeeds" '
68 - ipfs add --chunker rabin mountdir/hello.txt >actual
69 - '
70 -
71 - test_expect_success "ipfs add --chunker size-32 output looks good" '
72 - HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
73 - echo "added $HASH hello.txt" >expected &&
74 - test_cmp expected actual
75 - '
76 -
77 - test_expect_success "ipfs add on hidden file succeeds" '
78 - echo "Hello Worlds!" >mountdir/.hello.txt &&
79 - ipfs add mountdir/.hello.txt >actual
80 - '
81 -
82 - test_expect_success "ipfs add on hidden file output looks good" '
83 - HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
84 - echo "added $HASH .hello.txt" >expected &&
85 - test_cmp expected actual
86 - '
12 + test_expect_success "ipfs add --help works" '
13 + ipfs add --help 2> add_help_err > /dev/null
14 + '
15 +
16 + test_expect_success "stdin reading message doesnt show up" '
17 + test_expect_code 1 grep "ipfs: Reading from" add_help_err &&
18 + test_expect_code 1 grep "send Ctrl-d to stop." add_help_err
19 + '
20 +
21 + test_expect_success "ipfs add succeeds" '
22 + echo "Hello Worlds!" >mountdir/hello.txt &&
23 + ipfs add mountdir/hello.txt >actual
24 + '
25 +
26 + test_expect_success "ipfs add output looks good" '
27 + HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
28 + echo "added $HASH hello.txt" >expected &&
29 + test_cmp expected actual
30 + '
31 +
32 + test_expect_success "ipfs add --only-hash succeeds" '
33 + ipfs add --only-hash mountdir/hello.txt > oh_actual
34 + '
35 +
36 + test_expect_success "ipfs add --only-hash output looks good" '
37 + test_cmp expected oh_actual
38 + '
39 +
40 + test_expect_success "ipfs cat succeeds" '
41 + ipfs cat "$HASH" >actual
42 + '
43 +
44 + test_expect_success "ipfs cat output looks good" '
45 + echo "Hello Worlds!" >expected &&
46 + test_cmp expected actual
47 + '
48 +
49 + test_expect_success "ipfs cat /ipfs/file succeeds" '
50 + ipfs cat /ipfs/$HASH >actual
51 + '
52 +
53 + test_expect_success "output looks good" '
54 + test_cmp expected actual
55 + '
56 +
57 + test_expect_success "ipfs add -t succeeds" '
58 + ipfs add -t mountdir/hello.txt >actual
59 + '
60 +
61 + test_expect_success "ipfs add -t output looks good" '
62 + HASH="QmUkUQgxXeggyaD5Ckv8ZqfW8wHBX6cYyeiyqvVZYzq5Bi" &&
63 + echo "added $HASH hello.txt" >expected &&
64 + test_cmp expected actual
65 + '
66 +
67 + test_expect_success "ipfs add --chunker size-32 succeeds" '
68 + ipfs add --chunker rabin mountdir/hello.txt >actual
69 + '
70 +
71 + test_expect_success "ipfs add --chunker size-32 output looks good" '
72 + HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
73 + echo "added $HASH hello.txt" >expected &&
74 + test_cmp expected actual
75 + '
76 +
77 + test_expect_success "ipfs add on hidden file succeeds" '
78 + echo "Hello Worlds!" >mountdir/.hello.txt &&
79 + ipfs add mountdir/.hello.txt >actual
80 + '
81 +
82 + test_expect_success "ipfs add on hidden file output looks good" '
83 + HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
84 + echo "added $HASH .hello.txt" >expected &&
85 + test_cmp expected actual
86 + '
87 }
88
89 test_add_cat_5MB() {
90 - ADD_FLAGS="$1"
91 - EXP_HASH="$2"
92 -
93 - test_expect_success "generate 5MB file using go-random" '
94 - random 5242880 41 >mountdir/bigfile
95 - '
96 -
97 - test_expect_success "sha1 of the file looks ok" '
98 - echo "11145620fb92eb5a49c9986b5c6844efda37e471660e" >sha1_expected &&
99 - multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
100 - test_cmp sha1_expected sha1_actual
101 - '
102 -
103 - test_expect_success "'ipfs add $ADD_FLAGS bigfile' succeeds" '
104 - ipfs add $ADD_FLAGS mountdir/bigfile >actual ||
105 - test_fsh cat daemon_err
106 - '
107 -
108 - test_expect_success "'ipfs add bigfile' output looks good" '
109 - echo "added $EXP_HASH bigfile" >expected &&
110 - test_cmp expected actual
111 - '
112 - test_expect_success "'ipfs cat' succeeds" '
113 - ipfs cat "$EXP_HASH" >actual
114 - '
115 -
116 - test_expect_success "'ipfs cat' output looks good" '
117 - test_cmp mountdir/bigfile actual
118 - '
119 -
120 - test_expect_success FUSE "cat ipfs/bigfile succeeds" '
121 - cat "ipfs/$EXP_HASH" >actual
122 - '
123 -
124 - test_expect_success FUSE "cat ipfs/bigfile looks good" '
125 - test_cmp mountdir/bigfile actual
126 - '
90 + ADD_FLAGS="$1"
91 + EXP_HASH="$2"
92 +
93 + test_expect_success "generate 5MB file using go-random" '
94 + random 5242880 41 >mountdir/bigfile
95 + '
96 +
97 + test_expect_success "sha1 of the file looks ok" '
98 + echo "11145620fb92eb5a49c9986b5c6844efda37e471660e" >sha1_expected &&
99 + multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
100 + test_cmp sha1_expected sha1_actual
101 + '
102 +
103 + test_expect_success "'ipfs add $ADD_FLAGS bigfile' succeeds" '
104 + ipfs add $ADD_FLAGS mountdir/bigfile >actual ||
105 + test_fsh cat daemon_err
106 + '
107 +
108 + test_expect_success "'ipfs add bigfile' output looks good" '
109 + echo "added $EXP_HASH bigfile" >expected &&
110 + test_cmp expected actual
111 + '
112 + test_expect_success "'ipfs cat' succeeds" '
113 + ipfs cat "$EXP_HASH" >actual
114 + '
115 +
116 + test_expect_success "'ipfs cat' output looks good" '
117 + test_cmp mountdir/bigfile actual
118 + '
119 +
120 + test_expect_success FUSE "cat ipfs/bigfile succeeds" '
121 + cat "ipfs/$EXP_HASH" >actual
122 + '
123 +
124 + test_expect_success FUSE "cat ipfs/bigfile looks good" '
125 + test_cmp mountdir/bigfile actual
126 + '
127 }
128
129 test_add_cat_raw() {
130 - test_expect_success "add a small file with raw-leaves" '
131 - echo "foobar" > afile &&
132 - HASH=$(ipfs add -q --raw-leaves afile)
133 - '
134 -
135 - test_expect_success "cat that small file" '
136 - ipfs cat $HASH > afile_out
137 - '
138 -
139 - test_expect_success "make sure it looks good" '
140 - test_cmp afile afile_out
141 - '
130 + test_expect_success "add a small file with raw-leaves" '
131 + echo "foobar" > afile &&
132 + HASH=$(ipfs add -q --raw-leaves afile)
133 + '
134 +
135 + test_expect_success "cat that small file" '
136 + ipfs cat $HASH > afile_out
137 + '
138 +
139 + test_expect_success "make sure it looks good" '
140 + test_cmp afile afile_out
141 + '
142 }
143
144 test_add_cat_expensive() {
145 - ADD_FLAGS="$1"
146 - HASH="$2"
147 -
148 - test_expect_success EXPENSIVE "generate 100MB file using go-random" '
149 - random 104857600 42 >mountdir/bigfile
150 - '
151 -
152 - test_expect_success EXPENSIVE "sha1 of the file looks ok" '
153 - echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
154 - multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
155 - test_cmp sha1_expected sha1_actual
156 - '
157 -
158 - test_expect_success EXPENSIVE "ipfs add $ADD_FLAGS bigfile succeeds" '
159 - ipfs add $ADD_FLAGS mountdir/bigfile >actual
160 - '
161 -
162 - test_expect_success EXPENSIVE "ipfs add bigfile output looks good" '
163 - echo "added $HASH bigfile" >expected &&
164 - test_cmp expected actual
165 - '
166 -
167 - test_expect_success EXPENSIVE "ipfs cat succeeds" '
168 - ipfs cat "$HASH" | multihash -a=sha1 -e=hex >sha1_actual
169 - '
170 -
171 - test_expect_success EXPENSIVE "ipfs cat output looks good" '
172 - ipfs cat "$HASH" >actual &&
173 - test_cmp mountdir/bigfile actual
174 - '
175 -
176 - test_expect_success EXPENSIVE "ipfs cat output hashed looks good" '
177 - echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
178 - test_cmp sha1_expected sha1_actual
179 - '
180 -
181 - test_expect_success FUSE,EXPENSIVE "cat ipfs/bigfile succeeds" '
182 - cat "ipfs/$HASH" | multihash -a=sha1 -e=hex >sha1_actual
183 - '
184 -
185 - test_expect_success FUSE,EXPENSIVE "cat ipfs/bigfile looks good" '
186 - test_cmp sha1_expected sha1_actual
187 - '
145 + ADD_FLAGS="$1"
146 + HASH="$2"
147 +
148 + test_expect_success EXPENSIVE "generate 100MB file using go-random" '
149 + random 104857600 42 >mountdir/bigfile
150 + '
151 +
152 + test_expect_success EXPENSIVE "sha1 of the file looks ok" '
153 + echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
154 + multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
155 + test_cmp sha1_expected sha1_actual
156 + '
157 +
158 + test_expect_success EXPENSIVE "ipfs add $ADD_FLAGS bigfile succeeds" '
159 + ipfs add $ADD_FLAGS mountdir/bigfile >actual
160 + '
161 +
162 + test_expect_success EXPENSIVE "ipfs add bigfile output looks good" '
163 + echo "added $HASH bigfile" >expected &&
164 + test_cmp expected actual
165 + '
166 +
167 + test_expect_success EXPENSIVE "ipfs cat succeeds" '
168 + ipfs cat "$HASH" | multihash -a=sha1 -e=hex >sha1_actual
169 + '
170 +
171 + test_expect_success EXPENSIVE "ipfs cat output looks good" '
172 + ipfs cat "$HASH" >actual &&
173 + test_cmp mountdir/bigfile actual
174 + '
175 +
176 + test_expect_success EXPENSIVE "ipfs cat output hashed looks good" '
177 + echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
178 + test_cmp sha1_expected sha1_actual
179 + '
180 +
181 + test_expect_success FUSE,EXPENSIVE "cat ipfs/bigfile succeeds" '
182 + cat "ipfs/$HASH" | multihash -a=sha1 -e=hex >sha1_actual
183 + '
184 +
185 + test_expect_success FUSE,EXPENSIVE "cat ipfs/bigfile looks good" '
186 + test_cmp sha1_expected sha1_actual
187 + '
188 }
189
190 test_add_named_pipe() {
191 - err_prefix=$1
192 - test_expect_success "useful error message when adding a named pipe" '
193 - mkfifo named-pipe &&
194 - test_expect_code 1 ipfs add named-pipe 2>actual &&
195 - STAT=$(generic_stat named-pipe) &&
196 - rm named-pipe &&
197 - grep "Error: Unrecognized file type for named-pipe: $STAT" actual &&
198 - grep USAGE actual &&
199 - grep "ipfs add" actual
200 - '
201 -
202 - test_expect_success "useful error message when recursively adding a named pipe" '
203 - mkdir -p named-pipe-dir &&
204 - mkfifo named-pipe-dir/named-pipe &&
205 - STAT=$(generic_stat named-pipe-dir/named-pipe) &&
206 - test_expect_code 1 ipfs add -r named-pipe-dir 2>actual &&
207 - printf "Error:$err_prefix Unrecognized file type for named-pipe-dir/named-pipe: $STAT\n" >expected &&
208 - rm named-pipe-dir/named-pipe &&
209 - rmdir named-pipe-dir &&
210 - test_cmp expected actual
211 - '
191 + err_prefix=$1
192 + test_expect_success "useful error message when adding a named pipe" '
193 + mkfifo named-pipe &&
194 + test_expect_code 1 ipfs add named-pipe 2>actual &&
195 + STAT=$(generic_stat named-pipe) &&
196 + rm named-pipe &&
197 + grep "Error: Unrecognized file type for named-pipe: $STAT" actual &&
198 + grep USAGE actual &&
199 + grep "ipfs add" actual
200 + '
201 +
202 + test_expect_success "useful error message when recursively adding a named pipe" '
203 + mkdir -p named-pipe-dir &&
204 + mkfifo named-pipe-dir/named-pipe &&
205 + STAT=$(generic_stat named-pipe-dir/named-pipe) &&
206 + test_expect_code 1 ipfs add -r named-pipe-dir 2>actual &&
207 + printf "Error:$err_prefix Unrecognized file type for named-pipe-dir/named-pipe: $STAT\n" >expected &&
208 + rm named-pipe-dir/named-pipe &&
209 + rmdir named-pipe-dir &&
210 + test_cmp expected actual
211 + '
212 }
213
214 test_add_pwd_is_symlink() {
215 - test_expect_success "ipfs add -r adds directory content when ./ is symlink" '
216 - mkdir hellodir &&
217 - echo "World" > hellodir/world &&
218 - ln -s hellodir hellolink &&
219 - ( cd hellolink &&
220 - ipfs add -r . > ../actual ) &&
221 - grep "added Qma9CyFdG5ffrZCcYSin2uAETygB25cswVwEYYzwfQuhTe" actual &&
222 - rm -r hellodir
223 - '
215 + test_expect_success "ipfs add -r adds directory content when ./ is symlink" '
216 + mkdir hellodir &&
217 + echo "World" > hellodir/world &&
218 + ln -s hellodir hellolink &&
219 + ( cd hellolink &&
220 + ipfs add -r . > ../actual ) &&
221 + grep "added Qma9CyFdG5ffrZCcYSin2uAETygB25cswVwEYYzwfQuhTe" actual &&
222 + rm -r hellodir
223 + '
224 }
225
226 test_launch_ipfs_daemon_and_mount
227
228 test_expect_success "'ipfs add --help' succeeds" '
229 - ipfs add --help >actual
229 + ipfs add --help >actual
230 '
231
232 test_expect_success "'ipfs add --help' output looks good" '
233 - egrep "ipfs add.*<path>" actual >/dev/null ||
234 - test_fsh cat actual
233 + egrep "ipfs add.*<path>" actual >/dev/null ||
234 + test_fsh cat actual
235 '
236
237 test_expect_success "'ipfs cat --help' succeeds" '
238 - ipfs cat --help >actual
238 + ipfs cat --help >actual
239 '
240
241 test_expect_success "'ipfs cat --help' output looks good" '
242 - egrep "ipfs cat.*<ipfs-path>" actual >/dev/null ||
243 - test_fsh cat actual
242 + egrep "ipfs cat.*<ipfs-path>" actual >/dev/null ||
243 + test_fsh cat actual
244 '
245
246 test_add_cat_file
247
248 test_expect_success "ipfs cat succeeds with stdin opened (issue #1141)" '
249 - cat mountdir/hello.txt | while read line; do ipfs cat "$HASH" >actual || exit; done
249 + cat mountdir/hello.txt | while read line; do ipfs cat "$HASH" >actual || exit; done
250 '
251
252 test_expect_success "ipfs cat output looks good" '
253 - cat mountdir/hello.txt >expected &&
254 - test_cmp expected actual
253 + cat mountdir/hello.txt >expected &&
254 + test_cmp expected actual
255 '
256
257 test_expect_success "ipfs cat accept hash from built input" '
258 - echo "$HASH" | ipfs cat >actual
258 + echo "$HASH" | ipfs cat >actual
259 '
260
261 test_expect_success "ipfs cat output looks good" '
262 - test_cmp expected actual
262 + test_cmp expected actual
263 '
264
265 test_expect_success FUSE "cat ipfs/stuff succeeds" '
266 - cat "ipfs/$HASH" >actual
266 + cat "ipfs/$HASH" >actual
267 '
268
269 test_expect_success FUSE "cat ipfs/stuff looks good" '
270 - test_cmp expected actual
270 + test_cmp expected actual
271 '
272
273 test_expect_success "'ipfs add -q' succeeds" '
274 - echo "Hello Venus!" >mountdir/venus.txt &&
275 - ipfs add -q mountdir/venus.txt >actual
274 + echo "Hello Venus!" >mountdir/venus.txt &&
275 + ipfs add -q mountdir/venus.txt >actual
276 '
277
278 test_expect_success "'ipfs add -q' output looks good" '
279 - HASH="QmU5kp3BH3B8tnWUU2Pikdb2maksBNkb92FHRr56hyghh4" &&
280 - echo "$HASH" >expected &&
281 - test_cmp expected actual
279 + HASH="QmU5kp3BH3B8tnWUU2Pikdb2maksBNkb92FHRr56hyghh4" &&
280 + echo "$HASH" >expected &&
281 + test_cmp expected actual
282 '
283
284 test_expect_success "'ipfs add -q' with stdin input succeeds" '
285 - echo "Hello Jupiter!" | ipfs add -q >actual
285 + echo "Hello Jupiter!" | ipfs add -q >actual
286 '
287
288 test_expect_success "'ipfs add -q' output looks good" '
289 - HASH="QmUnvPcBctVTAcJpigv6KMqDvmDewksPWrNVoy1E1WP5fh" &&
290 - echo "$HASH" >expected &&
291 - test_cmp expected actual
289 + HASH="QmUnvPcBctVTAcJpigv6KMqDvmDewksPWrNVoy1E1WP5fh" &&
290 + echo "$HASH" >expected &&
291 + test_cmp expected actual
292 '
293
294 test_expect_success "'ipfs cat' succeeds" '
295 - ipfs cat "$HASH" >actual
295 + ipfs cat "$HASH" >actual
296 '
297
298 test_expect_success "ipfs cat output looks good" '
299 - echo "Hello Jupiter!" >expected &&
300 - test_cmp expected actual
299 + echo "Hello Jupiter!" >expected &&
300 + test_cmp expected actual
301 '
302
303 test_expect_success "'ipfs add' with stdin input succeeds" '
304 - printf "Hello Neptune!\nHello Pluton!" | ipfs add >actual
304 + printf "Hello Neptune!\nHello Pluton!" | ipfs add >actual
305 '
306
307 test_expect_success "'ipfs add' output looks good" '
308 - HASH="QmZDhWpi8NvKrekaYYhxKCdNVGWsFFe1CREnAjP1QbPaB3" &&
309 - echo "added $HASH $HASH" >expected &&
310 - test_cmp expected actual
308 + HASH="QmZDhWpi8NvKrekaYYhxKCdNVGWsFFe1CREnAjP1QbPaB3" &&
309 + echo "added $HASH $HASH" >expected &&
310 + test_cmp expected actual
311 '
312
313 test_expect_success "'ipfs cat' with built input succeeds" '
314 - echo "$HASH" | ipfs cat >actual
314 + echo "$HASH" | ipfs cat >actual
315 '
316
317 test_expect_success "ipfs cat with built input output looks good" '
318 - printf "Hello Neptune!\nHello Pluton!" >expected &&
319 - test_cmp expected actual
318 + printf "Hello Neptune!\nHello Pluton!" >expected &&
319 + test_cmp expected actual
320 '
321
322 add_directory() {
323 - EXTRA_ARGS=$1
324 -
325 - test_expect_success "'ipfs add -r $EXTRA_ARGS' succeeds" '
326 - mkdir mountdir/planets &&
327 - echo "Hello Mars!" >mountdir/planets/mars.txt &&
328 - echo "Hello Venus!" >mountdir/planets/venus.txt &&
329 - ipfs add -r $EXTRA_ARGS mountdir/planets >actual
330 - '
331 -
332 - test_expect_success "'ipfs add -r $EXTRA_ARGS' output looks good" '
333 - echo "added $MARS planets/mars.txt" >expected &&
334 - echo "added $VENUS planets/venus.txt" >>expected &&
335 - echo "added $PLANETS planets" >>expected &&
336 - test_cmp expected actual
337 - '
338 -
339 - test_expect_success "ipfs cat accept many hashes from built input" '
340 - { echo "$MARS"; echo "$VENUS"; } | ipfs cat >actual
341 - '
342 -
343 - test_expect_success "ipfs cat output looks good" '
344 - cat mountdir/planets/mars.txt mountdir/planets/venus.txt >expected &&
345 - test_cmp expected actual
346 - '
347 -
348 - test_expect_success "ipfs cat accept many hashes as args" '
349 - ipfs cat "$MARS" "$VENUS" >actual
350 - '
351 -
352 - test_expect_success "ipfs cat output looks good" '
353 - test_cmp expected actual
354 - '
355 -
356 - test_expect_success "ipfs cat with both arg and stdin" '
357 - echo "$MARS" | ipfs cat "$VENUS" >actual
358 - '
359 -
360 - test_expect_success "ipfs cat output looks good" '
361 - cat mountdir/planets/venus.txt >expected &&
362 - test_cmp expected actual
363 - '
364 -
365 - test_expect_success "ipfs cat with two args and stdin" '
366 - echo "$MARS" | ipfs cat "$VENUS" "$VENUS" >actual
367 - '
368 -
369 - test_expect_success "ipfs cat output looks good" '
370 - cat mountdir/planets/venus.txt mountdir/planets/venus.txt >expected &&
371 - test_cmp expected actual
372 - '
373 -
374 - test_expect_success "ipfs add --quieter succeeds" '
375 - ipfs add -r -Q $EXTRA_ARGS mountdir/planets >actual
376 - '
377 -
378 - test_expect_success "ipfs add --quieter returns only one correct hash" '
379 - echo "$PLANETS" > expected &&
380 - test_cmp expected actual
381 - '
382 -
383 - test_expect_success "cleanup" '
384 - rm -r mountdir/planets
385 - '
323 + EXTRA_ARGS=$1
324 +
325 + test_expect_success "'ipfs add -r $EXTRA_ARGS' succeeds" '
326 + mkdir mountdir/planets &&
327 + echo "Hello Mars!" >mountdir/planets/mars.txt &&
328 + echo "Hello Venus!" >mountdir/planets/venus.txt &&
329 + ipfs add -r $EXTRA_ARGS mountdir/planets >actual
330 + '
331 +
332 + test_expect_success "'ipfs add -r $EXTRA_ARGS' output looks good" '
333 + echo "added $MARS planets/mars.txt" >expected &&
334 + echo "added $VENUS planets/venus.txt" >>expected &&
335 + echo "added $PLANETS planets" >>expected &&
336 + test_cmp expected actual
337 + '
338 +
339 + test_expect_success "ipfs cat accept many hashes from built input" '
340 + { echo "$MARS"; echo "$VENUS"; } | ipfs cat >actual
341 + '
342 +
343 + test_expect_success "ipfs cat output looks good" '
344 + cat mountdir/planets/mars.txt mountdir/planets/venus.txt >expected &&
345 + test_cmp expected actual
346 + '
347 +
348 + test_expect_success "ipfs cat accept many hashes as args" '
349 + ipfs cat "$MARS" "$VENUS" >actual
350 + '
351 +
352 + test_expect_success "ipfs cat output looks good" '
353 + test_cmp expected actual
354 + '
355 +
356 + test_expect_success "ipfs cat with both arg and stdin" '
357 + echo "$MARS" | ipfs cat "$VENUS" >actual
358 + '
359 +
360 + test_expect_success "ipfs cat output looks good" '
361 + cat mountdir/planets/venus.txt >expected &&
362 + test_cmp expected actual
363 + '
364 +
365 + test_expect_success "ipfs cat with two args and stdin" '
366 + echo "$MARS" | ipfs cat "$VENUS" "$VENUS" >actual
367 + '
368 +
369 + test_expect_success "ipfs cat output looks good" '
370 + cat mountdir/planets/venus.txt mountdir/planets/venus.txt >expected &&
371 + test_cmp expected actual
372 + '
373 +
374 + test_expect_success "ipfs add --quieter succeeds" '
375 + ipfs add -r -Q $EXTRA_ARGS mountdir/planets >actual
376 + '
377 +
378 + test_expect_success "ipfs add --quieter returns only one correct hash" '
379 + echo "$PLANETS" > expected &&
380 + test_cmp expected actual
381 + '
382 +
383 + test_expect_success "cleanup" '
384 + rm -r mountdir/planets
385 + '
386 }
387
388 PLANETS="QmWSgS32xQEcXMeqd3YPJLrNBLSdsfYCep2U7CFkyrjXwY"
@@ -411,32 +411,32 @@ VENUS="zCT5htke5JcdoMM4WhmUKXWf2QC3TnQToqGZHH1WsZERv6kPhFPg"
411 add_directory '--hash=blake2b-256'
412
413 test_expect_success "'ipfs add -rn' succeeds" '
414 - mkdir -p mountdir/moons/jupiter &&
415 - mkdir -p mountdir/moons/saturn &&
416 - echo "Hello Europa!" >mountdir/moons/jupiter/europa.txt &&
417 - echo "Hello Titan!" >mountdir/moons/saturn/titan.txt &&
418 - echo "hey youre no moon!" >mountdir/moons/mercury.txt &&
419 - ipfs add -rn mountdir/moons >actual
414 + mkdir -p mountdir/moons/jupiter &&
415 + mkdir -p mountdir/moons/saturn &&
416 + echo "Hello Europa!" >mountdir/moons/jupiter/europa.txt &&
417 + echo "Hello Titan!" >mountdir/moons/saturn/titan.txt &&
418 + echo "hey youre no moon!" >mountdir/moons/mercury.txt &&
419 + ipfs add -rn mountdir/moons >actual
420 '
421
422 test_expect_success "'ipfs add -rn' output looks good" '
423 - MOONS="QmVKvomp91nMih5j6hYBA8KjbiaYvEetU2Q7KvtZkLe9nQ" &&
424 - EUROPA="Qmbjg7zWdqdMaK2BucPncJQDxiALExph5k3NkQv5RHpccu" &&
425 - JUPITER="QmS5mZddhFPLWFX3w6FzAy9QxyYkaxvUpsWCtZ3r7jub9J" &&
426 - SATURN="QmaMagZT4rTE7Nonw8KGSK4oe1bh533yhZrCo1HihSG8FK" &&
427 - TITAN="QmZzppb9WHn552rmRqpPfgU5FEiHH6gDwi3MrB9cTdPwdb" &&
428 - MERCURY="QmUJjVtnN8YEeYcS8VmUeWffTWhnMQAkk5DzZdKnPhqUdK" &&
429 - echo "added $EUROPA moons/jupiter/europa.txt" >expected &&
430 - echo "added $MERCURY moons/mercury.txt" >>expected &&
431 - echo "added $TITAN moons/saturn/titan.txt" >>expected &&
432 - echo "added $JUPITER moons/jupiter" >>expected &&
433 - echo "added $SATURN moons/saturn" >>expected &&
434 - echo "added $MOONS moons" >>expected &&
435 - test_cmp expected actual
423 + MOONS="QmVKvomp91nMih5j6hYBA8KjbiaYvEetU2Q7KvtZkLe9nQ" &&
424 + EUROPA="Qmbjg7zWdqdMaK2BucPncJQDxiALExph5k3NkQv5RHpccu" &&
425 + JUPITER="QmS5mZddhFPLWFX3w6FzAy9QxyYkaxvUpsWCtZ3r7jub9J" &&
426 + SATURN="QmaMagZT4rTE7Nonw8KGSK4oe1bh533yhZrCo1HihSG8FK" &&
427 + TITAN="QmZzppb9WHn552rmRqpPfgU5FEiHH6gDwi3MrB9cTdPwdb" &&
428 + MERCURY="QmUJjVtnN8YEeYcS8VmUeWffTWhnMQAkk5DzZdKnPhqUdK" &&
429 + echo "added $EUROPA moons/jupiter/europa.txt" >expected &&
430 + echo "added $MERCURY moons/mercury.txt" >>expected &&
431 + echo "added $TITAN moons/saturn/titan.txt" >>expected &&
432 + echo "added $JUPITER moons/jupiter" >>expected &&
433 + echo "added $SATURN moons/saturn" >>expected &&
434 + echo "added $MOONS moons" >>expected &&
435 + test_cmp expected actual
436 '
437
438 test_expect_success "go-random is installed" '
439 - type random
439 + type random
440 '
441
442 test_add_cat_5MB "" "QmSr7FqYkxYWGoSfy8ZiaMWQ5vosb18DQGCzjwEQnVHkTb"
@@ -479,9 +479,9 @@ test_add_pwd_is_symlink
479 test_add_cat_raw
480
481 test_expect_success "ipfs add --cid-version=9 fails" '
482 - echo "context" > afile.txt &&
483 - test_must_fail ipfs add --cid-version=9 afile.txt 2>&1 | tee add_out &&
484 - grep -q "unknown CID version" add_out
482 + echo "context" > afile.txt &&
483 + test_must_fail ipfs add --cid-version=9 afile.txt 2>&1 | tee add_out &&
484 + grep -q "unknown CID version" add_out
485 '
486
487 test_kill_ipfs_daemon
@@ -493,12 +493,12 @@ test_add_cat_file
493 test_add_cat_raw
494
495 test_expect_success "ipfs add --only-hash succeeds" '
496 - echo "unknown content for only-hash" | ipfs add --only-hash -q > oh_hash
496 + echo "unknown content for only-hash" | ipfs add --only-hash -q > oh_hash
497 '
498
499 #TODO: this doesn't work when online hence separated out from test_add_cat_file
500 test_expect_success "ipfs cat file fails" '
501 - test_must_fail ipfs cat $(cat oh_hash)
501 + test_must_fail ipfs cat $(cat oh_hash)
502 '
503
504 test_add_named_pipe ""
test/sharness/t0042-add-skip.sh
+43 -43
@@ -10,54 +10,54 @@ test_description="Test add and cat commands"
10
11 test_add_skip() {
12
13 - test_expect_success "'ipfs add -r' with hidden file succeeds" '
14 - mkdir -p mountdir/planets/.asteroids &&
15 - echo "Hello Mars" >mountdir/planets/mars.txt &&
16 - echo "Hello Venus" >mountdir/planets/venus.txt &&
17 - echo "Hello Pluto" >mountdir/planets/.pluto.txt &&
18 - echo "Hello Charon" >mountdir/planets/.charon.txt &&
19 - echo "Hello Ceres" >mountdir/planets/.asteroids/ceres.txt &&
20 - echo "Hello Pallas" >mountdir/planets/.asteroids/pallas.txt &&
21 - ipfs add -r mountdir/planets >actual
22 - '
13 + test_expect_success "'ipfs add -r' with hidden file succeeds" '
14 + mkdir -p mountdir/planets/.asteroids &&
15 + echo "Hello Mars" >mountdir/planets/mars.txt &&
16 + echo "Hello Venus" >mountdir/planets/venus.txt &&
17 + echo "Hello Pluto" >mountdir/planets/.pluto.txt &&
18 + echo "Hello Charon" >mountdir/planets/.charon.txt &&
19 + echo "Hello Ceres" >mountdir/planets/.asteroids/ceres.txt &&
20 + echo "Hello Pallas" >mountdir/planets/.asteroids/pallas.txt &&
21 + ipfs add -r mountdir/planets >actual
22 + '
23
24 - test_expect_success "'ipfs add -r' did not include . files" '
25 - cat >expected <<-\EOF &&
26 - added QmZy3khu7qf696i5HtkgL2NotsCZ8wzvNZJ1eUdA5n8KaV planets/mars.txt
27 - added QmQnv4m3Q5512zgVtpbJ9z85osQrzZzGRn934AGh6iVEXz planets/venus.txt
28 - added QmR8nD1Vzk5twWVC6oShTHvv7mMYkVh6dApCByBJyV2oj3 planets
29 - EOF
30 - test_cmp expected actual
31 - '
24 + test_expect_success "'ipfs add -r' did not include . files" '
25 + cat >expected <<-\EOF &&
26 +added QmZy3khu7qf696i5HtkgL2NotsCZ8wzvNZJ1eUdA5n8KaV planets/mars.txt
27 +added QmQnv4m3Q5512zgVtpbJ9z85osQrzZzGRn934AGh6iVEXz planets/venus.txt
28 +added QmR8nD1Vzk5twWVC6oShTHvv7mMYkVh6dApCByBJyV2oj3 planets
29 +EOF
30 + test_cmp expected actual
31 + '
32
33 - test_expect_success "'ipfs add -r --hidden' succeeds" '
34 - ipfs add -r --hidden mountdir/planets >actual
35 - '
33 + test_expect_success "'ipfs add -r --hidden' succeeds" '
34 + ipfs add -r --hidden mountdir/planets >actual
35 + '
36
37 - test_expect_success "'ipfs add -r --hidden' did include . files" '
38 - cat >expected <<-\EOF &&
39 - added QmcAREBcjgnUpKfyFmUGnfajA1NQS5ydqRp7WfqZ6JF8Dx planets/.asteroids/ceres.txt
40 - added QmZ5eaLybJ5GUZBNwy24AA9EEDTDpA4B8qXnuN3cGxu2uF planets/.asteroids/pallas.txt
41 - added QmaowqjedBkUrMUXgzt9c2ZnAJncM9jpJtkFfgdFstGr5a planets/.charon.txt
42 - added QmU4zFD5eJtRBsWC63AvpozM9Atiadg9kPVTuTrnCYJiNF planets/.pluto.txt
43 - added QmZy3khu7qf696i5HtkgL2NotsCZ8wzvNZJ1eUdA5n8KaV planets/mars.txt
44 - added QmQnv4m3Q5512zgVtpbJ9z85osQrzZzGRn934AGh6iVEXz planets/venus.txt
45 - added Qmf6rbs5GF85anDuoxpSAdtuZPM9D2Yt3HngzjUVSQ7kDV planets/.asteroids
46 - added QmetajtFdmzhWYodAsZoVZSiqpeJDAiaw2NwbM3xcWcpDj planets
47 - EOF
48 - test_cmp expected actual
49 - '
37 + test_expect_success "'ipfs add -r --hidden' did include . files" '
38 + cat >expected <<-\EOF &&
39 +added QmcAREBcjgnUpKfyFmUGnfajA1NQS5ydqRp7WfqZ6JF8Dx planets/.asteroids/ceres.txt
40 +added QmZ5eaLybJ5GUZBNwy24AA9EEDTDpA4B8qXnuN3cGxu2uF planets/.asteroids/pallas.txt
41 +added QmaowqjedBkUrMUXgzt9c2ZnAJncM9jpJtkFfgdFstGr5a planets/.charon.txt
42 +added QmU4zFD5eJtRBsWC63AvpozM9Atiadg9kPVTuTrnCYJiNF planets/.pluto.txt
43 +added QmZy3khu7qf696i5HtkgL2NotsCZ8wzvNZJ1eUdA5n8KaV planets/mars.txt
44 +added QmQnv4m3Q5512zgVtpbJ9z85osQrzZzGRn934AGh6iVEXz planets/venus.txt
45 +added Qmf6rbs5GF85anDuoxpSAdtuZPM9D2Yt3HngzjUVSQ7kDV planets/.asteroids
46 +added QmetajtFdmzhWYodAsZoVZSiqpeJDAiaw2NwbM3xcWcpDj planets
47 +EOF
48 + test_cmp expected actual
49 + '
50
51 - test_expect_success "'ipfs add' includes hidden files given explicitly even without --hidden" '
52 - mkdir -p mountdir/dotfiles &&
53 - echo "set nocompatible" > mountdir/dotfiles/.vimrc
54 - cat >expected <<-\EOF &&
51 + test_expect_success "'ipfs add' includes hidden files given explicitly even without --hidden" '
52 + mkdir -p mountdir/dotfiles &&
53 + echo "set nocompatible" > mountdir/dotfiles/.vimrc
54 + cat >expected <<-\EOF &&
55 added QmT4uMRDCN7EMpFeqwvKkboszbqeW1kWVGrBxBuCGqZcQc .vimrc
56 - EOF
57 - ipfs add mountdir/dotfiles/.vimrc >actual
58 - cat actual
59 - test_cmp expected actual
60 - '
56 +EOF
57 + ipfs add mountdir/dotfiles/.vimrc >actual
58 + cat actual
59 + test_cmp expected actual
60 + '
61
62 }
63
test/sharness/t0043-add-w.sh
+92 -92
@@ -57,98 +57,98 @@ add_w_r='QmcCksBMDuuyuyfAMMNzEAx6Z7jTrdRy9a23WpufAhG9ji'
57
58 test_add_w() {
59
60 - test_expect_success "go-random-files is installed" '
61 - type random-files
62 - '
63 -
64 - test_expect_success "random-files generates test files" '
65 - random-files --seed 7547632 --files 5 --dirs 2 --depth 3 m &&
66 - echo "$add_w_m" >expected &&
67 - ipfs add -q -r m | tail -n1 >actual &&
68 - test_sort_cmp expected actual
69 - '
70 -
71 - # test single file
72 - test_expect_success "ipfs add -w (single file) succeeds" '
73 - ipfs add -w m/4r93 >actual
74 - '
75 -
76 - test_expect_success "ipfs add -w (single file) is correct" '
77 - echo "$add_w_1" >expected &&
78 - test_sort_cmp expected actual
79 - '
80 -
81 - # test two files together
82 - test_expect_success "ipfs add -w (multiple) succeeds" '
83 - ipfs add -w m/4r93 m/4u6ead >actual
84 - '
85 -
86 - test_expect_success "ipfs add -w (multiple) is correct" '
87 - echo "$add_w_12" >expected &&
88 - test_sort_cmp expected actual
89 - '
90 -
91 - test_expect_success "ipfs add -w (multiple) succeeds" '
92 - ipfs add -w m/4u6ead m/4r93 >actual
93 - '
94 -
95 - test_expect_success "ipfs add -w (multiple) orders" '
96 - echo "$add_w_21" >expected &&
97 - test_sort_cmp expected actual
98 - '
99 -
100 - # test a directory
101 - test_expect_success "ipfs add -w -r (dir) succeeds" '
102 - ipfs add -r -w m/t_1wp-8a2/_jo7 >actual
103 - '
104 -
105 - test_expect_success "ipfs add -w -r (dir) is correct" '
106 - echo "$add_w_d1" >expected &&
107 - test_sort_cmp expected actual
108 - '
109 -
110 - # test files and directory
111 - test_expect_success "ipfs add -w -r <many> succeeds" '
112 - ipfs add -w -r m/t_1wp-8a2/h3qpecj0 \
113 - m/ha6f0x7su6/gnz66h m/t_1wp-8a2/_jo7 m/4r93 >actual
114 - '
115 -
116 - test_expect_success "ipfs add -w -r <many> is correct" '
117 - echo "$add_w_d2" >expected &&
118 - test_sort_cmp expected actual
119 - '
120 -
121 - # test -w -r m/* == -r m
122 - test_expect_success "ipfs add -w -r m/* == add -r m succeeds" '
123 - ipfs add -q -w -r m/* | tail -n1 >actual
124 - '
125 -
126 - test_expect_success "ipfs add -w -r m/* == add -r m is correct" '
127 - echo "$add_w_m" >expected &&
128 - test_sort_cmp expected actual
129 - '
130 -
131 - # test repeats together
132 - test_expect_success "ipfs add -w (repeats) succeeds" '
133 - ipfs add -q -w -r m/t_1wp-8a2/h3qpecj0 m/ha6f0x7su6/gnz66h \
134 - m/t_1wp-8a2/_jo7 m/4r93 m/t_1wp-8a2 m/t_1wp-8a2 m/4r93 \
135 - m/4r93 m/ha6f0x7su6/_rwujlf3qh_g08 \
136 - m/ha6f0x7su6/gnz66h/9cwudvacx | tail -n1 >actual
137 - '
138 -
139 - test_expect_success "ipfs add -w (repeats) is correct" '
140 - echo "$add_w_r" >expected &&
141 - test_sort_cmp expected actual
142 - '
143 -
144 - test_expect_success "ipfs add -w -r (dir) --cid-version=1 succeeds" '
145 - ipfs add -r -w --cid-version=1 m/t_1wp-8a2/_jo7 >actual
146 - '
147 -
148 - test_expect_success "ipfs add -w -r (dir) --cid-version=1 is correct" '
149 - echo "$add_w_d1_v1" >expected &&
150 - test_sort_cmp expected actual
151 - '
60 + test_expect_success "go-random-files is installed" '
61 + type random-files
62 + '
63 +
64 + test_expect_success "random-files generates test files" '
65 + random-files --seed 7547632 --files 5 --dirs 2 --depth 3 m &&
66 + echo "$add_w_m" >expected &&
67 + ipfs add -q -r m | tail -n1 >actual &&
68 + test_sort_cmp expected actual
69 + '
70 +
71 + # test single file
72 + test_expect_success "ipfs add -w (single file) succeeds" '
73 + ipfs add -w m/4r93 >actual
74 + '
75 +
76 + test_expect_success "ipfs add -w (single file) is correct" '
77 + echo "$add_w_1" >expected &&
78 + test_sort_cmp expected actual
79 + '
80 +
81 + # test two files together
82 + test_expect_success "ipfs add -w (multiple) succeeds" '
83 + ipfs add -w m/4r93 m/4u6ead >actual
84 + '
85 +
86 + test_expect_success "ipfs add -w (multiple) is correct" '
87 + echo "$add_w_12" >expected &&
88 + test_sort_cmp expected actual
89 + '
90 +
91 + test_expect_success "ipfs add -w (multiple) succeeds" '
92 + ipfs add -w m/4u6ead m/4r93 >actual
93 + '
94 +
95 + test_expect_success "ipfs add -w (multiple) orders" '
96 + echo "$add_w_21" >expected &&
97 + test_sort_cmp expected actual
98 + '
99 +
100 + # test a directory
101 + test_expect_success "ipfs add -w -r (dir) succeeds" '
102 + ipfs add -r -w m/t_1wp-8a2/_jo7 >actual
103 + '
104 +
105 + test_expect_success "ipfs add -w -r (dir) is correct" '
106 + echo "$add_w_d1" >expected &&
107 + test_sort_cmp expected actual
108 + '
109 +
110 + # test files and directory
111 + test_expect_success "ipfs add -w -r <many> succeeds" '
112 + ipfs add -w -r m/t_1wp-8a2/h3qpecj0 \
113 + m/ha6f0x7su6/gnz66h m/t_1wp-8a2/_jo7 m/4r93 >actual
114 + '
115 +
116 + test_expect_success "ipfs add -w -r <many> is correct" '
117 + echo "$add_w_d2" >expected &&
118 + test_sort_cmp expected actual
119 + '
120 +
121 + # test -w -r m/* == -r m
122 + test_expect_success "ipfs add -w -r m/* == add -r m succeeds" '
123 + ipfs add -q -w -r m/* | tail -n1 >actual
124 + '
125 +
126 + test_expect_success "ipfs add -w -r m/* == add -r m is correct" '
127 + echo "$add_w_m" >expected &&
128 + test_sort_cmp expected actual
129 + '
130 +
131 + # test repeats together
132 + test_expect_success "ipfs add -w (repeats) succeeds" '
133 + ipfs add -q -w -r m/t_1wp-8a2/h3qpecj0 m/ha6f0x7su6/gnz66h \
134 + m/t_1wp-8a2/_jo7 m/4r93 m/t_1wp-8a2 m/t_1wp-8a2 m/4r93 \
135 + m/4r93 m/ha6f0x7su6/_rwujlf3qh_g08 \
136 + m/ha6f0x7su6/gnz66h/9cwudvacx | tail -n1 >actual
137 + '
138 +
139 + test_expect_success "ipfs add -w (repeats) is correct" '
140 + echo "$add_w_r" >expected &&
141 + test_sort_cmp expected actual
142 + '
143 +
144 + test_expect_success "ipfs add -w -r (dir) --cid-version=1 succeeds" '
145 + ipfs add -r -w --cid-version=1 m/t_1wp-8a2/_jo7 >actual
146 + '
147 +
148 + test_expect_success "ipfs add -w -r (dir) --cid-version=1 is correct" '
149 + echo "$add_w_d1_v1" >expected &&
150 + test_sort_cmp expected actual
151 + '
152 }
153
154 test_init_ipfs
test/sharness/t0044-add-symlink.sh
+52 -52
@@ -9,62 +9,62 @@ test_description="Test add -w"
9 . lib/test-lib.sh
10
11 test_expect_success "creating files succeeds" '
12 - mkdir -p files/foo &&
13 - mkdir -p files/bar &&
14 - echo "some text" > files/foo/baz &&
15 - ln -s files/foo/baz files/bar/baz &&
16 - ln -s files/does/not/exist files/bad
12 + mkdir -p files/foo &&
13 + mkdir -p files/bar &&
14 + echo "some text" > files/foo/baz &&
15 + ln -s files/foo/baz files/bar/baz &&
16 + ln -s files/does/not/exist files/bad
17 '
18
19 test_add_symlinks() {
20 - test_expect_success "ipfs add files succeeds" '
21 - ipfs add -q -r files >filehash_all &&
22 - tail -n 1 filehash_all >filehash_out
23 - '
24 -
25 - test_expect_success "output looks good" '
26 - echo QmWdiHKoeSW8G1u7ATCgpx4yMoUhYaJBQGkyPLkS9goYZ8 > filehash_exp &&
27 - test_cmp filehash_exp filehash_out
28 - '
29 -
30 - test_expect_success "ipfs add --cid-version=1 files succeeds" '
31 - ipfs add -q -r --cid-version=1 files >filehash_all &&
32 - tail -n 1 filehash_all >filehash_out
33 - '
34 -
35 - test_expect_success "output looks good" '
36 - # note this hash implies all internal nodes are stored using CidV1
37 - echo zdj7WZDQ2xMmr4qn6aRZTsE9fCUs2KmvPigpHdpssqUobwcWK > filehash_exp &&
38 - test_cmp filehash_exp filehash_out
39 - '
40 -
41 - test_expect_success "adding a symlink adds the link itself" '
42 - ipfs add -q files/bar/baz > goodlink_out
43 - '
44 -
45 - test_expect_success "output looks good" '
46 - echo "QmdocmZeF7qwPT9Z8SiVhMSyKA2KKoA2J7jToW6z6WBmxR" > goodlink_exp &&
47 - test_cmp goodlink_exp goodlink_out
48 - '
49 -
50 - test_expect_success "adding a broken symlink works" '
51 - ipfs add -q files/bad > badlink_out
52 - '
53 -
54 - test_expect_success "output looks good" '
55 - echo "QmWYN8SEXCgNT2PSjB6BnxAx6NJQtazWoBkTRH9GRfPFFQ" > badlink_exp &&
56 - test_cmp badlink_exp badlink_out
57 - '
58 -
59 - test_expect_success "adding with symlink in middle of path is same as\
20 + test_expect_success "ipfs add files succeeds" '
21 + ipfs add -q -r files >filehash_all &&
22 + tail -n 1 filehash_all >filehash_out
23 + '
24 +
25 + test_expect_success "output looks good" '
26 + echo QmWdiHKoeSW8G1u7ATCgpx4yMoUhYaJBQGkyPLkS9goYZ8 > filehash_exp &&
27 + test_cmp filehash_exp filehash_out
28 + '
29 +
30 + test_expect_success "ipfs add --cid-version=1 files succeeds" '
31 + ipfs add -q -r --cid-version=1 files >filehash_all &&
32 + tail -n 1 filehash_all >filehash_out
33 + '
34 +
35 + test_expect_success "output looks good" '
36 + # note this hash implies all internal nodes are stored using CidV1
37 + echo zdj7WZDQ2xMmr4qn6aRZTsE9fCUs2KmvPigpHdpssqUobwcWK > filehash_exp &&
38 + test_cmp filehash_exp filehash_out
39 + '
40 +
41 + test_expect_success "adding a symlink adds the link itself" '
42 + ipfs add -q files/bar/baz > goodlink_out
43 + '
44 +
45 + test_expect_success "output looks good" '
46 + echo "QmdocmZeF7qwPT9Z8SiVhMSyKA2KKoA2J7jToW6z6WBmxR" > goodlink_exp &&
47 + test_cmp goodlink_exp goodlink_out
48 + '
49 +
50 + test_expect_success "adding a broken symlink works" '
51 + ipfs add -q files/bad > badlink_out
52 + '
53 +
54 + test_expect_success "output looks good" '
55 + echo "QmWYN8SEXCgNT2PSjB6BnxAx6NJQtazWoBkTRH9GRfPFFQ" > badlink_exp &&
56 + test_cmp badlink_exp badlink_out
57 + '
58 +
59 + test_expect_success "adding with symlink in middle of path is same as\
60 adding with no symlink" '
61 - mkdir -p files2/a/b/c &&
62 - echo "some other text" > files2/a/b/c/foo &&
63 - ln -s b files2/a/d
64 - ipfs add -rq files2/a/b/c > no_sym &&
65 - ipfs add -rq files2/a/d/c > sym &&
66 - test_cmp no_sym sym
67 - '
61 + mkdir -p files2/a/b/c &&
62 + echo "some other text" > files2/a/b/c/foo &&
63 + ln -s b files2/a/d
64 + ipfs add -rq files2/a/b/c > no_sym &&
65 + ipfs add -rq files2/a/d/c > sym &&
66 + test_cmp no_sym sym
67 + '
68 }
69
70 test_init_ipfs
test/sharness/t0045-ls.sh
+106 -106
@@ -12,104 +12,104 @@ test_init_ipfs
12
13 test_ls_cmd() {
14
15 - test_expect_success "'ipfs add -r testData' succeeds" '
16 - mkdir -p testData testData/d1 testData/d2 &&
17 - echo "test" >testData/f1 &&
18 - echo "data" >testData/f2 &&
19 - echo "hello" >testData/d1/a &&
20 - random 128 42 >testData/d1/128 &&
21 - echo "world" >testData/d2/a &&
22 - random 1024 42 >testData/d2/1024 &&
23 - ipfs add -r testData >actual_add
24 - '
25 -
26 - test_expect_success "'ipfs add' output looks good" '
27 - cat <<-\EOF >expected_add &&
28 - added QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe testData/d1/128
29 - added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN testData/d1/a
30 - added QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd testData/d2/1024
31 - added QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL testData/d2/a
32 - added QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH testData/f1
33 - added QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M testData/f2
34 - added QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss testData/d1
35 - added QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy testData/d2
36 - added QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj testData
37 - EOF
38 - test_cmp expected_add actual_add
39 - '
40 -
41 - test_expect_success "'ipfs ls <three dir hashes>' succeeds" '
42 - ipfs ls QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls
43 - '
44 -
45 - test_expect_success "'ipfs ls <three dir hashes>' output looks good" '
46 - cat <<-\EOF >expected_ls &&
47 - QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj:
48 - QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss 246 d1/
49 - QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy 1143 d2/
50 - QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH 13 f1
51 - QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M 13 f2
52 -
53 - QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy:
54 - QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd 1035 1024
55 - QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL 14 a
56 -
57 - QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss:
58 - QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe 139 128
59 - QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN 14 a
60 -
61 - EOF
62 - test_cmp expected_ls actual_ls
63 - '
64 -
65 - test_expect_success "'ipfs ls --headers <three dir hashes>' succeeds" '
66 - ipfs ls --headers QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls_headers
67 - '
68 -
69 - test_expect_success "'ipfs ls --headers <three dir hashes>' output looks good" '
70 - cat <<-\EOF >expected_ls_headers &&
71 - QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj:
72 - Hash Size Name
73 - QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss 246 d1/
74 - QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy 1143 d2/
75 - QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH 13 f1
76 - QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M 13 f2
77 -
78 - QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy:
79 - Hash Size Name
80 - QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd 1035 1024
81 - QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL 14 a
82 -
83 - QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss:
84 - Hash Size Name
85 - QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe 139 128
86 - QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN 14 a
87 -
88 - EOF
89 - test_cmp expected_ls_headers actual_ls_headers
90 - '
15 + test_expect_success "'ipfs add -r testData' succeeds" '
16 + mkdir -p testData testData/d1 testData/d2 &&
17 + echo "test" >testData/f1 &&
18 + echo "data" >testData/f2 &&
19 + echo "hello" >testData/d1/a &&
20 + random 128 42 >testData/d1/128 &&
21 + echo "world" >testData/d2/a &&
22 + random 1024 42 >testData/d2/1024 &&
23 + ipfs add -r testData >actual_add
24 + '
25 +
26 + test_expect_success "'ipfs add' output looks good" '
27 + cat <<-\EOF >expected_add &&
28 +added QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe testData/d1/128
29 +added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN testData/d1/a
30 +added QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd testData/d2/1024
31 +added QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL testData/d2/a
32 +added QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH testData/f1
33 +added QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M testData/f2
34 +added QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss testData/d1
35 +added QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy testData/d2
36 +added QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj testData
37 +EOF
38 + test_cmp expected_add actual_add
39 + '
40 +
41 + test_expect_success "'ipfs ls <three dir hashes>' succeeds" '
42 + ipfs ls QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls
43 + '
44 +
45 + test_expect_success "'ipfs ls <three dir hashes>' output looks good" '
46 + cat <<-\EOF >expected_ls &&
47 +QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj:
48 +QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss 246 d1/
49 +QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy 1143 d2/
50 +QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH 13 f1
51 +QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M 13 f2
52 +
53 +QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy:
54 +QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd 1035 1024
55 +QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL 14 a
56 +
57 +QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss:
58 +QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe 139 128
59 +QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN 14 a
60 +
61 +EOF
62 + test_cmp expected_ls actual_ls
63 + '
64 +
65 + test_expect_success "'ipfs ls --headers <three dir hashes>' succeeds" '
66 + ipfs ls --headers QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls_headers
67 + '
68 +
69 + test_expect_success "'ipfs ls --headers <three dir hashes>' output looks good" '
70 + cat <<-\EOF >expected_ls_headers &&
71 +QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj:
72 +Hash Size Name
73 +QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss 246 d1/
74 +QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy 1143 d2/
75 +QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH 13 f1
76 +QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M 13 f2
77 +
78 +QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy:
79 +Hash Size Name
80 +QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd 1035 1024
81 +QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL 14 a
82 +
83 +QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss:
84 +Hash Size Name
85 +QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe 139 128
86 +QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN 14 a
87 +
88 +EOF
89 + test_cmp expected_ls_headers actual_ls_headers
90 + '
91 }
92
93 test_ls_cmd_raw_leaves() {
94 - test_expect_success "'ipfs add -r --raw-leaves' then 'ipfs ls' works as expected" '
95 - mkdir -p somedir &&
96 - echo bar > somedir/foo &&
97 - ipfs add --raw-leaves -r somedir/ > /dev/null &&
98 - ipfs ls QmThNTdtKaVoCVrYmM5EBS6U3S5vfKFue2TxbxxAxRcKKE > ls-actual
99 - echo "zb2rhf6GzX4ckKZtjy8yy8iyq1KttCrRyqDedD6xubhY3sw2F 4 foo" > ls-expect
100 - test_cmp ls-actual ls-expect
101 - '
94 + test_expect_success "'ipfs add -r --raw-leaves' then 'ipfs ls' works as expected" '
95 + mkdir -p somedir &&
96 + echo bar > somedir/foo &&
97 + ipfs add --raw-leaves -r somedir/ > /dev/null &&
98 + ipfs ls QmThNTdtKaVoCVrYmM5EBS6U3S5vfKFue2TxbxxAxRcKKE > ls-actual
99 + echo "zb2rhf6GzX4ckKZtjy8yy8iyq1KttCrRyqDedD6xubhY3sw2F 4 foo" > ls-expect
100 + test_cmp ls-actual ls-expect
101 + '
102 }
103
104 test_ls_object() {
105 - test_expect_success "ipfs add medium size file then 'ipfs ls' works as expected" '
106 - random 500000 2 > somefile &&
107 - HASH=$(ipfs add somefile -q) &&
108 - echo "QmPrM8S5T7Q3M8DQvQMS7m41m3Aq4jBjzAzvky5fH3xfr4 262158 " > ls-expect &&
109 - echo "QmdaAntAzQqqVMo4B8V69nkQd5d918YjHXUe2oF6hr72ri 237870 " >> ls-expect &&
110 - ipfs ls $HASH > ls-actual &&
111 - test_cmp ls-actual ls-expect
112 - '
105 + test_expect_success "ipfs add medium size file then 'ipfs ls' works as expected" '
106 + random 500000 2 > somefile &&
107 + HASH=$(ipfs add somefile -q) &&
108 + echo "QmPrM8S5T7Q3M8DQvQMS7m41m3Aq4jBjzAzvky5fH3xfr4 262158 " > ls-expect &&
109 + echo "QmdaAntAzQqqVMo4B8V69nkQd5d918YjHXUe2oF6hr72ri 237870 " >> ls-expect &&
110 + ipfs ls $HASH > ls-actual &&
111 + test_cmp ls-actual ls-expect
112 + '
113 }
114
115 # should work offline
@@ -129,39 +129,39 @@ test_ls_object
129 #
130
131 test_expect_success "'ipfs add -r' succeeds" '
132 - mkdir adir &&
133 - # note: not using a seed as the files need to have truly random content
134 - random 1000 > adir/file1 &&
135 - random 1000 > adir/file2 &&
136 - ipfs add --pin=false -q -r adir > adir-hashes
132 + mkdir adir &&
133 + # note: not using a seed as the files need to have truly random content
134 + random 1000 > adir/file1 &&
135 + random 1000 > adir/file2 &&
136 + ipfs add --pin=false -q -r adir > adir-hashes
137 '
138
139 test_expect_success "get hashes from add output" '
140 - FILE=`head -1 adir-hashes` &&
141 - DIR=`tail -1 adir-hashes` &&
142 - test "$FILE" -a "$DIR"
140 + FILE=`head -1 adir-hashes` &&
141 + DIR=`tail -1 adir-hashes` &&
142 + test "$FILE" -a "$DIR"
143 '
144
145 test_expect_success "remove a file in dir" '
146 - ipfs block rm $FILE
146 + ipfs block rm $FILE
147 '
148
149 test_expect_success "'ipfs ls --resolve-type=false ' ok" '
150 - ipfs ls --resolve-type=false $DIR > /dev/null
150 + ipfs ls --resolve-type=false $DIR > /dev/null
151 '
152
153 test_expect_success "'ipfs ls' fails" '
154 - test_must_fail ipfs ls $DIR
154 + test_must_fail ipfs ls $DIR
155 '
156
157 test_launch_ipfs_daemon --offline
158
159 test_expect_success "'ipfs ls --resolve-type=false' ok" '
160 - ipfs ls --resolve-type=false $DIR > /dev/null
160 + ipfs ls --resolve-type=false $DIR > /dev/null
161 '
162
163 test_expect_success "'ipfs ls' fails" '
164 - test_must_fail ipfs ls $DIR
164 + test_must_fail ipfs ls $DIR
165 '
166
167 test_kill_ipfs_daemon
@@ -174,7 +174,7 @@ test_launch_ipfs_daemon
174 # should not exist on the network, but we don't want to wait for a
175 # timeout so we will kill the request after a few seconds
176 test_expect_success "'ipfs ls --resolve-type=false' ok and does not hang" '
177 - go-timeout 2 ipfs ls --resolve-type=false $DIR
177 + go-timeout 2 ipfs ls --resolve-type=false $DIR
178 '
179
180 test_kill_ipfs_daemon
test/sharness/t0050-block.sh
+61 -61
@@ -17,13 +17,13 @@ HASH="QmRKqGMAM6EZngbpjSqrvYzq5Qd8b1bSWymjSUY9zQSNDk"
17 #
18
19 test_expect_success "'ipfs block put' succeeds" '
20 - echo "Hello Mars!" >expected_in &&
21 - ipfs block put <expected_in >actual_out
20 + echo "Hello Mars!" >expected_in &&
21 + ipfs block put <expected_in >actual_out
22 '
23
24 test_expect_success "'ipfs block put' output looks good" '
25 - echo "$HASH" >expected_out &&
26 - test_cmp expected_out actual_out
25 + echo "$HASH" >expected_out &&
26 + test_cmp expected_out actual_out
27 '
28
29 #
@@ -31,11 +31,11 @@ test_expect_success "'ipfs block put' output looks good" '
31 #
32
33 test_expect_success "'ipfs block get' succeeds" '
34 - ipfs block get $HASH >actual_in
34 + ipfs block get $HASH >actual_in
35 '
36
37 test_expect_success "'ipfs block get' output looks good" '
38 - test_cmp expected_in actual_in
38 + test_cmp expected_in actual_in
39 '
40
41 #
@@ -43,13 +43,13 @@ test_expect_success "'ipfs block get' output looks good" '
43 #
44
45 test_expect_success "'ipfs block stat' succeeds" '
46 - ipfs block stat $HASH >actual_stat
46 + ipfs block stat $HASH >actual_stat
47 '
48
49 test_expect_success "'ipfs block stat' output looks good" '
50 - echo "Key: $HASH" >expected_stat &&
51 - echo "Size: 12" >>expected_stat &&
52 - test_cmp expected_stat actual_stat
50 + echo "Key: $HASH" >expected_stat &&
51 + echo "Size: 12" >>expected_stat &&
52 + test_cmp expected_stat actual_stat
53 '
54
55 #
@@ -57,16 +57,16 @@ test_expect_success "'ipfs block stat' output looks good" '
57 #
58
59 test_expect_success "'ipfs block rm' succeeds" '
60 - ipfs block rm $HASH >actual_rm
60 + ipfs block rm $HASH >actual_rm
61 '
62
63 test_expect_success "'ipfs block rm' output looks good" '
64 - echo "removed $HASH" > expected_rm &&
65 - test_cmp expected_rm actual_rm
64 + echo "removed $HASH" > expected_rm &&
65 + test_cmp expected_rm actual_rm
66 '
67
68 test_expect_success "'ipfs block rm' block actually removed" '
69 - test_must_fail ipfs block stat $HASH
69 + test_must_fail ipfs block stat $HASH
70 '
71
72 DIRHASH=QmdWmVmM6W2abTgkEfpbtA1CJyTWS2rhuUB9uP1xV8Uwtf
@@ -75,52 +75,52 @@ FILE2HASH=QmUtkGLvPf63NwVzLPKPUYgwhn8ZYPWF6vKWN3fZ2amfJF
75 FILE3HASH=Qmesmmf1EEG1orJb6XdK6DabxexsseJnCfw8pqWgonbkoj
76
77 test_expect_success "add and pin directory" '
78 - mkdir adir &&
79 - echo "file1" > adir/file1 &&
80 - echo "file2" > adir/file2 &&
81 - echo "file3" > adir/file3 &&
82 - ipfs add -r adir
83 - ipfs pin add -r $DIRHASH
78 + mkdir adir &&
79 + echo "file1" > adir/file1 &&
80 + echo "file2" > adir/file2 &&
81 + echo "file3" > adir/file3 &&
82 + ipfs add -r adir
83 + ipfs pin add -r $DIRHASH
84 '
85
86 test_expect_success "can't remove pinned block" '
87 - test_must_fail ipfs block rm $DIRHASH 2> block_rm_err
87 + test_must_fail ipfs block rm $DIRHASH 2> block_rm_err
88 '
89
90 test_expect_success "can't remove pinned block: output looks good" '
91 - grep -q "$DIRHASH: pinned: recursive" block_rm_err
91 + grep -q "$DIRHASH: pinned: recursive" block_rm_err
92 '
93
94 test_expect_success "can't remove indirectly pinned block" '
95 - test_must_fail ipfs block rm $FILE1HASH 2> block_rm_err
95 + test_must_fail ipfs block rm $FILE1HASH 2> block_rm_err
96 '
97
98 test_expect_success "can't remove indirectly pinned block: output looks good" '
99 - grep -q "$FILE1HASH: pinned via $DIRHASH" block_rm_err
99 + grep -q "$FILE1HASH: pinned via $DIRHASH" block_rm_err
100 '
101
102 test_expect_success "remove pin" '
103 - ipfs pin rm -r $DIRHASH
103 + ipfs pin rm -r $DIRHASH
104 '
105
106 test_expect_success "multi-block 'ipfs block rm' succeeds" '
107 - ipfs block rm $FILE1HASH $FILE2HASH $FILE3HASH > actual_rm
107 + ipfs block rm $FILE1HASH $FILE2HASH $FILE3HASH > actual_rm
108 '
109
110 test_expect_success "multi-block 'ipfs block rm' output looks good" '
111 - grep -F -q "removed $FILE1HASH" actual_rm &&
112 - grep -F -q "removed $FILE2HASH" actual_rm &&
113 - grep -F -q "removed $FILE3HASH" actual_rm
111 + grep -F -q "removed $FILE1HASH" actual_rm &&
112 + grep -F -q "removed $FILE2HASH" actual_rm &&
113 + grep -F -q "removed $FILE3HASH" actual_rm
114 '
115
116 test_expect_success "'add some blocks' succeeds" '
117 - echo "Hello Mars!" | ipfs block put &&
118 - echo "Hello Venus!" | ipfs block put
117 + echo "Hello Mars!" | ipfs block put &&
118 + echo "Hello Venus!" | ipfs block put
119 '
120
121 test_expect_success "add and pin directory" '
122 - ipfs add -r adir
123 - ipfs pin add -r $DIRHASH
122 + ipfs add -r adir
123 + ipfs pin add -r $DIRHASH
124 '
125
126 HASH=QmRKqGMAM6EZngbpjSqrvYzq5Qd8b1bSWymjSUY9zQSNDk
@@ -128,85 +128,85 @@ HASH2=QmdnpnsaEj69isdw5sNzp3h3HkaDz7xKq7BmvFFBzNr5e7
128 RANDOMHASH=QmRKqGMAM6EbngbZjSqrvYzq5Qd8b1bSWymjSUY9zQSNDq
129
130 test_expect_success "multi-block 'ipfs block rm' mixed" '
131 - test_must_fail ipfs block rm $FILE1HASH $DIRHASH $HASH $FILE3HASH $RANDOMHASH $HASH2 2> block_rm_err
131 + test_must_fail ipfs block rm $FILE1HASH $DIRHASH $HASH $FILE3HASH $RANDOMHASH $HASH2 2> block_rm_err
132 '
133
134 test_expect_success "pinned block not removed" '
135 - ipfs block stat $FILE1HASH &&
136 - ipfs block stat $FILE3HASH
135 + ipfs block stat $FILE1HASH &&
136 + ipfs block stat $FILE3HASH
137 '
138
139 test_expect_success "non-pinned blocks removed" '
140 - test_must_fail ipfs block stat $HASH &&
141 - test_must_fail ipfs block stat $HASH2
140 + test_must_fail ipfs block stat $HASH &&
141 + test_must_fail ipfs block stat $HASH2
142 '
143
144 test_expect_success "error reported on removing non-existent block" '
145 - grep -q "cannot remove $RANDOMHASH" block_rm_err
145 + grep -q "cannot remove $RANDOMHASH" block_rm_err
146 '
147
148 test_expect_success "'add some blocks' succeeds" '
149 - echo "Hello Mars!" | ipfs block put &&
150 - echo "Hello Venus!" | ipfs block put
149 + echo "Hello Mars!" | ipfs block put &&
150 + echo "Hello Venus!" | ipfs block put
151 '
152
153 test_expect_success "multi-block 'ipfs block rm -f' with non existent blocks succeed" '
154 - ipfs block rm -f $HASH $RANDOMHASH $HASH2
154 + ipfs block rm -f $HASH $RANDOMHASH $HASH2
155 '
156
157 test_expect_success "existent blocks removed" '
158 - test_must_fail ipfs block stat $HASH &&
159 - test_must_fail ipfs block stat $HASH2
158 + test_must_fail ipfs block stat $HASH &&
159 + test_must_fail ipfs block stat $HASH2
160 '
161
162 test_expect_success "'add some blocks' succeeds" '
163 - echo "Hello Mars!" | ipfs block put &&
164 - echo "Hello Venus!" | ipfs block put
163 + echo "Hello Mars!" | ipfs block put &&
164 + echo "Hello Venus!" | ipfs block put
165 '
166
167 test_expect_success "multi-block 'ipfs block rm -q' produces no output" '
168 - ipfs block rm -q $HASH $HASH2 > block_rm_out &&
169 - test ! -s block_rm_out
168 + ipfs block rm -q $HASH $HASH2 > block_rm_out &&
169 + test ! -s block_rm_out
170 '
171
172 test_expect_success "can set cid format on block put" '
173 - HASH=$(ipfs block put --format=protobuf ../t0051-object-data/testPut.pb)
173 + HASH=$(ipfs block put --format=protobuf ../t0051-object-data/testPut.pb)
174 '
175
176 test_expect_success "created an object correctly!" '
177 - ipfs object get $HASH > obj_out &&
178 - echo "{\"Links\":[],\"Data\":\"test json for sharness test\"}" > obj_exp &&
179 - test_cmp obj_out obj_exp
177 + ipfs object get $HASH > obj_out &&
178 + echo "{\"Links\":[],\"Data\":\"test json for sharness test\"}" > obj_exp &&
179 + test_cmp obj_out obj_exp
180 '
181
182 test_expect_success "block get output looks right" '
183 - ipfs block get $HASH > pb_block_out &&
184 - test_cmp pb_block_out ../t0051-object-data/testPut.pb
183 + ipfs block get $HASH > pb_block_out &&
184 + test_cmp pb_block_out ../t0051-object-data/testPut.pb
185 '
186
187 test_expect_success "can set multihash type and length on block put" '
188 - HASH=$(echo "foooo" | ipfs block put --format=raw --mhtype=sha3 --mhlen=16)
188 + HASH=$(echo "foooo" | ipfs block put --format=raw --mhtype=sha3 --mhlen=16)
189 '
190
191 test_expect_success "output looks good" '
192 - test "z25ScPysKoxJBcPxczn9NvuHiZU5" = "$HASH"
192 + test "z25ScPysKoxJBcPxczn9NvuHiZU5" = "$HASH"
193 '
194
195 test_expect_success "can read block with different hash" '
196 - ipfs block get $HASH > blk_get_out &&
197 - echo "foooo" > blk_get_exp &&
198 - test_cmp blk_get_exp blk_get_out
196 + ipfs block get $HASH > blk_get_out &&
197 + echo "foooo" > blk_get_exp &&
198 + test_cmp blk_get_exp blk_get_out
199 '
200 #
201 # Misc tests
202 #
203
204 test_expect_success "'ipfs block stat' with nothing from stdin doesnt crash" '
205 - test_expect_code 1 ipfs block stat < /dev/null 2> stat_out
205 + test_expect_code 1 ipfs block stat < /dev/null 2> stat_out
206 '
207
208 test_expect_success "no panic in output" '
209 - test_expect_code 1 grep "panic" stat_out
209 + test_expect_code 1 grep "panic" stat_out
210 '
211
212 test_done
test/sharness/t0051-object.sh
+300 -300
@@ -11,317 +11,317 @@ test_description="Test object command"
11 test_init_ipfs
12
13 test_patch_create_path() {
14 - root=$1
15 - name=$2
16 - target=$3
17 -
18 - test_expect_success "object patch --create works" '
19 - PCOUT=$(ipfs object patch $root add-link --create $name $target)
20 - '
21 -
22 - test_expect_success "output looks good" '
23 - ipfs cat "$PCOUT/$name" >tpcp_out &&
24 - ipfs cat "$target" >tpcp_exp &&
25 - test_cmp tpcp_exp tpcp_out
26 - '
14 + root=$1
15 + name=$2
16 + target=$3
17 +
18 + test_expect_success "object patch --create works" '
19 + PCOUT=$(ipfs object patch $root add-link --create $name $target)
20 + '
21 +
22 + test_expect_success "output looks good" '
23 + ipfs cat "$PCOUT/$name" >tpcp_out &&
24 + ipfs cat "$target" >tpcp_exp &&
25 + test_cmp tpcp_exp tpcp_out
26 + '
27 }
28
29 test_object_cmd() {
30
31 - test_expect_success "'ipfs add testData' succeeds" '
32 - printf "Hello Mars" >expected_in &&
33 - ipfs add expected_in >actual_Addout
34 - '
35 -
36 - test_expect_success "'ipfs add testData' output looks good" '
37 - HASH="QmWkHFpYBZ9mpPRreRbMhhYWXfUhBAue3JkbbpFqwowSRb" &&
38 - echo "added $HASH expected_in" >expected_Addout &&
39 - test_cmp expected_Addout actual_Addout
40 - '
41 -
42 - test_expect_success "'ipfs object get' succeeds" '
43 - ipfs object get $HASH >actual_getOut
44 - '
45 -
46 - test_expect_success "'ipfs object get' output looks good" '
47 - test_cmp ../t0051-object-data/expected_getOut actual_getOut
48 - '
49 -
50 - test_expect_success "'ipfs object stat' succeeds" '
51 - ipfs object stat $HASH >actual_stat
52 - '
53 -
54 - test_expect_success "'ipfs object get' output looks good" '
55 - echo "NumLinks: 0" > expected_stat &&
56 - echo "BlockSize: 18" >> expected_stat &&
57 - echo "LinksSize: 2" >> expected_stat &&
58 - echo "DataSize: 16" >> expected_stat &&
59 - echo "CumulativeSize: 18" >> expected_stat &&
60 - test_cmp expected_stat actual_stat
61 - '
62 -
63 - test_expect_success "'ipfs object put file.json' succeeds" '
64 - ipfs object put ../t0051-object-data/testPut.json > actual_putOut
65 - '
66 -
67 - test_expect_success "'ipfs object put file.json' output looks good" '
68 - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
69 - printf "added $HASH\n" > expected_putOut &&
70 - test_cmp expected_putOut actual_putOut
71 - '
72 -
73 - test_expect_success "'ipfs object put file.xml' succeeds" '
74 - ipfs object put ../t0051-object-data/testPut.xml --inputenc=xml > actual_putOut
75 - '
76 -
77 - test_expect_success "'ipfs object put file.xml' output looks good" '
78 - HASH="QmQzNKUHy4HyEUGkqKe3q3t796ffPLQXYCkHCcXUNT5JNK" &&
79 - printf "added $HASH\n" > expected_putOut &&
80 - test_cmp expected_putOut actual_putOut
81 - '
82 -
83 - test_expect_success "'ipfs object put' from stdin succeeds" '
84 - cat ../t0051-object-data/testPut.xml | ipfs object put --inputenc=xml > actual_putStdinOut
85 - '
86 -
87 - test_expect_success "'ipfs object put broken.xml' should fail" '
88 - test_expect_code 1 ipfs object put ../t0051-object-data/brokenPut.xml --inputenc=xml 2>actual_putBrokenErr >actual_putBroken
89 - '
90 -
91 - test_expect_success "'ipfs object put broken.hxml' output looks good" '
92 - touch expected_putBroken &&
93 - printf "Error: no data or links in this node\n" > expected_putBrokenErr &&
94 - test_cmp expected_putBroken actual_putBroken &&
95 - test_cmp expected_putBrokenErr actual_putBrokenErr
96 - '
97 - test_expect_success "'ipfs object get --enc=xml' succeeds" '
98 - ipfs object get --enc=xml $HASH >utf8_xml
99 - '
100 -
101 - test_expect_success "'ipfs object put --inputenc=xml' succeeds" '
102 - ipfs object put --inputenc=xml <utf8_xml >actual
103 - '
104 -
105 - test_expect_failure "'ipfs object put --inputenc=xml' output looks good" '
106 - echo "added $HASH\n" >expected &&
107 - test_cmp expected actual
108 - '
109 -
110 - test_expect_success "'ipfs object put file.pb' succeeds" '
111 - ipfs object put --inputenc=protobuf ../t0051-object-data/testPut.pb > actual_putOut
112 - '
113 -
114 - test_expect_success "'ipfs object put file.pb' output looks good" '
115 - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
116 - printf "added $HASH\n" > expected_putOut &&
117 - test_cmp expected_putOut actual_putOut
118 - '
119 -
120 - test_expect_success "'ipfs object put' from stdin succeeds" '
121 - cat ../t0051-object-data/testPut.json | ipfs object put > actual_putStdinOut
122 - '
123 -
124 - test_expect_success "'ipfs object put' from stdin output looks good" '
125 - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
126 - printf "added $HASH\n" > expected_putStdinOut &&
127 - test_cmp expected_putStdinOut actual_putStdinOut
128 - '
129 -
130 - test_expect_success "'ipfs object put' from stdin (pb) succeeds" '
131 - cat ../t0051-object-data/testPut.pb | ipfs object put --inputenc=protobuf > actual_putPbStdinOut
132 - '
133 -
134 - test_expect_success "'ipfs object put' from stdin (pb) output looks good" '
135 - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
136 - printf "added $HASH\n" > expected_putStdinOut &&
137 - test_cmp expected_putStdinOut actual_putPbStdinOut
138 - '
139 -
140 - test_expect_success "'ipfs object put broken.json' should fail" '
141 - test_expect_code 1 ipfs object put ../t0051-object-data/brokenPut.json 2>actual_putBrokenErr >actual_putBroken
142 - '
143 -
144 - test_expect_success "'ipfs object put broken.hjson' output looks good" '
145 - touch expected_putBroken &&
146 - printf "Error: no data or links in this node\n" > expected_putBrokenErr &&
147 - test_cmp expected_putBroken actual_putBroken &&
148 - test_cmp expected_putBrokenErr actual_putBrokenErr
149 - '
150 -
151 - test_expect_success "setup: add UTF-8 test file" '
152 - HASH="QmNY5sQeH9ttVCg24sizH71dNbcZTpGd7Yb3YwsKZ4jiFP" &&
153 - ipfs add ../t0051-object-data/UTF-8-test.txt >actual &&
154 - echo "added $HASH UTF-8-test.txt" >expected &&
155 - test_cmp expected actual
156 - '
157 -
158 - test_expect_success "'ipfs object get --enc=json' succeeds" '
159 - ipfs object get --enc=json $HASH >utf8_json
160 - '
161 -
162 - test_expect_success "'ipfs object put --inputenc=json' succeeds" '
163 - ipfs object put --inputenc=json <utf8_json >actual
164 - '
165 -
166 - test_expect_failure "'ipfs object put --inputenc=json' output looks good" '
167 - echo "added $HASH" >expected &&
168 - test_cmp expected actual
169 - '
170 -
171 - test_expect_success "'ipfs object put --pin' succeeds" '
172 - HASH="QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V" &&
173 - echo "added $HASH" >expected &&
174 - echo "{ \"Data\": \"abc\" }" | ipfs object put --pin >actual
175 - '
176 -
177 - test_expect_success "'ipfs object put --pin' output looks good" '
178 - echo "added $HASH" >expected &&
179 - test_cmp expected actual
180 - '
181 -
182 - test_expect_success "after gc, objects still acessible" '
183 - ipfs repo gc > /dev/null &&
184 - ipfs refs -r --timeout=2s $HASH > /dev/null
185 - '
186 -
187 - test_expect_success "'ipfs object patch' should work (no unixfs-dir)" '
188 - EMPTY_DIR=$(ipfs object new) &&
189 - OUTPUT=$(ipfs object patch $EMPTY_DIR add-link foo $EMPTY_DIR) &&
190 - ipfs object stat $OUTPUT
191 - '
192 -
193 - test_expect_success "'ipfs object patch' should work" '
194 - EMPTY_DIR=$(ipfs object new unixfs-dir) &&
195 - OUTPUT=$(ipfs object patch $EMPTY_DIR add-link foo $EMPTY_DIR) &&
196 - ipfs object stat $OUTPUT
197 - '
198 -
199 - test_expect_success "'ipfs object patch add-link' should work with paths" '
200 - EMPTY_DIR=$(ipfs object new unixfs-dir) &&
201 - N1=$(ipfs object patch $EMPTY_DIR add-link baz $EMPTY_DIR) &&
202 - N2=$(ipfs object patch $EMPTY_DIR add-link bar $N1) &&
203 - N3=$(ipfs object patch $EMPTY_DIR add-link foo /ipfs/$N2/bar) &&
204 - ipfs object stat /ipfs/$N3 > /dev/null &&
205 - ipfs object stat $N3/foo > /dev/null &&
206 - ipfs object stat /ipfs/$N3/foo/baz > /dev/null
207 - '
208 -
209 - test_expect_success "object patch creation looks right" '
210 - echo "QmPc73aWK9dgFBXe86P4PvQizHo9e5Qt7n7DAMXWuigFuG" > hash_exp &&
211 - echo $N3 > hash_actual &&
212 - test_cmp hash_exp hash_actual
213 - '
214 -
215 - test_expect_success "multilayer ipfs patch works" '
216 - echo "hello world" > hwfile &&
217 - FILE=$(ipfs add -q hwfile) &&
218 - EMPTY=$(ipfs object new unixfs-dir) &&
219 - ONE=$(ipfs object patch $EMPTY add-link b $EMPTY) &&
220 - TWO=$(ipfs object patch $EMPTY add-link a $ONE) &&
221 - ipfs object patch $TWO add-link a/b/c $FILE > multi_patch
222 - '
223 -
224 - test_expect_success "output looks good" '
225 - ipfs cat $(cat multi_patch)/a/b/c > hwfile_out &&
226 - test_cmp hwfile hwfile_out
227 - '
228 -
229 - test_expect_success "ipfs object stat path succeeds" '
230 - ipfs object stat $(cat multi_patch)/a > obj_stat_out
231 - '
232 -
233 - test_expect_success "ipfs object stat output looks good" '
234 - echo NumLinks: 1 > obj_stat_exp &&
235 - echo BlockSize: 47 >> obj_stat_exp &&
236 - echo LinksSize: 45 >> obj_stat_exp &&
237 - echo DataSize: 2 >> obj_stat_exp &&
238 - echo CumulativeSize: 114 >> obj_stat_exp &&
239 -
240 - test_cmp obj_stat_exp obj_stat_out
241 - '
242 -
243 - test_expect_success "should have created dir within a dir" '
244 - ipfs ls $OUTPUT > patched_output
245 - '
246 -
247 - test_expect_success "output looks good" '
248 - echo "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn 4 foo/" > patched_exp &&
249 - test_cmp patched_exp patched_output
250 - '
251 -
252 - test_expect_success "can remove the directory" '
253 - ipfs object patch $OUTPUT rm-link foo > rmlink_output
254 - '
255 -
256 - test_expect_success "output should be empty" '
257 - echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn > rmlink_exp &&
258 - test_cmp rmlink_exp rmlink_output
259 - '
260 -
261 - test_expect_success "multilayer rm-link should work" '
262 - ipfs object patch $(cat multi_patch) rm-link a/b/c > multi_link_rm_out
263 - '
264 -
265 - test_expect_success "output looks good" '
266 - echo "QmZD3r9cZjzU8huNY2JS9TC6n8daDfT8TmE8zBSqG31Wvq" > multi_link_rm_exp &&
267 - test_cmp multi_link_rm_exp multi_link_rm_out
268 - '
269 -
270 - test_patch_create_path $EMPTY a/b/c $FILE
271 -
272 - test_patch_create_path $EMPTY a $FILE
273 -
274 - test_patch_create_path $EMPTY a/b/b/b/b $FILE
275 -
276 - test_expect_success "can create blank object" '
277 - BLANK=$(ipfs object new)
278 - '
279 -
280 - test_patch_create_path $BLANK a $FILE
281 -
282 - test_expect_success "create bad path fails" '
283 - test_must_fail ipfs object patch $EMPTY add-link --create / $FILE
284 - '
285 -
286 - test_expect_success "patch set-data works" '
287 - EMPTY=$(ipfs object new) &&
288 - HASH=$(printf "foo" | ipfs object patch $EMPTY set-data)
289 - '
290 -
291 - test_expect_success "output looks good" '
292 - echo "{\"Links\":[],\"Data\":\"foo\"}" > exp_data_set &&
293 - ipfs object get $HASH > actual_data_set &&
294 - test_cmp exp_data_set actual_data_set
295 - '
296 -
297 - test_expect_success "patch append-data works" '
298 - HASH=$(printf "bar" | ipfs object patch $HASH append-data)
299 - '
300 -
301 - test_expect_success "output looks good" '
302 - echo "{\"Links\":[],\"Data\":\"foobar\"}" > exp_data_append &&
303 - ipfs object get $HASH > actual_data_append &&
304 - test_cmp exp_data_append actual_data_append
305 - '
31 + test_expect_success "'ipfs add testData' succeeds" '
32 + printf "Hello Mars" >expected_in &&
33 + ipfs add expected_in >actual_Addout
34 + '
35 +
36 + test_expect_success "'ipfs add testData' output looks good" '
37 + HASH="QmWkHFpYBZ9mpPRreRbMhhYWXfUhBAue3JkbbpFqwowSRb" &&
38 + echo "added $HASH expected_in" >expected_Addout &&
39 + test_cmp expected_Addout actual_Addout
40 + '
41 +
42 + test_expect_success "'ipfs object get' succeeds" '
43 + ipfs object get $HASH >actual_getOut
44 + '
45 +
46 + test_expect_success "'ipfs object get' output looks good" '
47 + test_cmp ../t0051-object-data/expected_getOut actual_getOut
48 + '
49 +
50 + test_expect_success "'ipfs object stat' succeeds" '
51 + ipfs object stat $HASH >actual_stat
52 + '
53 +
54 + test_expect_success "'ipfs object get' output looks good" '
55 + echo "NumLinks: 0" > expected_stat &&
56 + echo "BlockSize: 18" >> expected_stat &&
57 + echo "LinksSize: 2" >> expected_stat &&
58 + echo "DataSize: 16" >> expected_stat &&
59 + echo "CumulativeSize: 18" >> expected_stat &&
60 + test_cmp expected_stat actual_stat
61 + '
62 +
63 + test_expect_success "'ipfs object put file.json' succeeds" '
64 + ipfs object put ../t0051-object-data/testPut.json > actual_putOut
65 + '
66 +
67 + test_expect_success "'ipfs object put file.json' output looks good" '
68 + HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
69 + printf "added $HASH\n" > expected_putOut &&
70 + test_cmp expected_putOut actual_putOut
71 + '
72 +
73 + test_expect_success "'ipfs object put file.xml' succeeds" '
74 + ipfs object put ../t0051-object-data/testPut.xml --inputenc=xml > actual_putOut
75 + '
76 +
77 + test_expect_success "'ipfs object put file.xml' output looks good" '
78 + HASH="QmQzNKUHy4HyEUGkqKe3q3t796ffPLQXYCkHCcXUNT5JNK" &&
79 + printf "added $HASH\n" > expected_putOut &&
80 + test_cmp expected_putOut actual_putOut
81 + '
82 +
83 + test_expect_success "'ipfs object put' from stdin succeeds" '
84 + cat ../t0051-object-data/testPut.xml | ipfs object put --inputenc=xml > actual_putStdinOut
85 + '
86 +
87 + test_expect_success "'ipfs object put broken.xml' should fail" '
88 + test_expect_code 1 ipfs object put ../t0051-object-data/brokenPut.xml --inputenc=xml 2>actual_putBrokenErr >actual_putBroken
89 + '
90 +
91 + test_expect_success "'ipfs object put broken.hxml' output looks good" '
92 + touch expected_putBroken &&
93 + printf "Error: no data or links in this node\n" > expected_putBrokenErr &&
94 + test_cmp expected_putBroken actual_putBroken &&
95 + test_cmp expected_putBrokenErr actual_putBrokenErr
96 + '
97 + test_expect_success "'ipfs object get --enc=xml' succeeds" '
98 + ipfs object get --enc=xml $HASH >utf8_xml
99 + '
100 +
101 + test_expect_success "'ipfs object put --inputenc=xml' succeeds" '
102 + ipfs object put --inputenc=xml <utf8_xml >actual
103 + '
104 +
105 + test_expect_failure "'ipfs object put --inputenc=xml' output looks good" '
106 + echo "added $HASH\n" >expected &&
107 + test_cmp expected actual
108 + '
109 +
110 + test_expect_success "'ipfs object put file.pb' succeeds" '
111 + ipfs object put --inputenc=protobuf ../t0051-object-data/testPut.pb > actual_putOut
112 + '
113 +
114 + test_expect_success "'ipfs object put file.pb' output looks good" '
115 + HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
116 + printf "added $HASH\n" > expected_putOut &&
117 + test_cmp expected_putOut actual_putOut
118 + '
119 +
120 + test_expect_success "'ipfs object put' from stdin succeeds" '
121 + cat ../t0051-object-data/testPut.json | ipfs object put > actual_putStdinOut
122 + '
123 +
124 + test_expect_success "'ipfs object put' from stdin output looks good" '
125 + HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
126 + printf "added $HASH\n" > expected_putStdinOut &&
127 + test_cmp expected_putStdinOut actual_putStdinOut
128 + '
129 +
130 + test_expect_success "'ipfs object put' from stdin (pb) succeeds" '
131 + cat ../t0051-object-data/testPut.pb | ipfs object put --inputenc=protobuf > actual_putPbStdinOut
132 + '
133 +
134 + test_expect_success "'ipfs object put' from stdin (pb) output looks good" '
135 + HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" &&
136 + printf "added $HASH\n" > expected_putStdinOut &&
137 + test_cmp expected_putStdinOut actual_putPbStdinOut
138 + '
139 +
140 + test_expect_success "'ipfs object put broken.json' should fail" '
141 + test_expect_code 1 ipfs object put ../t0051-object-data/brokenPut.json 2>actual_putBrokenErr >actual_putBroken
142 + '
143 +
144 + test_expect_success "'ipfs object put broken.hjson' output looks good" '
145 + touch expected_putBroken &&
146 + printf "Error: no data or links in this node\n" > expected_putBrokenErr &&
147 + test_cmp expected_putBroken actual_putBroken &&
148 + test_cmp expected_putBrokenErr actual_putBrokenErr
149 + '
150 +
151 + test_expect_success "setup: add UTF-8 test file" '
152 + HASH="QmNY5sQeH9ttVCg24sizH71dNbcZTpGd7Yb3YwsKZ4jiFP" &&
153 + ipfs add ../t0051-object-data/UTF-8-test.txt >actual &&
154 + echo "added $HASH UTF-8-test.txt" >expected &&
155 + test_cmp expected actual
156 + '
157 +
158 + test_expect_success "'ipfs object get --enc=json' succeeds" '
159 + ipfs object get --enc=json $HASH >utf8_json
160 + '
161 +
162 + test_expect_success "'ipfs object put --inputenc=json' succeeds" '
163 + ipfs object put --inputenc=json <utf8_json >actual
164 + '
165 +
166 + test_expect_failure "'ipfs object put --inputenc=json' output looks good" '
167 + echo "added $HASH" >expected &&
168 + test_cmp expected actual
169 + '
170 +
171 + test_expect_success "'ipfs object put --pin' succeeds" '
172 + HASH="QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V" &&
173 + echo "added $HASH" >expected &&
174 + echo "{ \"Data\": \"abc\" }" | ipfs object put --pin >actual
175 + '
176 +
177 + test_expect_success "'ipfs object put --pin' output looks good" '
178 + echo "added $HASH" >expected &&
179 + test_cmp expected actual
180 + '
181 +
182 + test_expect_success "after gc, objects still acessible" '
183 + ipfs repo gc > /dev/null &&
184 + ipfs refs -r --timeout=2s $HASH > /dev/null
185 + '
186 +
187 + test_expect_success "'ipfs object patch' should work (no unixfs-dir)" '
188 + EMPTY_DIR=$(ipfs object new) &&
189 + OUTPUT=$(ipfs object patch $EMPTY_DIR add-link foo $EMPTY_DIR) &&
190 + ipfs object stat $OUTPUT
191 + '
192 +
193 + test_expect_success "'ipfs object patch' should work" '
194 + EMPTY_DIR=$(ipfs object new unixfs-dir) &&
195 + OUTPUT=$(ipfs object patch $EMPTY_DIR add-link foo $EMPTY_DIR) &&
196 + ipfs object stat $OUTPUT
197 + '
198 +
199 + test_expect_success "'ipfs object patch add-link' should work with paths" '
200 + EMPTY_DIR=$(ipfs object new unixfs-dir) &&
201 + N1=$(ipfs object patch $EMPTY_DIR add-link baz $EMPTY_DIR) &&
202 + N2=$(ipfs object patch $EMPTY_DIR add-link bar $N1) &&
203 + N3=$(ipfs object patch $EMPTY_DIR add-link foo /ipfs/$N2/bar) &&
204 + ipfs object stat /ipfs/$N3 > /dev/null &&
205 + ipfs object stat $N3/foo > /dev/null &&
206 + ipfs object stat /ipfs/$N3/foo/baz > /dev/null
207 + '
208 +
209 + test_expect_success "object patch creation looks right" '
210 + echo "QmPc73aWK9dgFBXe86P4PvQizHo9e5Qt7n7DAMXWuigFuG" > hash_exp &&
211 + echo $N3 > hash_actual &&
212 + test_cmp hash_exp hash_actual
213 + '
214 +
215 + test_expect_success "multilayer ipfs patch works" '
216 + echo "hello world" > hwfile &&
217 + FILE=$(ipfs add -q hwfile) &&
218 + EMPTY=$(ipfs object new unixfs-dir) &&
219 + ONE=$(ipfs object patch $EMPTY add-link b $EMPTY) &&
220 + TWO=$(ipfs object patch $EMPTY add-link a $ONE) &&
221 + ipfs object patch $TWO add-link a/b/c $FILE > multi_patch
222 + '
223 +
224 + test_expect_success "output looks good" '
225 + ipfs cat $(cat multi_patch)/a/b/c > hwfile_out &&
226 + test_cmp hwfile hwfile_out
227 + '
228 +
229 + test_expect_success "ipfs object stat path succeeds" '
230 + ipfs object stat $(cat multi_patch)/a > obj_stat_out
231 + '
232 +
233 + test_expect_success "ipfs object stat output looks good" '
234 + echo NumLinks: 1 > obj_stat_exp &&
235 + echo BlockSize: 47 >> obj_stat_exp &&
236 + echo LinksSize: 45 >> obj_stat_exp &&
237 + echo DataSize: 2 >> obj_stat_exp &&
238 + echo CumulativeSize: 114 >> obj_stat_exp &&
239 +
240 + test_cmp obj_stat_exp obj_stat_out
241 + '
242 +
243 + test_expect_success "should have created dir within a dir" '
244 + ipfs ls $OUTPUT > patched_output
245 + '
246 +
247 + test_expect_success "output looks good" '
248 + echo "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn 4 foo/" > patched_exp &&
249 + test_cmp patched_exp patched_output
250 + '
251 +
252 + test_expect_success "can remove the directory" '
253 + ipfs object patch $OUTPUT rm-link foo > rmlink_output
254 + '
255 +
256 + test_expect_success "output should be empty" '
257 + echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn > rmlink_exp &&
258 + test_cmp rmlink_exp rmlink_output
259 + '
260 +
261 + test_expect_success "multilayer rm-link should work" '
262 + ipfs object patch $(cat multi_patch) rm-link a/b/c > multi_link_rm_out
263 + '
264 +
265 + test_expect_success "output looks good" '
266 + echo "QmZD3r9cZjzU8huNY2JS9TC6n8daDfT8TmE8zBSqG31Wvq" > multi_link_rm_exp &&
267 + test_cmp multi_link_rm_exp multi_link_rm_out
268 + '
269 +
270 + test_patch_create_path $EMPTY a/b/c $FILE
271 +
272 + test_patch_create_path $EMPTY a $FILE
273 +
274 + test_patch_create_path $EMPTY a/b/b/b/b $FILE
275 +
276 + test_expect_success "can create blank object" '
277 + BLANK=$(ipfs object new)
278 + '
279 +
280 + test_patch_create_path $BLANK a $FILE
281 +
282 + test_expect_success "create bad path fails" '
283 + test_must_fail ipfs object patch $EMPTY add-link --create / $FILE
284 + '
285 +
286 + test_expect_success "patch set-data works" '
287 + EMPTY=$(ipfs object new) &&
288 + HASH=$(printf "foo" | ipfs object patch $EMPTY set-data)
289 + '
290 +
291 + test_expect_success "output looks good" '
292 + echo "{\"Links\":[],\"Data\":\"foo\"}" > exp_data_set &&
293 + ipfs object get $HASH > actual_data_set &&
294 + test_cmp exp_data_set actual_data_set
295 + '
296 +
297 + test_expect_success "patch append-data works" '
298 + HASH=$(printf "bar" | ipfs object patch $HASH append-data)
299 + '
300 +
301 + test_expect_success "output looks good" '
302 + echo "{\"Links\":[],\"Data\":\"foobar\"}" > exp_data_append &&
303 + ipfs object get $HASH > actual_data_append &&
304 + test_cmp exp_data_append actual_data_append
305 + '
306 }
307
308 test_object_content_type() {
309
310 - test_expect_success "'ipfs object get --encoding=protobuf' returns the correct content type" '
311 - curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=protobuf" | grep -q "^Content-Type: application/protobuf"
312 - '
310 + test_expect_success "'ipfs object get --encoding=protobuf' returns the correct content type" '
311 + curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=protobuf" | grep -q "^Content-Type: application/protobuf"
312 + '
313
314 - test_expect_success "'ipfs object get --encoding=json' returns the correct content type" '
315 - curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=json" | grep -q "^Content-Type: application/json"
316 - '
314 + test_expect_success "'ipfs object get --encoding=json' returns the correct content type" '
315 + curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=json" | grep -q "^Content-Type: application/json"
316 + '
317
318 - test_expect_success "'ipfs object get --encoding=text' returns the correct content type" '
319 - curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=text" | grep -q "^Content-Type: text/plain"
320 - '
318 + test_expect_success "'ipfs object get --encoding=text' returns the correct content type" '
319 + curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=text" | grep -q "^Content-Type: text/plain"
320 + '
321
322 - test_expect_success "'ipfs object get --encoding=xml' returns the correct content type" '
323 - curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=xml" | grep -q "^Content-Type: application/xml"
324 - '
322 + test_expect_success "'ipfs object get --encoding=xml' returns the correct content type" '
323 + curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=xml" | grep -q "^Content-Type: application/xml"
324 + '
325 }
326
327 # should work offline
test/sharness/t0052-object-diff.sh
+28 -28
@@ -11,70 +11,70 @@ test_description="Test object diff command"
11 test_init_ipfs
12
13 test_expect_success "create some objects for testing diffs" '
14 - mkdir foo &&
15 - echo "stuff" > foo/bar &&
16 - mkdir foo/baz &&
17 - A=$(ipfs add -r -q foo | tail -n1) &&
18 - echo "more things" > foo/cat &&
19 - B=$(ipfs add -r -q foo | tail -n1) &&
20 - echo "nested" > foo/baz/dog &&
21 - C=$(ipfs add -r -q foo | tail -n1)
22 - echo "changed" > foo/bar &&
23 - D=$(ipfs add -r -q foo | tail -n1)
14 + mkdir foo &&
15 + echo "stuff" > foo/bar &&
16 + mkdir foo/baz &&
17 + A=$(ipfs add -r -q foo | tail -n1) &&
18 + echo "more things" > foo/cat &&
19 + B=$(ipfs add -r -q foo | tail -n1) &&
20 + echo "nested" > foo/baz/dog &&
21 + C=$(ipfs add -r -q foo | tail -n1)
22 + echo "changed" > foo/bar &&
23 + D=$(ipfs add -r -q foo | tail -n1)
24 '
25
26 test_expect_success "diff against self is empty" '
27 - ipfs object diff $A $A > diff_out
27 + ipfs object diff $A $A > diff_out
28 '
29
30 test_expect_success "identity diff output looks good" '
31 - printf "" > diff_exp &&
32 - test_cmp diff_exp diff_out
31 + printf "" > diff_exp &&
32 + test_cmp diff_exp diff_out
33 '
34
35 test_expect_success "diff added link works" '
36 - ipfs object diff $A $B > diff_out
36 + ipfs object diff $A $B > diff_out
37 '
38
39 test_expect_success "diff added link looks right" '
40 - echo + QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A \"cat\" > diff_exp &&
41 - test_cmp diff_exp diff_out
40 + echo + QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A \"cat\" > diff_exp &&
41 + test_cmp diff_exp diff_out
42 '
43
44 test_expect_success "verbose diff added link works" '
45 - ipfs object diff -v $A $B > diff_out
45 + ipfs object diff -v $A $B > diff_out
46 '
47
48 test_expect_success "verbose diff added link looks right" '
49 - echo Added new link \"cat\" pointing to QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A. > diff_exp &&
50 - test_cmp diff_exp diff_out
49 + echo Added new link \"cat\" pointing to QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A. > diff_exp &&
50 + test_cmp diff_exp diff_out
51 '
52
53 test_expect_success "diff removed link works" '
54 - ipfs object diff -v $B $A > diff_out
54 + ipfs object diff -v $B $A > diff_out
55 '
56
57 test_expect_success "diff removed link looks right" '
58 - echo Removed link \"cat\" \(was QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A\). > diff_exp &&
59 - test_cmp diff_exp diff_out
58 + echo Removed link \"cat\" \(was QmUSvcqzhdfYM1KLDbM76eLPdS9ANFtkJvFuPYeZt73d7A\). > diff_exp &&
59 + test_cmp diff_exp diff_out
60 '
61
62 test_expect_success "diff nested add works" '
63 - ipfs object diff -v $B $C > diff_out
63 + ipfs object diff -v $B $C > diff_out
64 '
65
66 test_expect_success "diff looks right" '
67 - echo Added new link \"baz/dog\" pointing to QmdNJQUTZuDpsUcec7YDuCfRfvw1w4J13DCm7YcU4VMZdS. > diff_exp &&
68 - test_cmp diff_exp diff_out
67 + echo Added new link \"baz/dog\" pointing to QmdNJQUTZuDpsUcec7YDuCfRfvw1w4J13DCm7YcU4VMZdS. > diff_exp &&
68 + test_cmp diff_exp diff_out
69 '
70
71 test_expect_success "diff changed link works" '
72 - ipfs object diff -v $C $D > diff_out
72 + ipfs object diff -v $C $D > diff_out
73 '
74
75 test_expect_success "diff looks right" '
76 - echo Changed \"bar\" from QmNgd5cz2jNftnAHBhcRUGdtiaMzb5Rhjqd4etondHHST8 to QmRfFVsjSXkhFxrfWnLpMae2M4GBVsry6VAuYYcji5MiZb. > diff_exp &&
77 - test_cmp diff_exp diff_out
76 + echo Changed \"bar\" from QmNgd5cz2jNftnAHBhcRUGdtiaMzb5Rhjqd4etondHHST8 to QmRfFVsjSXkhFxrfWnLpMae2M4GBVsry6VAuYYcji5MiZb. > diff_exp &&
77 + test_cmp diff_exp diff_out
78 '
79
80 test_done
test/sharness/t0053-dag.sh
+183 -183
@@ -11,195 +11,195 @@ test_description="Test dag command"
11 test_init_ipfs
12
13 test_expect_success "make a few test files" '
14 - echo "foo" > file1 &&
15 - echo "bar" > file2 &&
16 - echo "baz" > file3 &&
17 - echo "qux" > file4 &&
18 - HASH1=$(ipfs add --pin=false -q file1) &&
19 - HASH2=$(ipfs add --pin=false -q file2) &&
20 - HASH3=$(ipfs add --pin=false -q file3) &&
21 - HASH4=$(ipfs add --pin=false -q file4)
14 + echo "foo" > file1 &&
15 + echo "bar" > file2 &&
16 + echo "baz" > file3 &&
17 + echo "qux" > file4 &&
18 + HASH1=$(ipfs add --pin=false -q file1) &&
19 + HASH2=$(ipfs add --pin=false -q file2) &&
20 + HASH3=$(ipfs add --pin=false -q file3) &&
21 + HASH4=$(ipfs add --pin=false -q file4)
22 '
23
24 test_expect_success "make an ipld object in json" '
25 - printf "{\"hello\":\"world\",\"cats\":[{\"/\":\"%s\"},{\"water\":{\"/\":\"%s\"}}],\"magic\":{\"/\":\"%s\"},\"sub\":{\"dict\":\"ionary\",\"beep\":[0,\"bop\"]}}" $HASH1 $HASH2 $HASH3 > ipld_object
25 + printf "{\"hello\":\"world\",\"cats\":[{\"/\":\"%s\"},{\"water\":{\"/\":\"%s\"}}],\"magic\":{\"/\":\"%s\"},\"sub\":{\"dict\":\"ionary\",\"beep\":[0,\"bop\"]}}" $HASH1 $HASH2 $HASH3 > ipld_object
26 '
27
28 test_dag_cmd() {
29 - test_expect_success "can add an ipld object" '
30 - IPLDHASH=$(cat ipld_object | ipfs dag put)
31 - '
32 -
33 - test_expect_success "output looks correct" '
34 - EXPHASH="zdpuAsXfkHapxohc8LtsCzYiAsy84ESqKRD8eWuY64tt9r2CE"
35 - test $EXPHASH = $IPLDHASH
36 - '
37 -
38 - test_expect_success "various path traversals work" '
39 - ipfs cat $IPLDHASH/cats/0 > out1 &&
40 - ipfs cat $IPLDHASH/cats/1/water > out2 &&
41 - ipfs cat $IPLDHASH/magic > out3
42 - '
43 -
44 - test_expect_success "outputs look correct" '
45 - test_cmp file1 out1 &&
46 - test_cmp file2 out2 &&
47 - test_cmp file3 out3
48 - '
49 -
50 - test_expect_success "resolving sub-objects works" '
51 - ipfs dag get $IPLDHASH/hello > sub1 &&
52 - ipfs dag get $IPLDHASH/sub > sub2 &&
53 - ipfs dag get $IPLDHASH/sub/beep > sub3 &&
54 - ipfs dag get $IPLDHASH/sub/beep/0 > sub4 &&
55 - ipfs dag get $IPLDHASH/sub/beep/1 > sub5
56 - '
57 -
58 - test_expect_success "sub-objects look right" '
59 - echo "\"world\"" > sub1_exp &&
60 - test_cmp sub1_exp sub1 &&
61 - echo "{\"beep\":[0,\"bop\"],\"dict\":\"ionary\"}" > sub2_exp &&
62 - test_cmp sub2_exp sub2 &&
63 - echo "[0,\"bop\"]" > sub3_exp &&
64 - test_cmp sub3_exp sub3 &&
65 - echo "0" > sub4_exp &&
66 - test_cmp sub4_exp sub4 &&
67 - echo "\"bop\"" > sub5_exp &&
68 - test_cmp sub5_exp sub5
69 - '
70 -
71 - test_expect_success "can pin cbor object" '
72 - ipfs pin add $EXPHASH
73 - '
74 -
75 - test_expect_success "after gc, objects still acessible" '
76 - ipfs repo gc > /dev/null &&
77 - ipfs refs -r --timeout=2s $EXPHASH > /dev/null
78 - '
79 -
80 - test_expect_success "can get object" '
81 - ipfs dag get $IPLDHASH > ipld_obj_out
82 - '
83 -
84 - test_expect_success "object links look right" '
85 - grep "{\"/\":\"" ipld_obj_out > /dev/null
86 - '
87 -
88 - test_expect_success "retreived object hashes back correctly" '
89 - IPLDHASH2=$(cat ipld_obj_out | ipfs dag put) &&
90 - test "$IPLDHASH" = "$IPLDHASH2"
91 - '
92 -
93 - test_expect_success "add a normal file" '
94 - HASH=$(echo "foobar" | ipfs add -q)
95 - '
96 -
97 - test_expect_success "can view protobuf object with dag get" '
98 - ipfs dag get $HASH > dag_get_pb_out
99 - '
100 -
101 - test_expect_success "output looks correct" '
102 - echo "{\"data\":\"CAISB2Zvb2JhcgoYBw==\",\"links\":[]}" > dag_get_pb_exp &&
103 - test_cmp dag_get_pb_exp dag_get_pb_out
104 - '
105 -
106 - test_expect_success "can call dag get with a path" '
107 - ipfs dag get $IPLDHASH/cats/0 > cat_out
108 - '
109 -
110 - test_expect_success "output looks correct" '
111 - echo "{\"data\":\"CAISBGZvbwoYBA==\",\"links\":[]}" > cat_exp &&
112 - test_cmp cat_exp cat_out
113 - '
114 -
115 - test_expect_success "non-canonical cbor input is normalized" '
116 - HASH=$(cat ../t0053-dag-data/non-canon.cbor | ipfs dag put --format=cbor --input-enc=raw) &&
117 - test $HASH = "zdpuAmxF8q6iTUtkB3xtEYzmc5Sw762qwQJftt5iW8NTWLtjC" ||
118 - test_fsh echo $HASH
119 - '
120 -
121 - test_expect_success "non-canonical cbor input is normalized with input-enc cbor" '
122 - HASH=$(cat ../t0053-dag-data/non-canon.cbor | ipfs dag put --format=cbor --input-enc=cbor) &&
123 - test $HASH = "zdpuAmxF8q6iTUtkB3xtEYzmc5Sw762qwQJftt5iW8NTWLtjC" ||
124 - test_fsh echo $HASH
125 - '
126 -
127 - test_expect_success "add an ipld with pin" '
128 - PINHASH=$(printf {\"foo\":\"bar\"} | ipfs dag put --pin=true)
129 - '
130 -
131 - test_expect_success "after gc, objects still acessible" '
132 - ipfs repo gc > /dev/null &&
133 - ipfs refs -r --timeout=2s $PINHASH > /dev/null
134 - '
135 -
136 - test_expect_success "can add an ipld object with sha3 hash" '
137 - IPLDHASH=$(cat ipld_object | ipfs dag put --hash sha3)
138 - '
139 -
140 - test_expect_success "output looks correct" '
141 - EXPHASH="zBwWX8u9LYZdCWqaryJW8QsBstghHSPy41nfhhFLY9qw1Vu2BWqnMFtk1jL3qCtEdGd7Kqw1HNPZv5z8LxP2eHGGDCdRE"
142 - test $EXPHASH = $IPLDHASH
143 - '
144 -
145 - test_expect_success "prepare dag-pb object" '
146 - echo foo > test_file &&
147 - HASH=$(ipfs add -wq test_file | tail -n1)
148 - '
149 -
150 - test_expect_success "dag put with json dag-pb works" '
151 - ipfs dag get $HASH > pbjson &&
152 - cat pbjson | ipfs dag put --format=dag-pb --input-enc=json > dag_put_out
153 - '
154 -
155 - test_expect_success "dag put with dag-pb works output looks good" '
156 - echo $HASH > dag_put_exp &&
157 - test_cmp dag_put_exp dag_put_out
158 - '
159 -
160 - test_expect_success "dag put with raw dag-pb works" '
161 - ipfs block get $HASH > pbraw &&
162 - cat pbraw | ipfs dag put --format=dag-pb --input-enc=raw > dag_put_out
163 - '
164 -
165 - test_expect_success "dag put with dag-pb works output looks good" '
166 - echo $HASH > dag_put_exp &&
167 - test_cmp dag_put_exp dag_put_out
168 - '
169 -
170 - test_expect_success "dag put multiple files" '
171 - printf {\"foo\":\"bar\"} > a.json &&
172 - printf {\"foo\":\"baz\"} > b.json &&
173 - ipfs dag put a.json b.json > dag_put_out
174 - '
175 -
176 - test_expect_success "dag put multiple files output looks good" '
177 - echo zdpuAoKMEvka7gKGSjF9B3of1F5gE5MyMMywxTC13wCmouQrf > dag_put_exp &&
178 - echo zdpuAogmDEvpvGjMFsNTGDEU1JMYe6v69oxR8nG81EurmGHMj >> dag_put_exp &&
179 -
180 - test_cmp dag_put_exp dag_put_out
181 - '
182 -
183 - test_expect_success "prepare data for dag resolve" '
184 - NESTED_HASH=$(echo "{\"data\":123}" | ipfs dag put) &&
185 - HASH=$(echo "{\"obj\":{\"/\":\"${NESTED_HASH}\"}}" | ipfs dag put)
186 - '
187 -
188 - test_expect_success "dag resolve some things" '
189 - ipfs dag resolve $HASH > resolve_hash &&
190 - ipfs dag resolve ${HASH}/obj > resolve_obj &&
191 - ipfs dag resolve ${HASH}/obj/data > resolve_data
192 - '
193 -
194 - test_expect_success "dag resolve output looks good" '
195 - printf $HASH > resolve_hash_exp &&
196 - printf $NESTED_HASH > resolve_obj_exp &&
197 - printf $NESTED_HASH/data > resolve_data_exp &&
198 -
199 - test_cmp resolve_hash_exp resolve_hash &&
200 - test_cmp resolve_obj_exp resolve_obj &&
201 - test_cmp resolve_data_exp resolve_data
202 - '
29 + test_expect_success "can add an ipld object" '
30 + IPLDHASH=$(cat ipld_object | ipfs dag put)
31 + '
32 +
33 + test_expect_success "output looks correct" '
34 + EXPHASH="zdpuAsXfkHapxohc8LtsCzYiAsy84ESqKRD8eWuY64tt9r2CE"
35 + test $EXPHASH = $IPLDHASH
36 + '
37 +
38 + test_expect_success "various path traversals work" '
39 + ipfs cat $IPLDHASH/cats/0 > out1 &&
40 + ipfs cat $IPLDHASH/cats/1/water > out2 &&
41 + ipfs cat $IPLDHASH/magic > out3
42 + '
43 +
44 + test_expect_success "outputs look correct" '
45 + test_cmp file1 out1 &&
46 + test_cmp file2 out2 &&
47 + test_cmp file3 out3
48 + '
49 +
50 + test_expect_success "resolving sub-objects works" '
51 + ipfs dag get $IPLDHASH/hello > sub1 &&
52 + ipfs dag get $IPLDHASH/sub > sub2 &&
53 + ipfs dag get $IPLDHASH/sub/beep > sub3 &&
54 + ipfs dag get $IPLDHASH/sub/beep/0 > sub4 &&
55 + ipfs dag get $IPLDHASH/sub/beep/1 > sub5
56 + '
57 +
58 + test_expect_success "sub-objects look right" '
59 + echo "\"world\"" > sub1_exp &&
60 + test_cmp sub1_exp sub1 &&
61 + echo "{\"beep\":[0,\"bop\"],\"dict\":\"ionary\"}" > sub2_exp &&
62 + test_cmp sub2_exp sub2 &&
63 + echo "[0,\"bop\"]" > sub3_exp &&
64 + test_cmp sub3_exp sub3 &&
65 + echo "0" > sub4_exp &&
66 + test_cmp sub4_exp sub4 &&
67 + echo "\"bop\"" > sub5_exp &&
68 + test_cmp sub5_exp sub5
69 + '
70 +
71 + test_expect_success "can pin cbor object" '
72 + ipfs pin add $EXPHASH
73 + '
74 +
75 + test_expect_success "after gc, objects still acessible" '
76 + ipfs repo gc > /dev/null &&
77 + ipfs refs -r --timeout=2s $EXPHASH > /dev/null
78 + '
79 +
80 + test_expect_success "can get object" '
81 + ipfs dag get $IPLDHASH > ipld_obj_out
82 + '
83 +
84 + test_expect_success "object links look right" '
85 + grep "{\"/\":\"" ipld_obj_out > /dev/null
86 + '
87 +
88 + test_expect_success "retreived object hashes back correctly" '
89 + IPLDHASH2=$(cat ipld_obj_out | ipfs dag put) &&
90 + test "$IPLDHASH" = "$IPLDHASH2"
91 + '
92 +
93 + test_expect_success "add a normal file" '
94 + HASH=$(echo "foobar" | ipfs add -q)
95 + '
96 +
97 + test_expect_success "can view protobuf object with dag get" '
98 + ipfs dag get $HASH > dag_get_pb_out
99 + '
100 +
101 + test_expect_success "output looks correct" '
102 + echo "{\"data\":\"CAISB2Zvb2JhcgoYBw==\",\"links\":[]}" > dag_get_pb_exp &&
103 + test_cmp dag_get_pb_exp dag_get_pb_out
104 + '
105 +
106 + test_expect_success "can call dag get with a path" '
107 + ipfs dag get $IPLDHASH/cats/0 > cat_out
108 + '
109 +
110 + test_expect_success "output looks correct" '
111 + echo "{\"data\":\"CAISBGZvbwoYBA==\",\"links\":[]}" > cat_exp &&
112 + test_cmp cat_exp cat_out
113 + '
114 +
115 + test_expect_success "non-canonical cbor input is normalized" '
116 + HASH=$(cat ../t0053-dag-data/non-canon.cbor | ipfs dag put --format=cbor --input-enc=raw) &&
117 + test $HASH = "zdpuAmxF8q6iTUtkB3xtEYzmc5Sw762qwQJftt5iW8NTWLtjC" ||
118 + test_fsh echo $HASH
119 + '
120 +
121 + test_expect_success "non-canonical cbor input is normalized with input-enc cbor" '
122 + HASH=$(cat ../t0053-dag-data/non-canon.cbor | ipfs dag put --format=cbor --input-enc=cbor) &&
123 + test $HASH = "zdpuAmxF8q6iTUtkB3xtEYzmc5Sw762qwQJftt5iW8NTWLtjC" ||
124 + test_fsh echo $HASH
125 + '
126 +
127 + test_expect_success "add an ipld with pin" '
128 + PINHASH=$(printf {\"foo\":\"bar\"} | ipfs dag put --pin=true)
129 + '
130 +
131 + test_expect_success "after gc, objects still acessible" '
132 + ipfs repo gc > /dev/null &&
133 + ipfs refs -r --timeout=2s $PINHASH > /dev/null
134 + '
135 +
136 + test_expect_success "can add an ipld object with sha3 hash" '
137 + IPLDHASH=$(cat ipld_object | ipfs dag put --hash sha3)
138 + '
139 +
140 + test_expect_success "output looks correct" '
141 + EXPHASH="zBwWX8u9LYZdCWqaryJW8QsBstghHSPy41nfhhFLY9qw1Vu2BWqnMFtk1jL3qCtEdGd7Kqw1HNPZv5z8LxP2eHGGDCdRE"
142 + test $EXPHASH = $IPLDHASH
143 + '
144 +
145 + test_expect_success "prepare dag-pb object" '
146 + echo foo > test_file &&
147 + HASH=$(ipfs add -wq test_file | tail -n1)
148 + '
149 +
150 + test_expect_success "dag put with json dag-pb works" '
151 + ipfs dag get $HASH > pbjson &&
152 + cat pbjson | ipfs dag put --format=dag-pb --input-enc=json > dag_put_out
153 + '
154 +
155 + test_expect_success "dag put with dag-pb works output looks good" '
156 + echo $HASH > dag_put_exp &&
157 + test_cmp dag_put_exp dag_put_out
158 + '
159 +
160 + test_expect_success "dag put with raw dag-pb works" '
161 + ipfs block get $HASH > pbraw &&
162 + cat pbraw | ipfs dag put --format=dag-pb --input-enc=raw > dag_put_out
163 + '
164 +
165 + test_expect_success "dag put with dag-pb works output looks good" '
166 + echo $HASH > dag_put_exp &&
167 + test_cmp dag_put_exp dag_put_out
168 + '
169 +
170 + test_expect_success "dag put multiple files" '
171 + printf {\"foo\":\"bar\"} > a.json &&
172 + printf {\"foo\":\"baz\"} > b.json &&
173 + ipfs dag put a.json b.json > dag_put_out
174 + '
175 +
176 + test_expect_success "dag put multiple files output looks good" '
177 + echo zdpuAoKMEvka7gKGSjF9B3of1F5gE5MyMMywxTC13wCmouQrf > dag_put_exp &&
178 + echo zdpuAogmDEvpvGjMFsNTGDEU1JMYe6v69oxR8nG81EurmGHMj >> dag_put_exp &&
179 +
180 + test_cmp dag_put_exp dag_put_out
181 + '
182 +
183 + test_expect_success "prepare data for dag resolve" '
184 + NESTED_HASH=$(echo "{\"data\":123}" | ipfs dag put) &&
185 + HASH=$(echo "{\"obj\":{\"/\":\"${NESTED_HASH}\"}}" | ipfs dag put)
186 + '
187 +
188 + test_expect_success "dag resolve some things" '
189 + ipfs dag resolve $HASH > resolve_hash &&
190 + ipfs dag resolve ${HASH}/obj > resolve_obj &&
191 + ipfs dag resolve ${HASH}/obj/data > resolve_data
192 + '
193 +
194 + test_expect_success "dag resolve output looks good" '
195 + printf $HASH > resolve_hash_exp &&
196 + printf $NESTED_HASH > resolve_obj_exp &&
197 + printf $NESTED_HASH/data > resolve_data_exp &&
198 +
199 + test_cmp resolve_hash_exp resolve_hash &&
200 + test_cmp resolve_obj_exp resolve_obj &&
201 + test_cmp resolve_data_exp resolve_data
202 + '
203 }
204
205 # should work offline
test/sharness/t0060-daemon.sh
+48 -48
@@ -14,116 +14,116 @@ test_launch_ipfs_daemon
14
15 # this errors if we didn't --init $IPFS_PATH correctly
16 test_expect_success "'ipfs config Identity.PeerID' works" '
17 - PEERID=$(ipfs config Identity.PeerID)
17 + PEERID=$(ipfs config Identity.PeerID)
18 '
19
20 test_expect_success "'ipfs swarm addrs local' works" '
21 - ipfs swarm addrs local >local_addrs
21 + ipfs swarm addrs local >local_addrs
22 '
23
24 test_expect_success "ipfs swarm addrs listen; works" '
25 - ipfs swarm addrs listen >listen_addrs
25 + ipfs swarm addrs listen >listen_addrs
26 '
27
28 test_expect_success "ipfs peer id looks good" '
29 - test_check_peerid "$PEERID"
29 + test_check_peerid "$PEERID"
30 '
31
32 # this is for checking SetAllowedOrigins race condition for the api and gateway
33 # See https://github.com/ipfs/go-ipfs/pull/1966
34 test_expect_success "ipfs API works with the correct allowed origin port" '
35 - curl -s -X GET -H "Origin:http://localhost:$API_PORT" -I "http://$API_ADDR/api/v0/version"
35 + curl -s -X GET -H "Origin:http://localhost:$API_PORT" -I "http://$API_ADDR/api/v0/version"
36 '
37
38 test_expect_success "ipfs gateway works with the correct allowed origin port" '
39 - curl -s -X GET -H "Origin:http://localhost:$GWAY_PORT" -I "http://$GWAY_ADDR/api/v0/version"
39 + curl -s -X GET -H "Origin:http://localhost:$GWAY_PORT" -I "http://$GWAY_ADDR/api/v0/version"
40 '
41
42 test_expect_success "ipfs daemon output looks good" '
43 - STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" &&
44 - echo "Initializing daemon..." >expected_daemon &&
45 - sed "s/^/Swarm listening on /" listen_addrs >>expected_daemon &&
46 - sed "s/^/Swarm announcing /" local_addrs >>expected_daemon &&
47 - echo "API server listening on '$API_MADDR'" >>expected_daemon &&
48 - echo "Gateway (readonly) server listening on '$GWAY_MADDR'" >>expected_daemon &&
49 - echo "Daemon is ready" >>expected_daemon &&
50 - test_cmp expected_daemon actual_daemon
43 + STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" &&
44 + echo "Initializing daemon..." >expected_daemon &&
45 + sed "s/^/Swarm listening on /" listen_addrs >>expected_daemon &&
46 + sed "s/^/Swarm announcing /" local_addrs >>expected_daemon &&
47 + echo "API server listening on '$API_MADDR'" >>expected_daemon &&
48 + echo "Gateway (readonly) server listening on '$GWAY_MADDR'" >>expected_daemon &&
49 + echo "Daemon is ready" >>expected_daemon &&
50 + test_cmp expected_daemon actual_daemon
51 '
52
53 test_expect_success ".ipfs/ has been created" '
54 - test -d ".ipfs" &&
55 - test -f ".ipfs/config" &&
56 - test -d ".ipfs/datastore" &&
57 - test -d ".ipfs/blocks" ||
58 - test_fsh ls -al .ipfs
54 + test -d ".ipfs" &&
55 + test -f ".ipfs/config" &&
56 + test -d ".ipfs/datastore" &&
57 + test -d ".ipfs/blocks" ||
58 + test_fsh ls -al .ipfs
59 '
60
61 # begin same as in t0010
62
63 test_expect_success "ipfs version succeeds" '
64 - ipfs version >version.txt
64 + ipfs version >version.txt
65 '
66
67 test_expect_success "ipfs version output looks good" '
68 - egrep "^ipfs version [0-9]+\.[0-9]+\.[0-9]" version.txt >/dev/null ||
69 - test_fsh cat version.txt
68 + egrep "^ipfs version [0-9]+\.[0-9]+\.[0-9]" version.txt >/dev/null ||
69 + test_fsh cat version.txt
70 '
71
72 test_expect_success "ipfs help succeeds" '
73 - ipfs help >help.txt
73 + ipfs help >help.txt
74 '
75
76 test_expect_success "ipfs help output looks good" '
77 - egrep -i "^Usage" help.txt >/dev/null &&
78 - egrep "ipfs .* <command>" help.txt >/dev/null ||
79 - test_fsh cat help.txt
77 + egrep -i "^Usage" help.txt >/dev/null &&
78 + egrep "ipfs .* <command>" help.txt >/dev/null ||
79 + test_fsh cat help.txt
80 '
81
82 # netcat (nc) is needed for the following test
83 test_expect_success "nc is available" '
84 - type nc >/dev/null
84 + type nc >/dev/null
85 '
86
87 # check transport is encrypted
88 test_expect_success "transport should be encrypted" '
89 - nc -w 1 localhost $SWARM_PORT > swarmnc < ../t0060-data/mss-ls &&
90 - grep -q "/secio" swarmnc &&
91 - test_must_fail grep -q "/plaintext/1.0.0" swarmnc ||
92 - test_fsh cat swarmnc
89 + nc -w 1 localhost $SWARM_PORT > swarmnc < ../t0060-data/mss-ls &&
90 + grep -q "/secio" swarmnc &&
91 + test_must_fail grep -q "/plaintext/1.0.0" swarmnc ||
92 + test_fsh cat swarmnc
93 '
94
95 test_expect_success "output from streaming commands works" '
96 - test_expect_code 28 curl -m 5 http://localhost:$API_PORT/api/v0/stats/bw\?poll=true > statsout
96 + test_expect_code 28 curl -m 5 http://localhost:$API_PORT/api/v0/stats/bw\?poll=true > statsout
97 '
98
99 test_expect_success "output looks good" '
100 - grep TotalIn statsout > /dev/null &&
101 - grep TotalOut statsout > /dev/null &&
102 - grep RateIn statsout > /dev/null &&
103 - grep RateOut statsout >/dev/null
100 + grep TotalIn statsout > /dev/null &&
101 + grep TotalOut statsout > /dev/null &&
102 + grep RateIn statsout > /dev/null &&
103 + grep RateOut statsout >/dev/null
104 '
105
106 # end same as in t0010
107
108 test_expect_success "daemon is still running" '
109 - kill -0 $IPFS_PID
109 + kill -0 $IPFS_PID
110 '
111
112 test_expect_success "'ipfs daemon' can be killed" '
113 - test_kill_repeat_10_sec $IPFS_PID
113 + test_kill_repeat_10_sec $IPFS_PID
114 '
115
116 test_expect_success "'ipfs daemon' should be able to run with a pipe attached to stdin (issue #861)" '
117 - yes | ipfs daemon >stdin_daemon_out 2>stdin_daemon_err &
118 - DAEMON_PID=$!
119 - test_wait_for_file 20 100ms "$IPFS_PATH/api" &&
120 - test_set_address_vars stdin_daemon_out
117 + yes | ipfs daemon >stdin_daemon_out 2>stdin_daemon_err &
118 + DAEMON_PID=$!
119 + test_wait_for_file 20 100ms "$IPFS_PATH/api" &&
120 + test_set_address_vars stdin_daemon_out
121 '
122
123 test_expect_success "daemon with pipe eventually becomes live" '
124 - pollEndpoint -host='$API_MADDR' -ep=/version -v -tout=1s -tries=10 >stdin_poll_apiout 2>stdin_poll_apierr &&
125 - test_kill_repeat_10_sec $DAEMON_PID ||
126 - test_fsh cat stdin_daemon_out || test_fsh cat stdin_daemon_err || test_fsh cat stdin_poll_apiout || test_fsh cat stdin_poll_apierr
124 + pollEndpoint -host='$API_MADDR' -ep=/version -v -tout=1s -tries=10 >stdin_poll_apiout 2>stdin_poll_apierr &&
125 + test_kill_repeat_10_sec $DAEMON_PID ||
126 + test_fsh cat stdin_daemon_out || test_fsh cat stdin_daemon_err || test_fsh cat stdin_poll_apiout || test_fsh cat stdin_poll_apierr
127 '
128
129 ulimit -S -n 512
@@ -131,15 +131,15 @@ TEST_ULIMIT_PRESET=1
131 test_launch_ipfs_daemon
132
133 test_expect_success "daemon raised its fd limit" '
134 - grep "raised file descriptor limit to 2048." actual_daemon > /dev/null
134 + grep "raised file descriptor limit to 2048." actual_daemon > /dev/null
135 '
136
137 test_expect_success "daemon actually can handle 2048 file descriptors" '
138 - hang-fds -hold=2s 2000 '$API_MADDR' > /dev/null
138 + hang-fds -hold=2s 2000 '$API_MADDR' > /dev/null
139 '
140
141 test_expect_success "daemon didnt throw any errors" '
142 - test_expect_code 1 grep "too many open files" daemon_err
142 + test_expect_code 1 grep "too many open files" daemon_err
143 '
144
145 test_kill_ipfs_daemon
test/sharness/t0061-daemon-opts.sh
+11 -11
@@ -18,10 +18,10 @@ apiaddr=$API_ADDR
18
19 # Odd. this fails here, but the inverse works on t0060-daemon.
20 test_expect_success 'transport should be unencrypted' '
21 - nc -w 1 localhost $SWARM_PORT > swarmnc < ../t0060-data/mss-ls &&
22 - test_must_fail grep -q "/secio" swarmnc &&
23 - grep -q "/plaintext" swarmnc ||
24 - test_fsh cat swarmnc
21 + nc -w 1 localhost $SWARM_PORT > swarmnc < ../t0060-data/mss-ls &&
22 + test_must_fail grep -q "/secio" swarmnc &&
23 + grep -q "/plaintext" swarmnc ||
24 + test_fsh cat swarmnc
25 '
26
27 test_kill_ipfs_daemon
@@ -32,21 +32,21 @@ gwyaddr=$GWAY_ADDR
32 apiaddr=$API_ADDR
33
34 test_expect_success 'gateway should work in offline mode' '
35 - echo "hello mars :$gwyaddr :$apiaddr" >expected &&
36 - HASH=$(ipfs add -q expected) &&
37 - curl -sfo actual1 "http://$gwyaddr/ipfs/$HASH" &&
38 - test_cmp expected actual1
35 + echo "hello mars :$gwyaddr :$apiaddr" >expected &&
36 + HASH=$(ipfs add -q expected) &&
37 + curl -sfo actual1 "http://$gwyaddr/ipfs/$HASH" &&
38 + test_cmp expected actual1
39 '
40
41 test_kill_ipfs_daemon
42
43 test_expect_success 'daemon should not start with bad dht opt' '
44 - test_must_fail ipfs daemon --routing=fdsfdsfds > daemon_output 2>&1
44 + test_must_fail ipfs daemon --routing=fdsfdsfds > daemon_output 2>&1
45 '
46
47 test_expect_success 'output contains info about dht option' '
48 - grep "unrecognized routing option:" daemon_output ||
49 - test_fsh cat daemon_output
48 + grep "unrecognized routing option:" daemon_output ||
49 + test_fsh cat daemon_output
50 '
51
52 test_done
test/sharness/t0062-daemon-api.sh
+40 -40
@@ -14,54 +14,54 @@ api_other="/ip4/127.0.0.1/tcp/$differentport"
14 api_unreachable="/ip4/127.0.0.1/tcp/1"
15
16 test_expect_success "config setup" '
17 - peerid=$(ipfs config Identity.PeerID) &&
18 - test_check_peerid "$peerid"
17 + peerid=$(ipfs config Identity.PeerID) &&
18 + test_check_peerid "$peerid"
19 '
20
21 test_client() {
22 - opts="$@"
23 - echo "OPTS = " $opts
24 - test_expect_success "client must work properly $state" '
25 - printf "$peerid" >expected &&
26 - ipfs id -f="<id>" $opts >actual &&
27 - test_cmp expected actual
28 - '
22 + opts="$@"
23 + echo "OPTS = " $opts
24 + test_expect_success "client must work properly $state" '
25 + printf "$peerid" >expected &&
26 + ipfs id -f="<id>" $opts >actual &&
27 + test_cmp expected actual
28 + '
29 }
30
31 test_client_must_fail() {
32 - opts="$@"
33 - echo "OPTS = " $opts
34 - test_expect_success "client should fail $state" '
35 - echo "Error: api not running" >expected_err &&
36 - test_must_fail ipfs id -f="<id>" $opts >actual 2>actual_err &&
37 - test_cmp expected_err actual_err
38 - '
32 + opts="$@"
33 + echo "OPTS = " $opts
34 + test_expect_success "client should fail $state" '
35 + echo "Error: api not running" >expected_err &&
36 + test_must_fail ipfs id -f="<id>" $opts >actual 2>actual_err &&
37 + test_cmp expected_err actual_err
38 + '
39 }
40
41 test_client_suite() {
42 - state="$1"
43 - cfg_success="$2"
44 - diff_success="$3"
45 - api_fromcfg="$4"
46 - api_different="$5"
47 -
48 - # must always work
49 - test_client
50 -
51 - # must always err
52 - test_client_must_fail --api "$api_unreachable"
53 -
54 - if [ "$cfg_success" = true ]; then
55 - test_client --api "$api_fromcfg"
56 - else
57 - test_client_must_fail --api "$api_fromcfg"
58 - fi
59 -
60 - if [ "$diff_success" = true ]; then
61 - test_client --api "$api_different"
62 - else
63 - test_client_must_fail --api "$api_different"
64 - fi
42 + state="$1"
43 + cfg_success="$2"
44 + diff_success="$3"
45 + api_fromcfg="$4"
46 + api_different="$5"
47 +
48 + # must always work
49 + test_client
50 +
51 + # must always err
52 + test_client_must_fail --api "$api_unreachable"
53 +
54 + if [ "$cfg_success" = true ]; then
55 + test_client --api "$api_fromcfg"
56 + else
57 + test_client_must_fail --api "$api_fromcfg"
58 + fi
59 +
60 + if [ "$diff_success" = true ]; then
61 + test_client --api "$api_different"
62 + else
63 + test_client_must_fail --api "$api_different"
64 + fi
65 }
66
67 # first, test things without daemon, without /api file
@@ -75,7 +75,7 @@ test_client_suite "(daemon off, no --api, no /api file)" false false "$api_unrea
75 test_launch_ipfs_daemon
76
77 test_expect_success "'ipfs daemon' creates api file" '
78 - test -f ".ipfs/api"
78 + test -f ".ipfs/api"
79 '
80
81 test_client_suite "(daemon on, no --api, /api file from cfg)" true false "$API_MADDR" "$api_other"
test/sharness/t0063-daemon-init.sh
+21 -21
@@ -14,37 +14,37 @@ export IPFS_PATH="$(pwd)/.ipfs"
14
15 # safety check since we will be removing the directory
16 if [ -e "$IPFS_PATH" ]; then
17 - echo "$IPFS_PATH exists"
18 - exit 1
17 + echo "$IPFS_PATH exists"
18 + exit 1
19 fi
20
21 test_ipfs_daemon_init() {
22 - # Doing it manually since we want to launch the daemon with an
23 - # empty or non-existent repo; the normal
24 - # test_launch_ipfs_daemon does not work since it assumes the
25 - # repo was created a particular way with regard to the API
26 - # server.
27 -
28 - test_expect_success "'ipfs daemon --init' succeeds" '
29 - ipfs daemon --init >actual_daemon 2>daemon_err &
30 - IPFS_PID=$!
31 - sleep 2 &&
32 - if ! kill -0 $IPFS_PID; then cat daemon_err; return 1; fi
33 - '
34 -
35 - test_expect_success "'ipfs daemon' can be killed" '
36 - test_kill_repeat_10_sec $IPFS_PID
37 - '
22 + # Doing it manually since we want to launch the daemon with an
23 + # empty or non-existent repo; the normal
24 + # test_launch_ipfs_daemon does not work since it assumes the
25 + # repo was created a particular way with regard to the API
26 + # server.
27 +
28 + test_expect_success "'ipfs daemon --init' succeeds" '
29 + ipfs daemon --init >actual_daemon 2>daemon_err &
30 + IPFS_PID=$!
31 + sleep 2 &&
32 + if ! kill -0 $IPFS_PID; then cat daemon_err; return 1; fi
33 + '
34 +
35 + test_expect_success "'ipfs daemon' can be killed" '
36 + test_kill_repeat_10_sec $IPFS_PID
37 + '
38 }
39
40 test_expect_success "remove \$IPFS_PATH dir" '
41 - rm -rf "$IPFS_PATH"
41 + rm -rf "$IPFS_PATH"
42 '
43 test_ipfs_daemon_init
44
45 test_expect_success "create empty \$IPFS_PATH dir" '
46 - rm -rf "$IPFS_PATH" &&
47 - mkdir "$IPFS_PATH"
46 + rm -rf "$IPFS_PATH" &&
47 + mkdir "$IPFS_PATH"
48 '
49
50 test_ipfs_daemon_init
test/sharness/t0063-external.sh
+8 -8
@@ -17,20 +17,20 @@ test_init_ipfs
17 test_launch_ipfs_daemon
18
19 test_expect_success "create fake ipfs-update bin" '
20 - mkdir bin &&
21 - echo "#!/bin/sh" > bin/ipfs-update &&
22 - echo "pwd" >> bin/ipfs-update &&
23 - chmod +x bin/ipfs-update
20 + mkdir bin &&
21 + echo "#!/bin/sh" > bin/ipfs-update &&
22 + echo "pwd" >> bin/ipfs-update &&
23 + chmod +x bin/ipfs-update
24 '
25
26 test_expect_success "external command runs from current user directory" '
27 - mkdir just_for_test &&
28 - (cd just_for_test && ipfs update) > actual
27 + mkdir just_for_test &&
28 + (cd just_for_test && ipfs update) > actual
29 '
30
31 test_expect_success "output looks good" '
32 - echo `pwd`/just_for_test > exp &&
33 - test_cmp exp actual
32 + echo `pwd`/just_for_test > exp &&
33 + test_cmp exp actual
34 '
35
36 test_kill_ipfs_daemon
test/sharness/t0065-active-requests.sh
+13 -13
@@ -12,41 +12,41 @@ test_init_ipfs
12 test_launch_ipfs_daemon
13
14 test_expect_success "command works" '
15 - ipfs diag cmds > cmd_out
15 + ipfs diag cmds > cmd_out
16 '
17
18 test_expect_success "invoc shows up in output" '
19 - grep "diag/cmds" cmd_out > /dev/null
19 + grep "diag/cmds" cmd_out > /dev/null
20 '
21
22 test_expect_success "start longer running command" '
23 - ipfs log tail &
24 - LOGPID=$!
25 - go-sleep 100ms
23 + ipfs log tail &
24 + LOGPID=$!
25 + go-sleep 100ms
26 '
27
28 test_expect_success "long running command shows up" '
29 - ipfs diag cmds > cmd_out2
29 + ipfs diag cmds > cmd_out2
30 '
31
32 test_expect_success "output looks good" '
33 - grep "log/tail" cmd_out2 | grep "true" > /dev/null
33 + grep "log/tail" cmd_out2 | grep "true" > /dev/null
34 '
35
36 test_expect_success "kill log cmd" '
37 - kill $LOGPID
38 - go-sleep 0.5s
39 - kill $LOGPID
37 + kill $LOGPID
38 + go-sleep 0.5s
39 + kill $LOGPID
40
41 - wait $LOGPID || true
41 + wait $LOGPID || true
42 '
43
44 test_expect_success "long running command inactive" '
45 - ipfs diag cmds > cmd_out3
45 + ipfs diag cmds > cmd_out3
46 '
47
48 test_expect_success "command shows up as inactive" '
49 - grep "log/tail" cmd_out3 | grep "false"
49 + grep "log/tail" cmd_out3 | grep "false"
50 '
51
52 test_kill_ipfs_daemon
test/sharness/t0066-migration.sh
+15 -15
@@ -11,42 +11,42 @@ test_description="Test migrations auto update prompt"
11 test_init_ipfs
12
13 test_expect_success "setup mock migrations" '
14 - mkdir bin &&
15 - echo "#!/bin/bash" > bin/fs-repo-migrations &&
16 - echo "echo 5" >> bin/fs-repo-migrations &&
17 - chmod +x bin/fs-repo-migrations &&
18 - export PATH="$(pwd)/bin":$PATH
14 + mkdir bin &&
15 + echo "#!/bin/bash" > bin/fs-repo-migrations &&
16 + echo "echo 5" >> bin/fs-repo-migrations &&
17 + chmod +x bin/fs-repo-migrations &&
18 + export PATH="$(pwd)/bin":$PATH
19 '
20
21 test_expect_success "manually reset repo version to 3" '
22 - echo "3" > "$IPFS_PATH"/version
22 + echo "3" > "$IPFS_PATH"/version
23 '
24
25 test_expect_success "ipfs daemon --migrate=false fails" '
26 - test_expect_code 1 ipfs daemon --migrate=false > false_out
26 + test_expect_code 1 ipfs daemon --migrate=false > false_out
27 '
28
29 test_expect_success "output looks good" '
30 - grep "Please get fs-repo-migrations from https://dist.ipfs.io" false_out
30 + grep "Please get fs-repo-migrations from https://dist.ipfs.io" false_out
31 '
32
33 test_expect_success "ipfs daemon --migrate=true runs migration" '
34 - test_expect_code 1 ipfs daemon --migrate=true > true_out
34 + test_expect_code 1 ipfs daemon --migrate=true > true_out
35 '
36
37 test_expect_failure "output looks good" '
38 - grep "Running: " true_out > /dev/null &&
39 - grep "Success: fs-repo has been migrated to version 5." true_out > /dev/null
38 + grep "Running: " true_out > /dev/null &&
39 + grep "Success: fs-repo has been migrated to version 5." true_out > /dev/null
40 '
41
42 test_expect_success "'ipfs daemon' prompts to auto migrate" '
43 - test_expect_code 1 ipfs daemon > daemon_out 2> daemon_err
43 + test_expect_code 1 ipfs daemon > daemon_out 2> daemon_err
44 '
45
46 test_expect_success "output looks good" '
47 - grep "Found outdated fs-repo" daemon_out > /dev/null &&
48 - grep "Run migrations now?" daemon_out > /dev/null &&
49 - grep "Please get fs-repo-migrations from https://dist.ipfs.io" daemon_out > /dev/null
47 + grep "Found outdated fs-repo" daemon_out > /dev/null &&
48 + grep "Run migrations now?" daemon_out > /dev/null &&
49 + grep "Please get fs-repo-migrations from https://dist.ipfs.io" daemon_out > /dev/null
50 '
51
52 test_done
test/sharness/t0070-user-config.sh
+5 -5
@@ -11,11 +11,11 @@ test_description="Test user-provided config values"
11 test_init_ipfs
12
13 test_expect_success "bootstrap doesn't overwrite user-provided config keys (top-level)" '
14 - ipfs config Foo.Bar baz &&
15 - ipfs bootstrap rm --all &&
16 - echo "baz" >expected &&
17 - ipfs config Foo.Bar >actual &&
18 - test_cmp expected actual
14 + ipfs config Foo.Bar baz &&
15 + ipfs bootstrap rm --all &&
16 + echo "baz" >expected &&
17 + ipfs config Foo.Bar >actual &&
18 + test_cmp expected actual
19 '
20
21 test_done
test/sharness/t0080-repo.sh
+137 -137
@@ -12,253 +12,253 @@ test_init_ipfs
12 test_launch_ipfs_daemon --offline
13
14 test_expect_success "'ipfs repo gc' succeeds" '
15 - ipfs repo gc >gc_out_actual
15 + ipfs repo gc >gc_out_actual
16 '
17
18 test_expect_success "'ipfs add afile' succeeds" '
19 - echo "some text" >afile &&
20 - HASH=`ipfs add -q afile`
19 + echo "some text" >afile &&
20 + HASH=`ipfs add -q afile`
21 '
22
23 test_expect_success "added file was pinned" '
24 - ipfs pin ls --type=recursive >actual &&
25 - grep "$HASH" actual
24 + ipfs pin ls --type=recursive >actual &&
25 + grep "$HASH" actual
26 '
27
28 test_expect_success "'ipfs repo gc' succeeds" '
29 - ipfs repo gc >gc_out_actual
29 + ipfs repo gc >gc_out_actual
30 '
31
32 test_expect_success "'ipfs repo gc' looks good (patch root)" '
33 - PATCH_ROOT=QmQXirSbubiySKnqaFyfs5YzziXRB5JEVQVjU6xsd7innr &&
34 - grep "removed $PATCH_ROOT" gc_out_actual
33 + PATCH_ROOT=QmQXirSbubiySKnqaFyfs5YzziXRB5JEVQVjU6xsd7innr &&
34 + grep "removed $PATCH_ROOT" gc_out_actual
35 '
36
37 test_expect_success "'ipfs repo gc' doesnt remove file" '
38 - ipfs cat "$HASH" >out &&
39 - test_cmp out afile
38 + ipfs cat "$HASH" >out &&
39 + test_cmp out afile
40 '
41
42 test_expect_success "'ipfs pin rm' succeeds" '
43 - ipfs pin rm -r "$HASH" >actual1
43 + ipfs pin rm -r "$HASH" >actual1
44 '
45
46 test_expect_success "'ipfs pin rm' output looks good" '
47 - echo "unpinned $HASH" >expected1 &&
48 - test_cmp expected1 actual1
47 + echo "unpinned $HASH" >expected1 &&
48 + test_cmp expected1 actual1
49 '
50
51 test_expect_failure "ipfs repo gc fully reverse ipfs add" '
52 - ipfs repo gc &&
53 - random 100000 41 >gcfile &&
54 - disk_usage "$IPFS_PATH/blocks" >expected &&
55 - hash=`ipfs add -q gcfile` &&
56 - ipfs pin rm -r $hash &&
57 - ipfs repo gc &&
58 - disk_usage "$IPFS_PATH/blocks" >actual &&
59 - test_cmp expected actual
52 + ipfs repo gc &&
53 + random 100000 41 >gcfile &&
54 + disk_usage "$IPFS_PATH/blocks" >expected &&
55 + hash=`ipfs add -q gcfile` &&
56 + ipfs pin rm -r $hash &&
57 + ipfs repo gc &&
58 + disk_usage "$IPFS_PATH/blocks" >actual &&
59 + test_cmp expected actual
60 '
61
62 test_expect_success "file no longer pinned" '
63 - ipfs pin ls --type=recursive --quiet >actual2 &&
64 - test_expect_code 1 grep $HASH actual2
63 + ipfs pin ls --type=recursive --quiet >actual2 &&
64 + test_expect_code 1 grep $HASH actual2
65 '
66
67 test_expect_success "recursively pin afile(default action)" '
68 - HASH=`ipfs add -q afile` &&
69 - ipfs pin add "$HASH"
68 + HASH=`ipfs add -q afile` &&
69 + ipfs pin add "$HASH"
70 '
71
72 test_expect_success "recursively pin rm afile (default action)" '
73 - ipfs pin rm "$HASH"
73 + ipfs pin rm "$HASH"
74 '
75
76 test_expect_success "recursively pin afile" '
77 - ipfs pin add -r "$HASH"
77 + ipfs pin add -r "$HASH"
78 '
79
80 test_expect_success "pinning directly should fail now" '
81 - echo "Error: pin: $HASH already pinned recursively" >expected3 &&
82 - test_must_fail ipfs pin add -r=false "$HASH" 2>actual3 &&
83 - test_cmp expected3 actual3
81 + echo "Error: pin: $HASH already pinned recursively" >expected3 &&
82 + test_must_fail ipfs pin add -r=false "$HASH" 2>actual3 &&
83 + test_cmp expected3 actual3
84 '
85
86 test_expect_success "'ipfs pin rm -r=false <hash>' should fail" '
87 - echo "Error: $HASH is pinned recursively" >expected4 &&
88 - test_must_fail ipfs pin rm -r=false "$HASH" 2>actual4 &&
89 - test_cmp expected4 actual4
87 + echo "Error: $HASH is pinned recursively" >expected4 &&
88 + test_must_fail ipfs pin rm -r=false "$HASH" 2>actual4 &&
89 + test_cmp expected4 actual4
90 '
91
92 test_expect_success "remove recursive pin, add direct" '
93 - echo "unpinned $HASH" >expected5 &&
94 - ipfs pin rm -r "$HASH" >actual5 &&
95 - test_cmp expected5 actual5 &&
96 - ipfs pin add -r=false "$HASH"
93 + echo "unpinned $HASH" >expected5 &&
94 + ipfs pin rm -r "$HASH" >actual5 &&
95 + test_cmp expected5 actual5 &&
96 + ipfs pin add -r=false "$HASH"
97 '
98
99 test_expect_success "remove direct pin" '
100 - echo "unpinned $HASH" >expected6 &&
101 - ipfs pin rm "$HASH" >actual6 &&
102 - test_cmp expected6 actual6
100 + echo "unpinned $HASH" >expected6 &&
101 + ipfs pin rm "$HASH" >actual6 &&
102 + test_cmp expected6 actual6
103 '
104
105 test_expect_success "'ipfs repo gc' removes file" '
106 - ipfs repo gc >actual7 &&
107 - grep "removed $HASH" actual7 &&
108 - grep "removed $PATCH_ROOT" actual7
106 + ipfs repo gc >actual7 &&
107 + grep "removed $HASH" actual7 &&
108 + grep "removed $PATCH_ROOT" actual7
109 '
110
111 test_expect_success "'ipfs refs local' no longer shows file" '
112 - EMPTY_DIR=QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn &&
113 - ipfs refs local >actual8 &&
114 - grep "QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y" actual8 &&
115 - grep "$EMPTY_DIR" actual8 &&
116 - grep "$HASH_WELCOME_DOCS" actual8 &&
117 - test_must_fail grep "$HASH" actual8 &&
118 - test_must_fail grep "$PATCH_ROOT" actual8
112 + EMPTY_DIR=QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn &&
113 + ipfs refs local >actual8 &&
114 + grep "QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y" actual8 &&
115 + grep "$EMPTY_DIR" actual8 &&
116 + grep "$HASH_WELCOME_DOCS" actual8 &&
117 + test_must_fail grep "$HASH" actual8 &&
118 + test_must_fail grep "$PATCH_ROOT" actual8
119 '
120
121 test_expect_success "adding multiblock random file succeeds" '
122 - random 1000000 >multiblock &&
123 - MBLOCKHASH=`ipfs add -q multiblock`
122 + random 1000000 >multiblock &&
123 + MBLOCKHASH=`ipfs add -q multiblock`
124 '
125
126 test_expect_success "'ipfs pin ls --type=indirect' is correct" '
127 - ipfs refs "$MBLOCKHASH" >refsout &&
128 - ipfs refs -r "$HASH_WELCOME_DOCS" >>refsout &&
129 - sed -i"~" "s/\(.*\)/\1 indirect/g" refsout &&
130 - ipfs pin ls --type=indirect >indirectpins &&
131 - test_sort_cmp refsout indirectpins
127 + ipfs refs "$MBLOCKHASH" >refsout &&
128 + ipfs refs -r "$HASH_WELCOME_DOCS" >>refsout &&
129 + sed -i"~" "s/\(.*\)/\1 indirect/g" refsout &&
130 + ipfs pin ls --type=indirect >indirectpins &&
131 + test_sort_cmp refsout indirectpins
132 '
133
134 test_expect_success "pin something directly" '
135 - echo "ipfs is so awesome" >awesome &&
136 - DIRECTPIN=`ipfs add -q awesome` &&
137 - echo "unpinned $DIRECTPIN" >expected9 &&
138 - ipfs pin rm -r "$DIRECTPIN" >actual9 &&
139 - test_cmp expected9 actual9 &&
135 + echo "ipfs is so awesome" >awesome &&
136 + DIRECTPIN=`ipfs add -q awesome` &&
137 + echo "unpinned $DIRECTPIN" >expected9 &&
138 + ipfs pin rm -r "$DIRECTPIN" >actual9 &&
139 + test_cmp expected9 actual9 &&
140
141 - echo "pinned $DIRECTPIN directly" >expected10 &&
142 - ipfs pin add -r=false "$DIRECTPIN" >actual10 &&
143 - test_cmp expected10 actual10
141 + echo "pinned $DIRECTPIN directly" >expected10 &&
142 + ipfs pin add -r=false "$DIRECTPIN" >actual10 &&
143 + test_cmp expected10 actual10
144 '
145
146 test_expect_success "'ipfs pin ls --type=direct' is correct" '
147 - echo "$DIRECTPIN direct" >directpinexpected &&
148 - ipfs pin ls --type=direct >directpinout &&
149 - test_sort_cmp directpinexpected directpinout
147 + echo "$DIRECTPIN direct" >directpinexpected &&
148 + ipfs pin ls --type=direct >directpinout &&
149 + test_sort_cmp directpinexpected directpinout
150 '
151
152 test_expect_success "'ipfs pin ls --type=recursive' is correct" '
153 - echo "$MBLOCKHASH" >rp_expected &&
154 - echo "$HASH_WELCOME_DOCS" >>rp_expected &&
155 - echo "$EMPTY_DIR" >>rp_expected &&
156 - sed -i"~" "s/\(.*\)/\1 recursive/g" rp_expected &&
157 - ipfs pin ls --type=recursive >rp_actual &&
158 - test_sort_cmp rp_expected rp_actual
153 + echo "$MBLOCKHASH" >rp_expected &&
154 + echo "$HASH_WELCOME_DOCS" >>rp_expected &&
155 + echo "$EMPTY_DIR" >>rp_expected &&
156 + sed -i"~" "s/\(.*\)/\1 recursive/g" rp_expected &&
157 + ipfs pin ls --type=recursive >rp_actual &&
158 + test_sort_cmp rp_expected rp_actual
159 '
160
161 test_expect_success "'ipfs pin ls --type=all --quiet' is correct" '
162 - cat directpinout >allpins &&
163 - cat rp_actual >>allpins &&
164 - cat indirectpins >>allpins &&
165 - cut -f1 -d " " allpins | sort | uniq >> allpins_uniq_hashes &&
166 - ipfs pin ls --type=all --quiet >actual_allpins &&
167 - test_sort_cmp allpins_uniq_hashes actual_allpins
162 + cat directpinout >allpins &&
163 + cat rp_actual >>allpins &&
164 + cat indirectpins >>allpins &&
165 + cut -f1 -d " " allpins | sort | uniq >> allpins_uniq_hashes &&
166 + ipfs pin ls --type=all --quiet >actual_allpins &&
167 + test_sort_cmp allpins_uniq_hashes actual_allpins
168 '
169
170 test_expect_success "'ipfs refs --unique' is correct" '
171 - mkdir -p uniques &&
172 - cd uniques &&
173 - echo "content1" > file1 &&
174 - echo "content1" > file2 &&
175 - ipfs add -r -q . > ../add_output &&
176 - ROOT=$(tail -n1 ../add_output) &&
177 - ipfs refs --unique $ROOT >expected &&
178 - ipfs add -q file1 >unique_hash &&
179 - test_cmp expected unique_hash || test_fsh cat ../add_output
171 + mkdir -p uniques &&
172 + cd uniques &&
173 + echo "content1" > file1 &&
174 + echo "content1" > file2 &&
175 + ipfs add -r -q . > ../add_output &&
176 + ROOT=$(tail -n1 ../add_output) &&
177 + ipfs refs --unique $ROOT >expected &&
178 + ipfs add -q file1 >unique_hash &&
179 + test_cmp expected unique_hash || test_fsh cat ../add_output
180 '
181
182 test_expect_success "'ipfs refs --unique --recursive' is correct" '
183 - mkdir -p a/b/c &&
184 - echo "c1" > a/f1 &&
185 - echo "c1" > a/b/f1 &&
186 - echo "c1" > a/b/c/f1 &&
187 - echo "c2" > a/b/c/f2 &&
188 - ipfs add -r -q a >add_output &&
189 - ROOT=$(tail -n1 add_output) &&
190 - ipfs refs --unique --recursive $ROOT >refs_output &&
191 - wc -l refs_output | sed "s/^ *//g" >line_count &&
192 - echo "4 refs_output" >expected &&
193 - test_cmp expected line_count || test_fsh cat add_output || test_fsh cat refs_output
183 + mkdir -p a/b/c &&
184 + echo "c1" > a/f1 &&
185 + echo "c1" > a/b/f1 &&
186 + echo "c1" > a/b/c/f1 &&
187 + echo "c2" > a/b/c/f2 &&
188 + ipfs add -r -q a >add_output &&
189 + ROOT=$(tail -n1 add_output) &&
190 + ipfs refs --unique --recursive $ROOT >refs_output &&
191 + wc -l refs_output | sed "s/^ *//g" >line_count &&
192 + echo "4 refs_output" >expected &&
193 + test_cmp expected line_count || test_fsh cat add_output || test_fsh cat refs_output
194 '
195
196 test_expect_success "'ipfs refs --recursive (bigger)'" '
197 - mkdir -p b/c/d/e &&
198 - echo "content1" >b/f &&
199 - echo "content1" >b/c/f1 &&
200 - echo "content1" >b/c/d/f2 &&
201 - echo "content2" >b/c/f2 &&
202 - echo "content2" >b/c/d/f1 &&
203 - echo "content2" >b/c/d/e/f &&
204 - cp -r b b2 && mv b2 b/b2 &&
205 - cp -r b b3 && mv b3 b/b3 &&
206 - cp -r b b4 && mv b4 b/b4 &&
207 - ipfs add -r -q b >add_output &&
208 - hash=$(tail -n1 add_output) &&
209 - ipfs refs -r "$hash" >refs_output &&
210 - wc -l refs_output | sed "s/^ *//g" >actual &&
211 - echo "79 refs_output" >expected &&
212 - test_cmp expected actual || test_fsh cat add_output || test_fsh cat refs_output
197 + mkdir -p b/c/d/e &&
198 + echo "content1" >b/f &&
199 + echo "content1" >b/c/f1 &&
200 + echo "content1" >b/c/d/f2 &&
201 + echo "content2" >b/c/f2 &&
202 + echo "content2" >b/c/d/f1 &&
203 + echo "content2" >b/c/d/e/f &&
204 + cp -r b b2 && mv b2 b/b2 &&
205 + cp -r b b3 && mv b3 b/b3 &&
206 + cp -r b b4 && mv b4 b/b4 &&
207 + ipfs add -r -q b >add_output &&
208 + hash=$(tail -n1 add_output) &&
209 + ipfs refs -r "$hash" >refs_output &&
210 + wc -l refs_output | sed "s/^ *//g" >actual &&
211 + echo "79 refs_output" >expected &&
212 + test_cmp expected actual || test_fsh cat add_output || test_fsh cat refs_output
213 '
214
215 test_expect_success "'ipfs refs --unique --recursive (bigger)'" '
216 - ipfs refs -r "$hash" >refs_output &&
217 - sort refs_output | uniq >expected &&
218 - ipfs refs -r -u "$hash" >actual &&
219 - test_sort_cmp expected actual || test_fsh cat refs_output
216 + ipfs refs -r "$hash" >refs_output &&
217 + sort refs_output | uniq >expected &&
218 + ipfs refs -r -u "$hash" >actual &&
219 + test_sort_cmp expected actual || test_fsh cat refs_output
220 '
221
222 get_field_num() {
223 - field=$1
224 - file=$2
225 - num=$(grep "$field" "$file" | awk '{ print $2 }')
226 - echo $num
223 + field=$1
224 + file=$2
225 + num=$(grep "$field" "$file" | awk '{ print $2 }')
226 + echo $num
227 }
228
229 test_expect_success "'ipfs repo stat' succeeds" '
230 - ipfs repo stat > repo-stats
230 + ipfs repo stat > repo-stats
231 '
232 test_expect_success "repo stats came out correct" '
233 - grep "RepoPath" repo-stats &&
234 - grep "RepoSize" repo-stats &&
235 - grep "NumObjects" repo-stats &&
236 - grep "Version" repo-stats &&
237 - grep "StorageMax" repo-stats
233 + grep "RepoPath" repo-stats &&
234 + grep "RepoSize" repo-stats &&
235 + grep "NumObjects" repo-stats &&
236 + grep "Version" repo-stats &&
237 + grep "StorageMax" repo-stats
238 '
239
240 test_expect_success "'ipfs repo stat' after adding a file" '
241 - ipfs add repo-stats &&
242 - ipfs repo stat > repo-stats-2
241 + ipfs add repo-stats &&
242 + ipfs repo stat > repo-stats-2
243 '
244
245 test_expect_success "repo stats are updated correctly" '
246 - test $(get_field_num "RepoSize" repo-stats-2) -ge $(get_field_num "RepoSize" repo-stats)
246 + test $(get_field_num "RepoSize" repo-stats-2) -ge $(get_field_num "RepoSize" repo-stats)
247 '
248
249 test_expect_success "'ipfs repo version' succeeds" '
250 - ipfs repo version > repo-version
250 + ipfs repo version > repo-version
251 '
252
253 test_expect_success "repo version came out correct" '
254 - egrep "^ipfs repo version fs-repo@[0-9]+" repo-version >/dev/null
254 + egrep "^ipfs repo version fs-repo@[0-9]+" repo-version >/dev/null
255 '
256
257 test_expect_success "'ipfs repo version -q' succeeds" '
258 - ipfs repo version -q > repo-version-q
258 + ipfs repo version -q > repo-version-q
259 '
260 test_expect_success "repo version came out correct" '
261 - egrep "^fs-repo@[0-9]+" repo-version-q >/dev/null
261 + egrep "^fs-repo@[0-9]+" repo-version-q >/dev/null
262 '
263
264 test_kill_ipfs_daemon
test/sharness/t0081-repo-pinning.sh
+160 -160
@@ -9,41 +9,41 @@ test_description="Test ipfs repo pinning"
9 . lib/test-lib.sh
10
11 test_pin_flag() {
12 - object=$1
13 - ptype=$2
14 - expect=$3
15 -
16 - echo "test_pin_flag" "$@"
17 -
18 - if ipfs pin ls --type="$ptype" "$object" >actual
19 - then
20 - test "$expect" = "true" && return
21 - test_fsh cat actual
22 - return
23 - else
24 - test "$expect" = "false" && return
25 - test_fsh cat actual
26 - return
27 - fi
12 + object=$1
13 + ptype=$2
14 + expect=$3
15 +
16 + echo "test_pin_flag" "$@"
17 +
18 + if ipfs pin ls --type="$ptype" "$object" >actual
19 + then
20 + test "$expect" = "true" && return
21 + test_fsh cat actual
22 + return
23 + else
24 + test "$expect" = "false" && return
25 + test_fsh cat actual
26 + return
27 + fi
28 }
29
30 test_pin() {
31 - object=$1
32 - shift
31 + object=$1
32 + shift
33
34 - test_str_contains "recursive" $@
35 - [ "$?" = "0" ] && r="true" || r="false"
34 + test_str_contains "recursive" $@
35 + [ "$?" = "0" ] && r="true" || r="false"
36
37 - test_str_contains "indirect" $@
38 - [ "$?" = "0" ] && i="true" || i="false"
37 + test_str_contains "indirect" $@
38 + [ "$?" = "0" ] && i="true" || i="false"
39
40 - test_str_contains "direct" $@
41 - [ "$?" = "0" ] && d="true" || d="false"
40 + test_str_contains "direct" $@
41 + [ "$?" = "0" ] && d="true" || d="false"
42
43 - test_pin_flag "$object" "recursive" $r || return 1
44 - test_pin_flag "$object" "indirect" $i || return 1
45 - test_pin_flag "$object" "direct" $d || return 1
46 - return 0
43 + test_pin_flag "$object" "recursive" $r || return 1
44 + test_pin_flag "$object" "indirect" $i || return 1
45 + test_pin_flag "$object" "direct" $d || return 1
46 + return 0
47 }
48
49
@@ -80,204 +80,204 @@ FILE6="dir1/dir2/dir4/file6"
80 FILE5="dir1/dir3/file5"
81
82 test_expect_success "'ipfs add dir' succeeds" '
83 - mkdir dir1 &&
84 - mkdir dir1/dir2 &&
85 - mkdir dir1/dir2/dir4 &&
86 - mkdir dir1/dir3 &&
87 - echo "some text 1" >dir1/file1 &&
88 - echo "some text 2" >dir1/file2 &&
89 - echo "some text 3" >dir1/file3 &&
90 - echo "some text 1" >dir1/dir2/file1 &&
91 - echo "some text 4" >dir1/dir2/file4 &&
92 - echo "some text 1" >dir1/dir2/dir4/file1 &&
93 - echo "some text 2" >dir1/dir2/dir4/file2 &&
94 - echo "some text 6" >dir1/dir2/dir4/file6 &&
95 - echo "some text 2" >dir1/dir3/file2 &&
96 - echo "some text 5" >dir1/dir3/file5 &&
97 - ipfs add -q -r dir1 >actualall &&
98 - tail -n1 actualall >actual1 &&
99 - echo "$HASH_DIR1" >expected1 &&
100 - ipfs repo gc && # remove the patch chaff
101 - test_cmp expected1 actual1
83 + mkdir dir1 &&
84 + mkdir dir1/dir2 &&
85 + mkdir dir1/dir2/dir4 &&
86 + mkdir dir1/dir3 &&
87 + echo "some text 1" >dir1/file1 &&
88 + echo "some text 2" >dir1/file2 &&
89 + echo "some text 3" >dir1/file3 &&
90 + echo "some text 1" >dir1/dir2/file1 &&
91 + echo "some text 4" >dir1/dir2/file4 &&
92 + echo "some text 1" >dir1/dir2/dir4/file1 &&
93 + echo "some text 2" >dir1/dir2/dir4/file2 &&
94 + echo "some text 6" >dir1/dir2/dir4/file6 &&
95 + echo "some text 2" >dir1/dir3/file2 &&
96 + echo "some text 5" >dir1/dir3/file5 &&
97 + ipfs add -q -r dir1 >actualall &&
98 + tail -n1 actualall >actual1 &&
99 + echo "$HASH_DIR1" >expected1 &&
100 + ipfs repo gc && # remove the patch chaff
101 + test_cmp expected1 actual1
102 '
103
104 test_expect_success "objects are there" '
105 - ipfs cat "$HASH_FILE6" >FILE6_a &&
106 - ipfs cat "$HASH_FILE5" >FILE5_a &&
107 - ipfs cat "$HASH_FILE4" >FILE4_a &&
108 - ipfs cat "$HASH_FILE3" >FILE3_a &&
109 - ipfs cat "$HASH_FILE2" >FILE2_a &&
110 - ipfs cat "$HASH_FILE1" >FILE1_a &&
111 - ipfs ls "$HASH_DIR3" >DIR3_a &&
112 - ipfs ls "$HASH_DIR4" >DIR4_a &&
113 - ipfs ls "$HASH_DIR2" >DIR2_a &&
114 - ipfs ls "$HASH_DIR1" >DIR1_a
105 + ipfs cat "$HASH_FILE6" >FILE6_a &&
106 + ipfs cat "$HASH_FILE5" >FILE5_a &&
107 + ipfs cat "$HASH_FILE4" >FILE4_a &&
108 + ipfs cat "$HASH_FILE3" >FILE3_a &&
109 + ipfs cat "$HASH_FILE2" >FILE2_a &&
110 + ipfs cat "$HASH_FILE1" >FILE1_a &&
111 + ipfs ls "$HASH_DIR3" >DIR3_a &&
112 + ipfs ls "$HASH_DIR4" >DIR4_a &&
113 + ipfs ls "$HASH_DIR2" >DIR2_a &&
114 + ipfs ls "$HASH_DIR1" >DIR1_a
115 '
116
117 # saving this output for later
118 test_expect_success "ipfs object links $HASH_DIR1 works" '
119 - ipfs object links $HASH_DIR1 > DIR1_objlink
119 + ipfs object links $HASH_DIR1 > DIR1_objlink
120 '
121
122
123 test_expect_success "added dir was pinned recursively" '
124 - test_pin_flag $HASH_DIR1 recursive true
124 + test_pin_flag $HASH_DIR1 recursive true
125 '
126
127 test_expect_success "rest were pinned indirectly" '
128 - test_pin_flag "$HASH_FILE6" indirect true
129 - test_pin_flag "$HASH_FILE5" indirect true
130 - test_pin_flag "$HASH_FILE4" indirect true
131 - test_pin_flag "$HASH_FILE3" indirect true
132 - test_pin_flag "$HASH_FILE2" indirect true
133 - test_pin_flag "$HASH_FILE1" indirect true
134 - test_pin_flag "$HASH_DIR3" indirect true
135 - test_pin_flag "$HASH_DIR4" indirect true
136 - test_pin_flag "$HASH_DIR2" indirect true
128 + test_pin_flag "$HASH_FILE6" indirect true
129 + test_pin_flag "$HASH_FILE5" indirect true
130 + test_pin_flag "$HASH_FILE4" indirect true
131 + test_pin_flag "$HASH_FILE3" indirect true
132 + test_pin_flag "$HASH_FILE2" indirect true
133 + test_pin_flag "$HASH_FILE1" indirect true
134 + test_pin_flag "$HASH_DIR3" indirect true
135 + test_pin_flag "$HASH_DIR4" indirect true
136 + test_pin_flag "$HASH_DIR2" indirect true
137 '
138
139 test_expect_success "added dir was NOT pinned indirectly" '
140 - test_pin_flag "$HASH_DIR1" indirect false
140 + test_pin_flag "$HASH_DIR1" indirect false
141 '
142
143 test_expect_success "nothing is pinned directly" '
144 - ipfs pin ls --type=direct >actual4 &&
145 - test_must_be_empty actual4
144 + ipfs pin ls --type=direct >actual4 &&
145 + test_must_be_empty actual4
146 '
147
148 test_expect_success "'ipfs repo gc' succeeds" '
149 - ipfs repo gc >gc_out_actual
149 + ipfs repo gc >gc_out_actual
150 '
151
152 test_expect_success "objects are still there" '
153 - cat FILE6_a FILE5_a FILE4_a FILE3_a FILE2_a FILE1_a >expected45 &&
154 - cat DIR3_a DIR4_a DIR2_a DIR1_a >>expected45 &&
155 - ipfs cat "$HASH_FILE6" >actual45 &&
156 - ipfs cat "$HASH_FILE5" >>actual45 &&
157 - ipfs cat "$HASH_FILE4" >>actual45 &&
158 - ipfs cat "$HASH_FILE3" >>actual45 &&
159 - ipfs cat "$HASH_FILE2" >>actual45 &&
160 - ipfs cat "$HASH_FILE1" >>actual45 &&
161 - ipfs ls "$HASH_DIR3" >>actual45 &&
162 - ipfs ls "$HASH_DIR4" >>actual45 &&
163 - ipfs ls "$HASH_DIR2" >>actual45 &&
164 - ipfs ls "$HASH_DIR1" >>actual45 &&
165 - test_cmp expected45 actual45
153 + cat FILE6_a FILE5_a FILE4_a FILE3_a FILE2_a FILE1_a >expected45 &&
154 + cat DIR3_a DIR4_a DIR2_a DIR1_a >>expected45 &&
155 + ipfs cat "$HASH_FILE6" >actual45 &&
156 + ipfs cat "$HASH_FILE5" >>actual45 &&
157 + ipfs cat "$HASH_FILE4" >>actual45 &&
158 + ipfs cat "$HASH_FILE3" >>actual45 &&
159 + ipfs cat "$HASH_FILE2" >>actual45 &&
160 + ipfs cat "$HASH_FILE1" >>actual45 &&
161 + ipfs ls "$HASH_DIR3" >>actual45 &&
162 + ipfs ls "$HASH_DIR4" >>actual45 &&
163 + ipfs ls "$HASH_DIR2" >>actual45 &&
164 + ipfs ls "$HASH_DIR1" >>actual45 &&
165 + test_cmp expected45 actual45
166 '
167
168 test_expect_success "remove dir recursive pin succeeds" '
169 - echo "unpinned $HASH_DIR1" >expected5 &&
170 - ipfs pin rm -r "$HASH_DIR1" >actual5 &&
171 - test_cmp expected5 actual5
169 + echo "unpinned $HASH_DIR1" >expected5 &&
170 + ipfs pin rm -r "$HASH_DIR1" >actual5 &&
171 + test_cmp expected5 actual5
172 '
173
174 test_expect_success "none are pinned any more" '
175 - test_pin "$HASH_FILE6" &&
176 - test_pin "$HASH_FILE5" &&
177 - test_pin "$HASH_FILE4" &&
178 - test_pin "$HASH_FILE3" &&
179 - test_pin "$HASH_FILE2" &&
180 - test_pin "$HASH_FILE1" &&
181 - test_pin "$HASH_DIR3" &&
182 - test_pin "$HASH_DIR4" &&
183 - test_pin "$HASH_DIR2" &&
184 - test_pin "$HASH_DIR1"
175 + test_pin "$HASH_FILE6" &&
176 + test_pin "$HASH_FILE5" &&
177 + test_pin "$HASH_FILE4" &&
178 + test_pin "$HASH_FILE3" &&
179 + test_pin "$HASH_FILE2" &&
180 + test_pin "$HASH_FILE1" &&
181 + test_pin "$HASH_DIR3" &&
182 + test_pin "$HASH_DIR4" &&
183 + test_pin "$HASH_DIR2" &&
184 + test_pin "$HASH_DIR1"
185 '
186
187 test_expect_success "pin some directly and indirectly" '
188 - ipfs pin add -r=false "$HASH_DIR1" >actual7 &&
189 - ipfs pin add -r=true "$HASH_DIR2" >>actual7 &&
190 - ipfs pin add -r=false "$HASH_FILE1" >>actual7 &&
191 - echo "pinned $HASH_DIR1 directly" >expected7 &&
192 - echo "pinned $HASH_DIR2 recursively" >>expected7 &&
193 - echo "pinned $HASH_FILE1 directly" >>expected7 &&
194 - test_cmp expected7 actual7
188 + ipfs pin add -r=false "$HASH_DIR1" >actual7 &&
189 + ipfs pin add -r=true "$HASH_DIR2" >>actual7 &&
190 + ipfs pin add -r=false "$HASH_FILE1" >>actual7 &&
191 + echo "pinned $HASH_DIR1 directly" >expected7 &&
192 + echo "pinned $HASH_DIR2 recursively" >>expected7 &&
193 + echo "pinned $HASH_FILE1 directly" >>expected7 &&
194 + test_cmp expected7 actual7
195 '
196
197 test_expect_success "pin lists look good" '
198 - test_pin $HASH_DIR1 direct &&
199 - test_pin $HASH_DIR2 recursive &&
200 - test_pin $HASH_DIR3 &&
201 - test_pin $HASH_DIR4 indirect &&
202 - test_pin $HASH_FILE1 indirect direct &&
203 - test_pin $HASH_FILE2 indirect &&
204 - test_pin $HASH_FILE3 &&
205 - test_pin $HASH_FILE4 indirect &&
206 - test_pin $HASH_FILE5 &&
207 - test_pin $HASH_FILE6 indirect
198 + test_pin $HASH_DIR1 direct &&
199 + test_pin $HASH_DIR2 recursive &&
200 + test_pin $HASH_DIR3 &&
201 + test_pin $HASH_DIR4 indirect &&
202 + test_pin $HASH_FILE1 indirect direct &&
203 + test_pin $HASH_FILE2 indirect &&
204 + test_pin $HASH_FILE3 &&
205 + test_pin $HASH_FILE4 indirect &&
206 + test_pin $HASH_FILE5 &&
207 + test_pin $HASH_FILE6 indirect
208 '
209
210 test_expect_success "'ipfs repo gc' succeeds" '
211 - ipfs repo gc >gc_out_actual2 &&
212 - echo "removed $HASH_FILE3" > gc_out_exp2 &&
213 - echo "removed $HASH_FILE5" >> gc_out_exp2 &&
214 - echo "removed $HASH_DIR3" >> gc_out_exp2 &&
215 - test_includes_lines gc_out_exp2 gc_out_actual2
211 + ipfs repo gc >gc_out_actual2 &&
212 + echo "removed $HASH_FILE3" > gc_out_exp2 &&
213 + echo "removed $HASH_FILE5" >> gc_out_exp2 &&
214 + echo "removed $HASH_DIR3" >> gc_out_exp2 &&
215 + test_includes_lines gc_out_exp2 gc_out_actual2
216 '
217
218 # use object links for HASH_DIR1 here because its children
219 # no longer exist
220 test_expect_success "some objects are still there" '
221 - cat FILE6_a FILE4_a FILE2_a FILE1_a >expected8 &&
222 - cat DIR4_a DIR2_a DIR1_objlink >>expected8 &&
223 - ipfs cat "$HASH_FILE6" >actual8 &&
224 - ipfs cat "$HASH_FILE4" >>actual8 &&
225 - ipfs cat "$HASH_FILE2" >>actual8 &&
226 - ipfs cat "$HASH_FILE1" >>actual8 &&
227 - ipfs ls "$HASH_DIR4" >>actual8 &&
228 - ipfs ls "$HASH_DIR2" >>actual8 &&
229 - ipfs object links "$HASH_DIR1" >>actual8 &&
230 - test_cmp expected8 actual8
221 + cat FILE6_a FILE4_a FILE2_a FILE1_a >expected8 &&
222 + cat DIR4_a DIR2_a DIR1_objlink >>expected8 &&
223 + ipfs cat "$HASH_FILE6" >actual8 &&
224 + ipfs cat "$HASH_FILE4" >>actual8 &&
225 + ipfs cat "$HASH_FILE2" >>actual8 &&
226 + ipfs cat "$HASH_FILE1" >>actual8 &&
227 + ipfs ls "$HASH_DIR4" >>actual8 &&
228 + ipfs ls "$HASH_DIR2" >>actual8 &&
229 + ipfs object links "$HASH_DIR1" >>actual8 &&
230 + test_cmp expected8 actual8
231 '
232
233 # todo: make this faster somehow.
234 test_expect_success "some are no longer there" '
235 - test_must_fail ipfs cat "$HASH_FILE5" &&
236 - test_must_fail ipfs cat "$HASH_FILE3" &&
237 - test_must_fail ipfs ls "$HASH_DIR3"
235 + test_must_fail ipfs cat "$HASH_FILE5" &&
236 + test_must_fail ipfs cat "$HASH_FILE3" &&
237 + test_must_fail ipfs ls "$HASH_DIR3"
238 '
239
240 test_expect_success "recursive pin fails without objects" '
241 - ipfs pin rm -r=false "$HASH_DIR1" &&
242 - test_must_fail ipfs pin add -r "$HASH_DIR1" 2>err_expected8 &&
243 - grep "pin: merkledag: not found" err_expected8 ||
244 - test_fsh cat err_expected8
241 + ipfs pin rm -r=false "$HASH_DIR1" &&
242 + test_must_fail ipfs pin add -r "$HASH_DIR1" 2>err_expected8 &&
243 + grep "pin: merkledag: not found" err_expected8 ||
244 + test_fsh cat err_expected8
245 '
246
247 test_expect_success "test add nopin file" '
248 - echo "test nopin data" > test_nopin_data &&
249 - NOPINHASH=$(ipfs add -q --pin=false test_nopin_data) &&
250 - test_pin_flag "$NOPINHASH" direct false &&
251 - test_pin_flag "$NOPINHASH" indirect false &&
252 - test_pin_flag "$NOPINHASH" recursive false
248 + echo "test nopin data" > test_nopin_data &&
249 + NOPINHASH=$(ipfs add -q --pin=false test_nopin_data) &&
250 + test_pin_flag "$NOPINHASH" direct false &&
251 + test_pin_flag "$NOPINHASH" indirect false &&
252 + test_pin_flag "$NOPINHASH" recursive false
253 '
254
255
256 test_expect_success "test add nopin dir" '
257 - mkdir nopin_dir1 &&
258 - echo "some nopin text 1" >nopin_dir1/file1 &&
259 - echo "some nopin text 2" >nopin_dir1/file2 &&
260 - ipfs add -q -r --pin=false nopin_dir1 | tail -n1 >actual1 &&
261 - echo "$HASH_NOPINDIR" >expected1 &&
262 - test_cmp actual1 expected1 &&
263 - test_pin_flag "$HASH_NOPINDIR" direct false &&
264 - test_pin_flag "$HASH_NOPINDIR" indirect false &&
265 - test_pin_flag "$HASH_NOPINDIR" recursive false &&
266 - test_pin_flag "$HASH_NOPIN_FILE1" direct false &&
267 - test_pin_flag "$HASH_NOPIN_FILE1" indirect false &&
268 - test_pin_flag "$HASH_NOPIN_FILE1" recursive false &&
269 - test_pin_flag "$HASH_NOPIN_FILE2" direct false &&
270 - test_pin_flag "$HASH_NOPIN_FILE2" indirect false &&
271 - test_pin_flag "$HASH_NOPIN_FILE2" recursive false
257 + mkdir nopin_dir1 &&
258 + echo "some nopin text 1" >nopin_dir1/file1 &&
259 + echo "some nopin text 2" >nopin_dir1/file2 &&
260 + ipfs add -q -r --pin=false nopin_dir1 | tail -n1 >actual1 &&
261 + echo "$HASH_NOPINDIR" >expected1 &&
262 + test_cmp actual1 expected1 &&
263 + test_pin_flag "$HASH_NOPINDIR" direct false &&
264 + test_pin_flag "$HASH_NOPINDIR" indirect false &&
265 + test_pin_flag "$HASH_NOPINDIR" recursive false &&
266 + test_pin_flag "$HASH_NOPIN_FILE1" direct false &&
267 + test_pin_flag "$HASH_NOPIN_FILE1" indirect false &&
268 + test_pin_flag "$HASH_NOPIN_FILE1" recursive false &&
269 + test_pin_flag "$HASH_NOPIN_FILE2" direct false &&
270 + test_pin_flag "$HASH_NOPIN_FILE2" indirect false &&
271 + test_pin_flag "$HASH_NOPIN_FILE2" recursive false
272
273 '
274
275 FICTIONAL_HASH="QmXV4f9v8a56MxWKBhP3ETsz4EaafudU1cKfPaaJnenc48"
276 test_launch_ipfs_daemon
277 test_expect_success "test unpinning a hash that's not pinned" "
278 - test_expect_code 1 ipfs pin rm $FICTIONAL_HASH --timeout=2s
279 - test_expect_code 1 ipfs pin rm $FICTIONAL_HASH/a --timeout=2s
280 - test_expect_code 1 ipfs pin rm $FICTIONAL_HASH/a/b --timeout=2s
278 + test_expect_code 1 ipfs pin rm $FICTIONAL_HASH --timeout=2s
279 + test_expect_code 1 ipfs pin rm $FICTIONAL_HASH/a --timeout=2s
280 + test_expect_code 1 ipfs pin rm $FICTIONAL_HASH/a/b --timeout=2s
281 "
282 test_kill_ipfs_daemon
283
test/sharness/t0082-repo-gc-auto.sh
+32 -32
@@ -12,61 +12,61 @@ skip_all="skipping auto repo gc tests until they can be fixed"
12 test_done
13
14 check_ipfs_storage() {
15 - ipfs config Datastore.StorageMax
15 + ipfs config Datastore.StorageMax
16 }
17
18 test_init_ipfs
19
20 test_expect_success "generate 2 600 kB files and 2 MB file using go-random" '
21 - random 600k 41 >600k1 &&
22 - random 600k 42 >600k2 &&
23 - random 2M 43 >2M
21 + random 600k 41 >600k1 &&
22 + random 600k 42 >600k2 &&
23 + random 2M 43 >2M
24 '
25
26 test_expect_success "set ipfs gc watermark, storage max, and gc timeout" '
27 - test_config_set Datastore.StorageMax "2MB" &&
28 - test_config_set --json Datastore.StorageGCWatermark 60 &&
29 - test_config_set Datastore.GCPeriod "20ms"
27 + test_config_set Datastore.StorageMax "2MB" &&
28 + test_config_set --json Datastore.StorageGCWatermark 60 &&
29 + test_config_set Datastore.GCPeriod "20ms"
30 '
31
32 test_launch_ipfs_daemon --enable-gc
33
34 test_gc() {
35 - test_expect_success "adding data below watermark doesn't trigger auto gc" '
36 - ipfs add 600k1 >/dev/null &&
37 - disk_usage "$IPFS_PATH/blocks" >expected &&
38 - go-sleep 40ms &&
39 - disk_usage "$IPFS_PATH/blocks" >actual &&
40 - test_cmp expected actual
41 - '
35 + test_expect_success "adding data below watermark doesn't trigger auto gc" '
36 + ipfs add 600k1 >/dev/null &&
37 + disk_usage "$IPFS_PATH/blocks" >expected &&
38 + go-sleep 40ms &&
39 + disk_usage "$IPFS_PATH/blocks" >actual &&
40 + test_cmp expected actual
41 + '
42
43 - test_expect_success "adding data beyond watermark triggers auto gc" '
44 - HASH=`ipfs add -q 600k2` &&
45 - ipfs pin rm -r $HASH &&
46 - go-sleep 40ms &&
47 - DU=$(disk_usage "$IPFS_PATH/blocks") &&
48 - if test $(uname -s) = "Darwin"; then
49 - test "$DU" -lt 1400 # 60% of 2MB
50 - else
51 - test "$DU" -lt 1000000
52 - fi
53 - '
43 + test_expect_success "adding data beyond watermark triggers auto gc" '
44 + HASH=`ipfs add -q 600k2` &&
45 + ipfs pin rm -r $HASH &&
46 + go-sleep 40ms &&
47 + DU=$(disk_usage "$IPFS_PATH/blocks") &&
48 + if test $(uname -s) = "Darwin"; then
49 + test "$DU" -lt 1400 # 60% of 2MB
50 + else
51 + test "$DU" -lt 1000000
52 + fi
53 + '
54 }
55
56 #TODO: conditional GC test is disabled due to files size bug in ipfs add
57 #test_expect_success "adding data beyond storageMax fails" '
58 -# test_must_fail ipfs add 2M 2>add_fail_out
58 +# test_must_fail ipfs add 2M 2>add_fail_out
59 #'
60 #test_expect_success "ipfs add not enough space message looks good" '
61 -# echo "Error: file size exceeds slack space allowed by storageMax. Maybe unpin some files?" >add_fail_exp &&
62 -# test_cmp add_fail_exp add_fail_out
61 +# echo "Error: file size exceeds slack space allowed by storageMax. Maybe unpin some files?" >add_fail_exp &&
62 +# test_cmp add_fail_exp add_fail_out
63 #'
64
65 test_expect_success "periodic auto gc stress test" '
66 - for i in $(test_seq 1 20)
67 - do
68 - test_gc
69 - done
66 + for i in $(test_seq 1 20)
67 + do
68 + test_gc
69 + done
70 '
71
72 test_kill_ipfs_daemon
test/sharness/t0083-repo-fsck.sh
+59 -59
@@ -19,22 +19,22 @@ test_init_ipfs
19 # repo.lock and datastore/LOCK being empty
20 test_expect_success "'ipfs repo fsck' succeeds with no daemon running empty
21 repo.lock" '
22 - mkdir -p $IPFS_PATH &&
23 - mkdir -p $IPFS_PATH/datastore &&
24 - touch $IPFS_PATH/datastore/LOCK &&
25 - touch $IPFS_PATH/repo.lock &&
26 - printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api &&
27 - ipfs repo fsck > fsck_out_actual1
22 + mkdir -p $IPFS_PATH &&
23 + mkdir -p $IPFS_PATH/datastore &&
24 + touch $IPFS_PATH/datastore/LOCK &&
25 + touch $IPFS_PATH/repo.lock &&
26 + printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api &&
27 + ipfs repo fsck > fsck_out_actual1
28 '
29 test_expect_success "'ipfs repo fsck' output looks good with no daemon" '
30 - grep "Lockfiles have been removed." fsck_out_actual1
30 + grep "Lockfiles have been removed." fsck_out_actual1
31 '
32
33 # Make sure the files are actually removed
34 test_expect_success "'ipfs repo fsck' confirm file deletion" '
35 - test ! -e "$IPFS_PATH/repo.lock" &&
36 - test ! -e "$IPFS_PATH/datastore/LOCK" &&
37 - test ! -e "$IPFS_PATH/api"
35 + test ! -e "$IPFS_PATH/repo.lock" &&
36 + test ! -e "$IPFS_PATH/datastore/LOCK" &&
37 + test ! -e "$IPFS_PATH/api"
38 '
39
40 # 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" '
42 # non-zero repo.lock issue
43 test_expect_success "'ipfs repo fsck' succeeds with no daemon running non-zero
44 repo.lock" '
45 - mkdir -p $IPFS_PATH &&
46 - printf ":D" > $IPFS_PATH/repo.lock &&
47 - touch $IPFS_PATH/datastore/LOCK &&
48 - ipfs repo fsck > fsck_out_actual1b
45 + mkdir -p $IPFS_PATH &&
46 + printf ":D" > $IPFS_PATH/repo.lock &&
47 + touch $IPFS_PATH/datastore/LOCK &&
48 + ipfs repo fsck > fsck_out_actual1b
49 '
50 test_expect_success "'ipfs repo fsck' output looks good with no daemon" '
51 - grep "Lockfiles have been removed." fsck_out_actual1b
51 + grep "Lockfiles have been removed." fsck_out_actual1b
52 '
53
54 # Make sure the files are actually removed
55 test_expect_success "'ipfs repo fsck' confirm file deletion" '
56 - test ! -e "$IPFS_PATH/repo.lock" &&
57 - test ! -e "$IPFS_PATH/datastore/LOCK" &&
58 - test ! -e "$IPFS_PATH/api"
56 + test ! -e "$IPFS_PATH/repo.lock" &&
57 + test ! -e "$IPFS_PATH/datastore/LOCK" &&
58 + test ! -e "$IPFS_PATH/api"
59 '
60
61 ########################
@@ -64,56 +64,56 @@ test_expect_success "'ipfs repo fsck' confirm file deletion" '
64
65 # Try with locks api and datastore/LOCK
66 test_expect_success "'ipfs repo fsck' succeeds partial lock" '
67 - printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api &&
68 - touch $IPFS_PATH/datastore/LOCK &&
69 - ipfs repo fsck > fsck_out_actual2
67 + printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api &&
68 + touch $IPFS_PATH/datastore/LOCK &&
69 + ipfs repo fsck > fsck_out_actual2
70 '
71
72 test_expect_success "'ipfs repo fsck' output looks good with no daemon" '
73 - grep "Lockfiles have been removed." fsck_out_actual2
73 + grep "Lockfiles have been removed." fsck_out_actual2
74 '
75
76 # Make sure the files are actually removed
77 test_expect_success "'ipfs repo fsck' confirm file deletion" '
78 - test ! -e "$IPFS_PATH/repo.lock" &&
79 - test ! -e "$IPFS_PATH/datastore/LOCK" &&
80 - test ! -e "$IPFS_PATH/api"
78 + test ! -e "$IPFS_PATH/repo.lock" &&
79 + test ! -e "$IPFS_PATH/datastore/LOCK" &&
80 + test ! -e "$IPFS_PATH/api"
81 '
82
83 # Try with locks api and repo.lock
84 test_expect_success "'ipfs repo fsck' succeeds partial lock" '
85 - printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api &&
86 - touch $IPFS_PATH/repo.lock &&
87 - ipfs repo fsck > fsck_out_actual3
85 + printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api &&
86 + touch $IPFS_PATH/repo.lock &&
87 + ipfs repo fsck > fsck_out_actual3
88 '
89
90 test_expect_success "'ipfs repo fsck' output looks good with no daemon" '
91 - grep "Lockfiles have been removed." fsck_out_actual3
91 + grep "Lockfiles have been removed." fsck_out_actual3
92 '
93
94 # Make sure the files are actually removed
95 test_expect_success "'ipfs repo fsck' confirm file deletion" '
96 - test ! -e "$IPFS_PATH/repo.lock" &&
97 - test ! -e "$IPFS_PATH/datastore/LOCK" &&
98 - test ! -e "$IPFS_PATH/api"
96 + test ! -e "$IPFS_PATH/repo.lock" &&
97 + test ! -e "$IPFS_PATH/datastore/LOCK" &&
98 + test ! -e "$IPFS_PATH/api"
99 '
100
101 # Try with locks repo.lock and datastore
102 test_expect_success "'ipfs repo fsck' succeeds partial lock" '
103 - touch $IPFS_PATH/repo.lock &&
104 - touch $IPFS_PATH/datastore/LOCK &&
105 - ipfs repo fsck > fsck_out_actual4
103 + touch $IPFS_PATH/repo.lock &&
104 + touch $IPFS_PATH/datastore/LOCK &&
105 + ipfs repo fsck > fsck_out_actual4
106 '
107
108 test_expect_success "'ipfs repo fsck' output looks good with no daemon" '
109 - grep "Lockfiles have been removed." fsck_out_actual4
109 + grep "Lockfiles have been removed." fsck_out_actual4
110 '
111
112 # Make sure the files are actually removed
113 test_expect_success "'ipfs repo fsck' confirm file deletion" '
114 - test ! -e "$IPFS_PATH/repo.lock" &&
115 - test ! -e "$IPFS_PATH/datastore/LOCK" &&
116 - test ! -e "$IPFS_PATH/api"
114 + test ! -e "$IPFS_PATH/repo.lock" &&
115 + test ! -e "$IPFS_PATH/datastore/LOCK" &&
116 + test ! -e "$IPFS_PATH/api"
117 '
118
119 #######################
@@ -122,51 +122,51 @@ test_expect_success "'ipfs repo fsck' confirm file deletion" '
122
123 # Try with single locks repo.lock
124 test_expect_success "'ipfs repo fsck' succeeds partial lock" '
125 - touch $IPFS_PATH/repo.lock &&
126 - ipfs repo fsck > fsck_out_actual5
125 + touch $IPFS_PATH/repo.lock &&
126 + ipfs repo fsck > fsck_out_actual5
127 '
128 test_expect_success "'ipfs repo fsck' output looks good with no daemon" '
129 - grep "Lockfiles have been removed." fsck_out_actual5
129 + grep "Lockfiles have been removed." fsck_out_actual5
130 '
131
132 # Make sure the files are actually removed
133 test_expect_success "'ipfs repo fsck' confirm file deletion" '
134 - test ! -e "$IPFS_PATH/repo.lock" &&
135 - test ! -e "$IPFS_PATH/datastore/LOCK" &&
136 - test ! -e "$IPFS_PATH/api"
134 + test ! -e "$IPFS_PATH/repo.lock" &&
135 + test ! -e "$IPFS_PATH/datastore/LOCK" &&
136 + test ! -e "$IPFS_PATH/api"
137 '
138
139 # Try with single locks datastore/LOCK
140 test_expect_success "'ipfs repo fsck' succeeds partial lock" '
141 - touch $IPFS_PATH/datastore/LOCK &&
142 - ipfs repo fsck > fsck_out_actual6
141 + touch $IPFS_PATH/datastore/LOCK &&
142 + ipfs repo fsck > fsck_out_actual6
143 '
144 test_expect_success "'ipfs repo fsck' output looks good with no daemon" '
145 - grep "Lockfiles have been removed." fsck_out_actual6
145 + grep "Lockfiles have been removed." fsck_out_actual6
146 '
147
148 # Make sure the files are actually removed
149 test_expect_success "'ipfs repo fsck' confirm file deletion" '
150 - test ! -e "$IPFS_PATH/repo.lock" &&
151 - test ! -e "$IPFS_PATH/datastore/LOCK" &&
152 - test ! -e "$IPFS_PATH/api"
150 + test ! -e "$IPFS_PATH/repo.lock" &&
151 + test ! -e "$IPFS_PATH/datastore/LOCK" &&
152 + test ! -e "$IPFS_PATH/api"
153 '
154
155 # Try with single lock api
156 test_expect_success "'ipfs repo fsck' succeeds partial lock" '
157 - printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api &&
158 - ipfs repo fsck > fsck_out_actual7
157 + printf "/ip4/127.0.0.1/tcp/5001" > $IPFS_PATH/api &&
158 + ipfs repo fsck > fsck_out_actual7
159 '
160
161 test_expect_success "'ipfs repo fsck' output looks good with no daemon" '
162 - grep "Lockfiles have been removed." fsck_out_actual7
162 + grep "Lockfiles have been removed." fsck_out_actual7
163 '
164
165 # Make sure the files are actually removed
166 test_expect_success "'ipfs repo fsck' confirm file deletion" '
167 - test ! -e "$IPFS_PATH/repo.lock" &&
168 - test ! -e "$IPFS_PATH/datastore/LOCK" &&
169 - test ! -e "$IPFS_PATH/api"
167 + test ! -e "$IPFS_PATH/repo.lock" &&
168 + test ! -e "$IPFS_PATH/datastore/LOCK" &&
169 + test ! -e "$IPFS_PATH/api"
170 '
171
172 ##########################
@@ -177,12 +177,12 @@ test_launch_ipfs_daemon
177
178 # Daemon is running -> command doesn't run
179 test_expect_success "'ipfs repo fsck' fails with daemon running" '
180 - ! (ipfs repo fsck 2>fsck_out_actual8 )
180 + ! (ipfs repo fsck 2>fsck_out_actual8 )
181
182 '
183
184 test_expect_success "'ipfs repo fsck' output looks good with daemon" '
185 - grep "Error: ipfs daemon is running" fsck_out_actual8
185 + grep "Error: ipfs daemon is running" fsck_out_actual8
186 '
187
188 test_kill_ipfs_daemon
test/sharness/t0084-repo-read-rehash.sh
+15 -15
@@ -21,31 +21,31 @@ BS_BLOCK2="CK/CIQNYWBOKHY7TCY7FUOBXKVJ66YRMARDT3KC7PPY6UWWPZR4YA67CKQ.data"
21
22
23 test_expect_success 'blocks are swapped' '
24 - ipfs cat $H_BLOCK2 > noswap &&
25 - cp -f "$IPFS_PATH/blocks/$BS_BLOCK1" "$IPFS_PATH/blocks/$BS_BLOCK2" &&
26 - ipfs cat $H_BLOCK2 > swap &&
27 - test_must_fail test_cmp noswap swap
24 + ipfs cat $H_BLOCK2 > noswap &&
25 + cp -f "$IPFS_PATH/blocks/$BS_BLOCK1" "$IPFS_PATH/blocks/$BS_BLOCK2" &&
26 + ipfs cat $H_BLOCK2 > swap &&
27 + test_must_fail test_cmp noswap swap
28 '
29
30 ipfs config --bool Datastore.HashOnRead true
31
32 test_check_bad_blocks() {
33 - test_expect_success 'getting modified block fails' '
34 - (test_must_fail ipfs cat $H_BLOCK2 2> err_msg) &&
35 - grep "block in storage has different hash than requested" err_msg
36 - '
37 -
38 - test_expect_success "block shows up in repo verify" '
39 - test_expect_code 1 ipfs repo verify > verify_out &&
40 - grep "$H_BLOCK2" verify_out
41 - '
33 + test_expect_success 'getting modified block fails' '
34 + (test_must_fail ipfs cat $H_BLOCK2 2> err_msg) &&
35 + grep "block in storage has different hash than requested" err_msg
36 + '
37 +
38 + test_expect_success "block shows up in repo verify" '
39 + test_expect_code 1 ipfs repo verify > verify_out &&
40 + grep "$H_BLOCK2" verify_out
41 + '
42 }
43
44 test_check_bad_blocks
45
46 test_expect_success "can add and cat a raw-leaf file" '
47 - HASH=$(echo "stuff" | ipfs add -q --raw-leaves) &&
48 - ipfs cat $HASH > /dev/null
47 + HASH=$(echo "stuff" | ipfs add -q --raw-leaves) &&
48 + ipfs cat $HASH > /dev/null
49 '
50
51 test_launch_ipfs_daemon
test/sharness/t0085-pins.sh
+67 -67
@@ -10,91 +10,91 @@ test_description="Test ipfs pinning operations"
10
11
12 test_pins() {
13 - EXTRA_ARGS=$1
14 -
15 - test_expect_success "create some hashes" '
16 - HASH_A=$(echo "A" | ipfs add -q --pin=false) &&
17 - HASH_B=$(echo "B" | ipfs add -q --pin=false) &&
18 - HASH_C=$(echo "C" | ipfs add -q --pin=false) &&
19 - HASH_D=$(echo "D" | ipfs add -q --pin=false) &&
20 - HASH_E=$(echo "E" | ipfs add -q --pin=false) &&
21 - HASH_F=$(echo "F" | ipfs add -q --pin=false) &&
22 - HASH_G=$(echo "G" | ipfs add -q --pin=false)
23 - '
24 -
25 - test_expect_success "put all those hashes in a file" '
26 - echo $HASH_A > hashes &&
27 - echo $HASH_B >> hashes &&
28 - echo $HASH_C >> hashes &&
29 - echo $HASH_D >> hashes &&
30 - echo $HASH_E >> hashes &&
31 - echo $HASH_F >> hashes &&
32 - echo $HASH_G >> hashes
33 - '
34 -
35 - test_expect_success "'ipfs pin add $EXTRA_ARGS' via stdin" '
36 - cat hashes | ipfs pin add $EXTRA_ARGS
37 - '
38 -
39 - test_expect_success "unpin those hashes" '
40 - cat hashes | ipfs pin rm
41 - '
13 + EXTRA_ARGS=$1
14 +
15 + test_expect_success "create some hashes" '
16 + HASH_A=$(echo "A" | ipfs add -q --pin=false) &&
17 + HASH_B=$(echo "B" | ipfs add -q --pin=false) &&
18 + HASH_C=$(echo "C" | ipfs add -q --pin=false) &&
19 + HASH_D=$(echo "D" | ipfs add -q --pin=false) &&
20 + HASH_E=$(echo "E" | ipfs add -q --pin=false) &&
21 + HASH_F=$(echo "F" | ipfs add -q --pin=false) &&
22 + HASH_G=$(echo "G" | ipfs add -q --pin=false)
23 + '
24 +
25 + test_expect_success "put all those hashes in a file" '
26 + echo $HASH_A > hashes &&
27 + echo $HASH_B >> hashes &&
28 + echo $HASH_C >> hashes &&
29 + echo $HASH_D >> hashes &&
30 + echo $HASH_E >> hashes &&
31 + echo $HASH_F >> hashes &&
32 + echo $HASH_G >> hashes
33 + '
34 +
35 + test_expect_success "'ipfs pin add $EXTRA_ARGS' via stdin" '
36 + cat hashes | ipfs pin add $EXTRA_ARGS
37 + '
38 +
39 + test_expect_success "unpin those hashes" '
40 + cat hashes | ipfs pin rm
41 + '
42 }
43
44 RANDOM_HASH=Qme8uX5n9hn15pw9p6WcVKoziyyC9LXv4LEgvsmKMULjnV
45
46 test_pins_error_reporting() {
47 - EXTRA_ARGS=$1
47 + EXTRA_ARGS=$1
48
49 - test_expect_success "'ipfs pin add $EXTRA_ARGS' on non-existent hash should fail" '
50 - test_must_fail ipfs pin add $EXTRA_ARGS $RANDOM_HASH 2> err &&
51 - grep -q "not found" err
52 - '
49 + test_expect_success "'ipfs pin add $EXTRA_ARGS' on non-existent hash should fail" '
50 + test_must_fail ipfs pin add $EXTRA_ARGS $RANDOM_HASH 2> err &&
51 + grep -q "not found" err
52 + '
53 }
54
55 test_pin_dag_init() {
56 - EXTRA_ARGS=$1
56 + EXTRA_ARGS=$1
57
58 - test_expect_success "'ipfs add $EXTRA_ARGS --pin=false' 1MB file" '
59 - random 1048576 56 > afile &&
60 - HASH=`ipfs add $EXTRA_ARGS --pin=false -q afile`
61 - '
58 + test_expect_success "'ipfs add $EXTRA_ARGS --pin=false' 1MB file" '
59 + random 1048576 56 > afile &&
60 + HASH=`ipfs add $EXTRA_ARGS --pin=false -q afile`
61 + '
62 }
63
64 test_pin_dag() {
65 - test_pin_dag_init $1
66 -
67 - test_expect_success "'ipfs pin add --progress' file" '
68 - ipfs pin add --recursive=true $HASH
69 - '
70 -
71 - test_expect_success "'ipfs pin rm' file" '
72 - ipfs pin rm $HASH
73 - '
74 -
75 - test_expect_success "remove part of the dag" '
76 - PART=`ipfs refs $HASH | head -1` &&
77 - ipfs block rm $PART
78 - '
79 -
80 - test_expect_success "pin file, should fail" '
81 - test_must_fail ipfs pin add --recursive=true $HASH 2> err &&
82 - cat err &&
83 - grep -q "not found" err
84 - '
65 + test_pin_dag_init $1
66 +
67 + test_expect_success "'ipfs pin add --progress' file" '
68 + ipfs pin add --recursive=true $HASH
69 + '
70 +
71 + test_expect_success "'ipfs pin rm' file" '
72 + ipfs pin rm $HASH
73 + '
74 +
75 + test_expect_success "remove part of the dag" '
76 + PART=`ipfs refs $HASH | head -1` &&
77 + ipfs block rm $PART
78 + '
79 +
80 + test_expect_success "pin file, should fail" '
81 + test_must_fail ipfs pin add --recursive=true $HASH 2> err &&
82 + cat err &&
83 + grep -q "not found" err
84 + '
85 }
86
87 test_pin_progress() {
88 - test_pin_dag_init
88 + test_pin_dag_init
89
90 - test_expect_success "'ipfs pin add --progress' file" '
91 - ipfs pin add --progress $HASH 2> err
92 - '
90 + test_expect_success "'ipfs pin add --progress' file" '
91 + ipfs pin add --progress $HASH 2> err
92 + '
93
94 - test_expect_success "pin progress reported correctly" '
95 - cat err
96 - grep -q " 5 nodes" err
97 - '
94 + test_expect_success "pin progress reported correctly" '
95 + cat err
96 + grep -q " 5 nodes" err
97 + '
98 }
99
100 test_init_ipfs
test/sharness/t0086-repo-verify.sh
+27 -27
@@ -11,50 +11,50 @@ test_description="Test ipfs repo fsck"
11 test_init_ipfs
12
13 sort_rand() {
14 - case `uname` in
15 - Linux)
16 - sort -R
17 - ;;
18 - Darwin)
19 - ruby -e 'puts STDIN.readlines.shuffle'
20 - ;;
21 - *)
22 - echo "unsupported system: $(uname)"
23 - esac
14 + case `uname` in
15 + Linux)
16 + sort -R
17 + ;;
18 + Darwin)
19 + ruby -e 'puts STDIN.readlines.shuffle'
20 + ;;
21 + *)
22 + echo "unsupported system: $(uname)"
23 + esac
24 }
25
26 check_random_corruption() {
27 - to_break=$(find "$IPFS_PATH/blocks" -type f | grep -v README | grep -v SHARDING | sort_rand | head -n 1)
27 + to_break=$(find "$IPFS_PATH/blocks" -type f | grep -v README | grep -v SHARDING | sort_rand | head -n 1)
28
29 - test_expect_success "back up file and overwrite it" '
30 - cp "$to_break" backup_file &&
31 - echo "this is super broken" > "$to_break"
32 - '
29 + test_expect_success "back up file and overwrite it" '
30 + cp "$to_break" backup_file &&
31 + echo "this is super broken" > "$to_break"
32 + '
33
34 - test_expect_success "repo verify detects failure" '
35 - test_expect_code 1 ipfs repo verify
36 - '
34 + test_expect_success "repo verify detects failure" '
35 + test_expect_code 1 ipfs repo verify
36 + '
37
38 - test_expect_success "replace the object" '
39 - cp backup_file "$to_break"
40 - '
38 + test_expect_success "replace the object" '
39 + cp backup_file "$to_break"
40 + '
41
42 - test_expect_success "ipfs repo verify passes just fine now" '
43 - ipfs repo verify
44 - '
42 + test_expect_success "ipfs repo verify passes just fine now" '
43 + ipfs repo verify
44 + '
45 }
46
47 test_expect_success "create some files" '
48 - random-files -depth=3 -dirs=4 -files=10 foobar > /dev/null
48 + random-files -depth=3 -dirs=4 -files=10 foobar > /dev/null
49 '
50
51 test_expect_success "add them all" '
52 - ipfs add -r -q foobar > /dev/null
52 + ipfs add -r -q foobar > /dev/null
53 '
54
55 for i in `seq 20`
56 do
57 - check_random_corruption
57 + check_random_corruption
58 done
59
60 test_done
test/sharness/t0087-repo-robust-gc.sh
+135 -135
@@ -11,145 +11,145 @@ set -e
11
12 test_gc_robust_part1() {
13
14 - test_expect_success "add a 1MB file with --raw-leaves" '
15 - random 1048576 56 > afile &&
16 - HASH1=`ipfs add --raw-leaves -q afile`
17 - '
18 -
19 - HASH1FILE=.ipfs/blocks/L3/CIQNIPL4GP62ZMNNSLZ2G33Z3T5VAN3YHCJTGT5FG45XWH5FGZRXL3A.data
20 -
21 - LEAF1=zb2rhZWKCMcHCfCym41ocwE5BhNQsEVLrwBkLEQaxJzRHHZch
22 - LEAF1FILE=.ipfs/blocks/C2/AFKREIBKRCW7HF6NHR6DVWECQXC5RQC7U7PKHKTI53BYYZNQP23DK5FC2Y.data
23 -
24 - LEAF2=zb2rhdUpCuyoQPRtvBW8JhAEfPaNd9dBb3QQCMMWYS1V8hjBR
25 - LEAF2FILE=.ipfs/blocks/Q6/BAFKREIDFSUIR43GJPHNDXXQA45GJVNRZBET3CRPUMYJCBLK3RTN7ZAMQ6Q
26 -
27 - LEAF3=zb2rhnwyvreekPqEMAbKqs35KYHxkNi7pXED7L2TfJKveTTva
28 - LEAF4=zb2rhnvAVvfDDnndcfQkwqNgUm94ba3zBSXyJKCfVXwU4FXx2
29 -
30 - test_expect_success "remove a leaf node from the repo manually" '
31 - rm "$LEAF1FILE"
32 - '
33 -
34 - test_expect_success "check that the node is removed" '
35 - test_must_fail ipfs cat $HASH1
36 - '
37 -
38 - test_expect_success "'ipfs repo gc' should still be be fine" '
39 - ipfs repo gc
40 - '
41 -
42 - test_expect_success "corrupt the root node of 1MB file" '
43 - test -e "$HASH1FILE" &&
44 - dd if=/dev/zero of="$HASH1FILE" count=1 bs=100 conv=notrunc
45 - '
46 -
47 - test_expect_success "'ipfs repo gc' should abort without removing anything" '
48 - test_must_fail ipfs repo gc 2>&1 | tee gc_err &&
49 - grep -q "could not retrieve links for $HASH1" gc_err &&
50 - grep -q "aborted" gc_err
51 - '
52 -
53 - test_expect_success "leaf nodes were not removed after gc" '
54 - ipfs cat $LEAF3 > /dev/null &&
55 - ipfs cat $LEAF4 > /dev/null
56 - '
57 -
58 - test_expect_success "unpin the 1MB file" '
59 - ipfs pin rm $HASH1
60 - '
61 -
62 - # make sure the permission problem is fixed on exit, otherwise cleanup
63 - # will fail
64 - trap "chmod 700 `dirname "$LEAF2FILE"` 2> /dev/null || true" 0
65 -
66 - test_expect_success "create a permission problem" '
67 - chmod 500 `dirname "$LEAF2FILE"` &&
68 - test_must_fail ipfs block rm $LEAF2 2>&1 | tee block_rm_err &&
69 - grep -q "permission denied" block_rm_err
70 - '
71 -
72 - test_expect_success "'ipfs repo gc' should still run and remove as much as possible" '
73 - test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out &&
74 - grep -q "removed $HASH1" repo_gc_out &&
75 - grep -q "could not remove $LEAF2" repo_gc_out &&
76 - grep -q "removed $LEAF3" repo_gc_out &&
77 - grep -q "removed $LEAF4" repo_gc_out
78 - '
79 -
80 - test_expect_success "fix the permission problem" '
81 - chmod 700 `dirname "$LEAF2FILE"`
82 - '
83 -
84 - test_expect_success "'ipfs repo gc' should be ok now" '
85 - ipfs repo gc | tee repo_gc_out
86 - grep -q "removed $LEAF2" repo_gc_out
87 - '
14 + test_expect_success "add a 1MB file with --raw-leaves" '
15 + random 1048576 56 > afile &&
16 + HASH1=`ipfs add --raw-leaves -q afile`
17 + '
18 +
19 + HASH1FILE=.ipfs/blocks/L3/CIQNIPL4GP62ZMNNSLZ2G33Z3T5VAN3YHCJTGT5FG45XWH5FGZRXL3A.data
20 +
21 + LEAF1=zb2rhZWKCMcHCfCym41ocwE5BhNQsEVLrwBkLEQaxJzRHHZch
22 + LEAF1FILE=.ipfs/blocks/C2/AFKREIBKRCW7HF6NHR6DVWECQXC5RQC7U7PKHKTI53BYYZNQP23DK5FC2Y.data
23 +
24 + LEAF2=zb2rhdUpCuyoQPRtvBW8JhAEfPaNd9dBb3QQCMMWYS1V8hjBR
25 + LEAF2FILE=.ipfs/blocks/Q6/BAFKREIDFSUIR43GJPHNDXXQA45GJVNRZBET3CRPUMYJCBLK3RTN7ZAMQ6Q
26 +
27 + LEAF3=zb2rhnwyvreekPqEMAbKqs35KYHxkNi7pXED7L2TfJKveTTva
28 + LEAF4=zb2rhnvAVvfDDnndcfQkwqNgUm94ba3zBSXyJKCfVXwU4FXx2
29 +
30 + test_expect_success "remove a leaf node from the repo manually" '
31 + rm "$LEAF1FILE"
32 + '
33 +
34 + test_expect_success "check that the node is removed" '
35 + test_must_fail ipfs cat $HASH1
36 + '
37 +
38 + test_expect_success "'ipfs repo gc' should still be be fine" '
39 + ipfs repo gc
40 + '
41 +
42 + test_expect_success "corrupt the root node of 1MB file" '
43 + test -e "$HASH1FILE" &&
44 + dd if=/dev/zero of="$HASH1FILE" count=1 bs=100 conv=notrunc
45 + '
46 +
47 + test_expect_success "'ipfs repo gc' should abort without removing anything" '
48 + test_must_fail ipfs repo gc 2>&1 | tee gc_err &&
49 + grep -q "could not retrieve links for $HASH1" gc_err &&
50 + grep -q "aborted" gc_err
51 + '
52 +
53 + test_expect_success "leaf nodes were not removed after gc" '
54 + ipfs cat $LEAF3 > /dev/null &&
55 + ipfs cat $LEAF4 > /dev/null
56 + '
57 +
58 + test_expect_success "unpin the 1MB file" '
59 + ipfs pin rm $HASH1
60 + '
61 +
62 + # make sure the permission problem is fixed on exit, otherwise cleanup
63 + # will fail
64 + trap "chmod 700 `dirname "$LEAF2FILE"` 2> /dev/null || true" 0
65 +
66 + test_expect_success "create a permission problem" '
67 + chmod 500 `dirname "$LEAF2FILE"` &&
68 + test_must_fail ipfs block rm $LEAF2 2>&1 | tee block_rm_err &&
69 + grep -q "permission denied" block_rm_err
70 + '
71 +
72 + test_expect_success "'ipfs repo gc' should still run and remove as much as possible" '
73 + test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out &&
74 + grep -q "removed $HASH1" repo_gc_out &&
75 + grep -q "could not remove $LEAF2" repo_gc_out &&
76 + grep -q "removed $LEAF3" repo_gc_out &&
77 + grep -q "removed $LEAF4" repo_gc_out
78 + '
79 +
80 + test_expect_success "fix the permission problem" '
81 + chmod 700 `dirname "$LEAF2FILE"`
82 + '
83 +
84 + test_expect_success "'ipfs repo gc' should be ok now" '
85 + ipfs repo gc | tee repo_gc_out
86 + grep -q "removed $LEAF2" repo_gc_out
87 + '
88 }
89
90 test_gc_robust_part2() {
91
92 - test_expect_success "add 1MB file normally (i.e., without raw leaves)" '
93 - random 1048576 56 > afile &&
94 - HASH2=`ipfs add -q afile`
95 - '
96 -
97 - LEAF1=QmSijovevteoY63Uj1uC5b8pkpDU5Jgyk2dYBqz3sMJUPc
98 - LEAF1FILE=.ipfs/blocks/ME/CIQECF2K344QITW5S6E6H6T4DOXDDB2XA2V7BBOCIMN2VVF4Q77SMEY.data
99 -
100 - LEAF2=QmTbPEyrA1JyGUHFvmtx1FNZVzdBreMv8Hc8jV9sBRWhNA
101 - LEAF2FILE=.ipfs/blocks/WM/CIQE4EFIJN2SUTQYSKMKNG7VM75W3SXT6LWJCHJJ73UAWN73WCX3WMY.data
102 -
103 - test_expect_success "add some additional unpinned content" '
104 - random 1000 3 > junk1 &&
105 - random 1000 4 > junk2 &&
106 - JUNK1=`ipfs add --pin=false -q junk1` &&
107 - JUNK2=`ipfs add --pin=false -q junk2`
108 - '
109 -
110 - test_expect_success "remove a leaf node from the repo manually" '
111 - rm "$LEAF1FILE"
112 - '
113 -
114 - test_expect_success "'ipfs repo gc' should abort" '
115 - test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out &&
116 - grep -q "could not retrieve links for $LEAF1" repo_gc_out &&
117 - grep -q "aborted" repo_gc_out
118 - '
119 -
120 - test_expect_success "test that garbage collector really aborted" '
121 - ipfs cat $JUNK1 > /dev/null &&
122 - ipfs cat $JUNK2 > /dev/null
123 - '
124 -
125 - test_expect_success "corrupt a key" '
126 - test -e "$LEAF2FILE" &&
127 - dd if=/dev/zero of="$LEAF2FILE" count=1 bs=100 conv=notrunc
128 - '
129 -
130 - test_expect_success "'ipfs repo gc' should abort with two errors" '
131 - test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out &&
132 - grep -q "could not retrieve links for $LEAF1" repo_gc_out &&
133 - grep -q "could not retrieve links for $LEAF2" repo_gc_out &&
134 - grep -q "aborted" repo_gc_out
135 - '
136 -
137 - test_expect_success "'ipfs repo gc --stream-errors' should abort and report each error separately" '
138 - test_must_fail ipfs repo gc --stream-errors 2>&1 | tee repo_gc_out &&
139 - grep -q "Error: could not retrieve links for $LEAF1" repo_gc_out &&
140 - grep -q "Error: could not retrieve links for $LEAF2" repo_gc_out &&
141 - grep -q "Error: garbage collection aborted" repo_gc_out
142 - '
143 -
144 - test_expect_success "unpin 1MB file" '
145 - ipfs pin rm $HASH2
146 - '
147 -
148 - test_expect_success "'ipfs repo gc' should be fine now" '
149 - ipfs repo gc | tee repo_gc_out &&
150 - grep -q "removed $HASH2" repo_gc_out &&
151 - grep -q "removed $LEAF2" repo_gc_out
152 - '
92 + test_expect_success "add 1MB file normally (i.e., without raw leaves)" '
93 + random 1048576 56 > afile &&
94 + HASH2=`ipfs add -q afile`
95 + '
96 +
97 + LEAF1=QmSijovevteoY63Uj1uC5b8pkpDU5Jgyk2dYBqz3sMJUPc
98 + LEAF1FILE=.ipfs/blocks/ME/CIQECF2K344QITW5S6E6H6T4DOXDDB2XA2V7BBOCIMN2VVF4Q77SMEY.data
99 +
100 + LEAF2=QmTbPEyrA1JyGUHFvmtx1FNZVzdBreMv8Hc8jV9sBRWhNA
101 + LEAF2FILE=.ipfs/blocks/WM/CIQE4EFIJN2SUTQYSKMKNG7VM75W3SXT6LWJCHJJ73UAWN73WCX3WMY.data
102 +
103 + test_expect_success "add some additional unpinned content" '
104 + random 1000 3 > junk1 &&
105 + random 1000 4 > junk2 &&
106 + JUNK1=`ipfs add --pin=false -q junk1` &&
107 + JUNK2=`ipfs add --pin=false -q junk2`
108 + '
109 +
110 + test_expect_success "remove a leaf node from the repo manually" '
111 + rm "$LEAF1FILE"
112 + '
113 +
114 + test_expect_success "'ipfs repo gc' should abort" '
115 + test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out &&
116 + grep -q "could not retrieve links for $LEAF1" repo_gc_out &&
117 + grep -q "aborted" repo_gc_out
118 + '
119 +
120 + test_expect_success "test that garbage collector really aborted" '
121 + ipfs cat $JUNK1 > /dev/null &&
122 + ipfs cat $JUNK2 > /dev/null
123 + '
124 +
125 + test_expect_success "corrupt a key" '
126 + test -e "$LEAF2FILE" &&
127 + dd if=/dev/zero of="$LEAF2FILE" count=1 bs=100 conv=notrunc
128 + '
129 +
130 + test_expect_success "'ipfs repo gc' should abort with two errors" '
131 + test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out &&
132 + grep -q "could not retrieve links for $LEAF1" repo_gc_out &&
133 + grep -q "could not retrieve links for $LEAF2" repo_gc_out &&
134 + grep -q "aborted" repo_gc_out
135 + '
136 +
137 + test_expect_success "'ipfs repo gc --stream-errors' should abort and report each error separately" '
138 + test_must_fail ipfs repo gc --stream-errors 2>&1 | tee repo_gc_out &&
139 + grep -q "Error: could not retrieve links for $LEAF1" repo_gc_out &&
140 + grep -q "Error: could not retrieve links for $LEAF2" repo_gc_out &&
141 + grep -q "Error: garbage collection aborted" repo_gc_out
142 + '
143 +
144 + test_expect_success "unpin 1MB file" '
145 + ipfs pin rm $HASH2
146 + '
147 +
148 + test_expect_success "'ipfs repo gc' should be fine now" '
149 + ipfs repo gc | tee repo_gc_out &&
150 + grep -q "removed $HASH2" repo_gc_out &&
151 + grep -q "removed $LEAF2" repo_gc_out
152 + '
153 }
154
155 test_init_ipfs
test/sharness/t0090-get.sh
+125 -125
@@ -11,138 +11,138 @@ test_description="Test get command"
11 test_init_ipfs
12
13 test_ipfs_get_flag() {
14 - ext="$1"; shift
15 - tar_flag="$1"; shift
16 - flag="$@"
17 -
18 - test_expect_success "ipfs get $flag succeeds" '
19 - ipfs get "$HASH" '"$flag"' >actual
20 - '
21 -
22 - test_expect_success "ipfs get $flag output looks good" '
23 - printf "%s\n\n" "Saving archive to $HASH$ext" >expected &&
24 - test_cmp expected actual
25 - '
26 -
27 - test_expect_success "ipfs get $flag archive output is valid" '
28 - tar "$tar_flag" "$HASH$ext" &&
29 - test_cmp "$HASH" data &&
30 - rm "$HASH$ext" &&
31 - rm "$HASH"
32 - '
14 + ext="$1"; shift
15 + tar_flag="$1"; shift
16 + flag="$@"
17 +
18 + test_expect_success "ipfs get $flag succeeds" '
19 + ipfs get "$HASH" '"$flag"' >actual
20 + '
21 +
22 + test_expect_success "ipfs get $flag output looks good" '
23 + printf "%s\n\n" "Saving archive to $HASH$ext" >expected &&
24 + test_cmp expected actual
25 + '
26 +
27 + test_expect_success "ipfs get $flag archive output is valid" '
28 + tar "$tar_flag" "$HASH$ext" &&
29 + test_cmp "$HASH" data &&
30 + rm "$HASH$ext" &&
31 + rm "$HASH"
32 + '
33 }
34
35 # we use a function so that we can run it both offline + online
36 test_get_cmd() {
37
38 - test_expect_success "'ipfs get --help' succeeds" '
39 - ipfs get --help >actual
40 - '
41 -
42 - test_expect_success "'ipfs get --help' output looks good" '
43 - egrep "ipfs get.*<ipfs-path>" actual >/dev/null ||
44 - test_fsh cat actual
45 - '
46 -
47 - test_expect_success "ipfs get succeeds" '
48 - echo "Hello Worlds!" >data &&
49 - HASH=`ipfs add -q data` &&
50 - ipfs get "$HASH" >actual
51 - '
52 -
53 - test_expect_success "ipfs get output looks good" '
54 - printf "%s\n\n" "Saving file(s) to $HASH" >expected &&
55 - test_cmp expected actual
56 - '
57 -
58 - test_expect_success "ipfs get file output looks good" '
59 - test_cmp "$HASH" data
60 - '
61 -
62 - test_expect_success "ipfs get DOES NOT error when trying to overwrite a file" '
63 - ipfs get "$HASH" >actual &&
64 - rm "$HASH"
65 - '
66 -
67 - test_expect_success "ipfs get works with raw leaves" '
68 - HASH2=$(ipfs add --raw-leaves -q data) &&
69 - ipfs get "$HASH2" >actual2
70 - '
71 -
72 - test_expect_success "ipfs get output looks good" '
73 - printf "%s\n\n" "Saving file(s) to $HASH2" >expected2 &&
74 - test_cmp expected2 actual2
75 - '
76 -
77 - test_expect_success "ipfs get file output looks good" '
78 - test_cmp "$HASH2" data
79 - '
80 -
81 - test_ipfs_get_flag ".tar" "-xf" -a
82 -
83 - test_ipfs_get_flag ".tar.gz" "-zxf" -a -C
84 -
85 - test_ipfs_get_flag ".tar.gz" "-zxf" -a -C -l 9
86 -
87 - test_expect_success "ipfs get succeeds (directory)" '
88 - mkdir -p dir &&
89 - touch dir/a &&
90 - mkdir -p dir/b &&
91 - echo "Hello, Worlds!" >dir/b/c &&
92 - HASH2=`ipfs add -r -q dir | tail -n 1` &&
93 - ipfs get "$HASH2" >actual
94 - '
95 -
96 - test_expect_success "ipfs get output looks good (directory)" '
97 - printf "%s\n\n" "Saving file(s) to $HASH2" >expected &&
98 - test_cmp expected actual
99 - '
100 -
101 - test_expect_success "ipfs get output is valid (directory)" '
102 - test_cmp dir/a "$HASH2"/a &&
103 - test_cmp dir/b/c "$HASH2"/b/c &&
104 - rm -r "$HASH2"
105 - '
106 -
107 - test_expect_success "ipfs get -a -C succeeds (directory)" '
108 - ipfs get "$HASH2" -a -C >actual
109 - '
110 -
111 - test_expect_success "ipfs get -a -C output looks good (directory)" '
112 - printf "%s\n\n" "Saving archive to $HASH2.tar.gz" >expected &&
113 - test_cmp expected actual
114 - '
115 -
116 - test_expect_success "gzipped tar archive output is valid (directory)" '
117 - tar -zxf "$HASH2".tar.gz &&
118 - test_cmp dir/a "$HASH2"/a &&
119 - test_cmp dir/b/c "$HASH2"/b/c &&
120 - rm -r "$HASH2"
121 - '
122 -
123 - test_expect_success "ipfs get ../.. should fail" '
124 - echo "Error: invalid 'ipfs ref' path" >expected &&
125 - test_must_fail ipfs get ../.. 2>actual &&
126 - test_cmp expected actual
127 - '
38 + test_expect_success "'ipfs get --help' succeeds" '
39 + ipfs get --help >actual
40 + '
41 +
42 + test_expect_success "'ipfs get --help' output looks good" '
43 + egrep "ipfs get.*<ipfs-path>" actual >/dev/null ||
44 + test_fsh cat actual
45 + '
46 +
47 + test_expect_success "ipfs get succeeds" '
48 + echo "Hello Worlds!" >data &&
49 + HASH=`ipfs add -q data` &&
50 + ipfs get "$HASH" >actual
51 + '
52 +
53 + test_expect_success "ipfs get output looks good" '
54 + printf "%s\n\n" "Saving file(s) to $HASH" >expected &&
55 + test_cmp expected actual
56 + '
57 +
58 + test_expect_success "ipfs get file output looks good" '
59 + test_cmp "$HASH" data
60 + '
61 +
62 + test_expect_success "ipfs get DOES NOT error when trying to overwrite a file" '
63 + ipfs get "$HASH" >actual &&
64 + rm "$HASH"
65 + '
66 +
67 + test_expect_success "ipfs get works with raw leaves" '
68 + HASH2=$(ipfs add --raw-leaves -q data) &&
69 + ipfs get "$HASH2" >actual2
70 + '
71 +
72 + test_expect_success "ipfs get output looks good" '
73 + printf "%s\n\n" "Saving file(s) to $HASH2" >expected2 &&
74 + test_cmp expected2 actual2
75 + '
76 +
77 + test_expect_success "ipfs get file output looks good" '
78 + test_cmp "$HASH2" data
79 + '
80 +
81 + test_ipfs_get_flag ".tar" "-xf" -a
82 +
83 + test_ipfs_get_flag ".tar.gz" "-zxf" -a -C
84 +
85 + test_ipfs_get_flag ".tar.gz" "-zxf" -a -C -l 9
86 +
87 + test_expect_success "ipfs get succeeds (directory)" '
88 + mkdir -p dir &&
89 + touch dir/a &&
90 + mkdir -p dir/b &&
91 + echo "Hello, Worlds!" >dir/b/c &&
92 + HASH2=`ipfs add -r -q dir | tail -n 1` &&
93 + ipfs get "$HASH2" >actual
94 + '
95 +
96 + test_expect_success "ipfs get output looks good (directory)" '
97 + printf "%s\n\n" "Saving file(s) to $HASH2" >expected &&
98 + test_cmp expected actual
99 + '
100 +
101 + test_expect_success "ipfs get output is valid (directory)" '
102 + test_cmp dir/a "$HASH2"/a &&
103 + test_cmp dir/b/c "$HASH2"/b/c &&
104 + rm -r "$HASH2"
105 + '
106 +
107 + test_expect_success "ipfs get -a -C succeeds (directory)" '
108 + ipfs get "$HASH2" -a -C >actual
109 + '
110 +
111 + test_expect_success "ipfs get -a -C output looks good (directory)" '
112 + printf "%s\n\n" "Saving archive to $HASH2.tar.gz" >expected &&
113 + test_cmp expected actual
114 + '
115 +
116 + test_expect_success "gzipped tar archive output is valid (directory)" '
117 + tar -zxf "$HASH2".tar.gz &&
118 + test_cmp dir/a "$HASH2"/a &&
119 + test_cmp dir/b/c "$HASH2"/b/c &&
120 + rm -r "$HASH2"
121 + '
122 +
123 + test_expect_success "ipfs get ../.. should fail" '
124 + echo "Error: invalid 'ipfs ref' path" >expected &&
125 + test_must_fail ipfs get ../.. 2>actual &&
126 + test_cmp expected actual
127 + '
128 }
129
130 test_get_fail() {
131 - test_expect_success "create an object that has unresolveable links" '
132 - cat <<-\EOF >bad_object &&
131 + test_expect_success "create an object that has unresolveable links" '
132 + cat <<-\EOF >bad_object &&
133 { "Links": [ { "Name": "foo", "Hash": "QmZzaC6ydNXiR65W8VjGA73ET9MZ6VFAqUT1ngYMXcpihn", "Size": 1897 }, { "Name": "bar", "Hash": "Qmd4mG6pDFDmDTn6p3hX1srP8qTbkyXKj5yjpEsiHDX3u8", "Size": 56 }, { "Name": "baz", "Hash": "QmUTjwRnG28dSrFFVTYgbr6LiDLsBmRr2SaUSTGheK2YqG", "Size": 24266 } ], "Data": "\b\u0001" }
134 - EOF
135 - cat bad_object | ipfs object put > put_out
136 - '
137 -
138 - test_expect_success "output looks good" '
139 - echo "added QmaGidyrnX8FMbWJoxp8HVwZ1uRKwCyxBJzABnR1S2FVUr" > put_exp &&
140 - test_cmp put_exp put_out
141 - '
142 -
143 - test_expect_success "ipfs get fails" '
144 - test_expect_code 1 ipfs get QmaGidyrnX8FMbWJoxp8HVwZ1uRKwCyxBJzABnR1S2FVUr
145 - '
134 +EOF
135 + cat bad_object | ipfs object put > put_out
136 + '
137 +
138 + test_expect_success "output looks good" '
139 + echo "added QmaGidyrnX8FMbWJoxp8HVwZ1uRKwCyxBJzABnR1S2FVUr" > put_exp &&
140 + test_cmp put_exp put_out
141 + '
142 +
143 + test_expect_success "ipfs get fails" '
144 + test_expect_code 1 ipfs get QmaGidyrnX8FMbWJoxp8HVwZ1uRKwCyxBJzABnR1S2FVUr
145 + '
146 }
147
148 # should work offline
@@ -156,8 +156,8 @@ test_launch_ipfs_daemon
156 test_get_cmd
157
158 test_expect_success "empty request to get doesn't panic and returns error" '
159 - curl "http://$API_ADDR/api/v0/get" > curl_out || true &&
160 - grep "not enough arugments provided" curl_out
159 + curl "http://$API_ADDR/api/v0/get" > curl_out || true &&
160 + grep "not enough arugments provided" curl_out
161
162
163 '
test/sharness/t0100-name.sh
+30 -30
@@ -13,81 +13,81 @@ test_init_ipfs
13 # test publishing a hash
14
15 test_expect_success "'ipfs name publish' succeeds" '
16 - PEERID=`ipfs id --format="<id>"` &&
17 - test_check_peerid "${PEERID}" &&
18 - ipfs name publish "/ipfs/$HASH_WELCOME_DOCS" >publish_out
16 + PEERID=`ipfs id --format="<id>"` &&
17 + test_check_peerid "${PEERID}" &&
18 + ipfs name publish "/ipfs/$HASH_WELCOME_DOCS" >publish_out
19 '
20
21 test_expect_success "publish output looks good" '
22 - echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected1 &&
23 - test_cmp expected1 publish_out
22 + echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected1 &&
23 + test_cmp expected1 publish_out
24 '
25
26 test_expect_success "'ipfs name resolve' succeeds" '
27 - ipfs name resolve "$PEERID" >output
27 + ipfs name resolve "$PEERID" >output
28 '
29
30 test_expect_success "resolve output looks good" '
31 - printf "/ipfs/%s\n" "$HASH_WELCOME_DOCS" >expected2 &&
32 - test_cmp expected2 output
31 + printf "/ipfs/%s\n" "$HASH_WELCOME_DOCS" >expected2 &&
32 + test_cmp expected2 output
33 '
34
35 # now test with a path
36
37 test_expect_success "'ipfs name publish' succeeds" '
38 - PEERID=`ipfs id --format="<id>"` &&
39 - test_check_peerid "${PEERID}" &&
40 - ipfs name publish "/ipfs/$HASH_WELCOME_DOCS/help" >publish_out
38 + PEERID=`ipfs id --format="<id>"` &&
39 + test_check_peerid "${PEERID}" &&
40 + ipfs name publish "/ipfs/$HASH_WELCOME_DOCS/help" >publish_out
41 '
42
43 test_expect_success "publish a path looks good" '
44 - echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS/help" >expected3 &&
45 - test_cmp expected3 publish_out
44 + echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS/help" >expected3 &&
45 + test_cmp expected3 publish_out
46 '
47
48 test_expect_success "'ipfs name resolve' succeeds" '
49 - ipfs name resolve "$PEERID" >output
49 + ipfs name resolve "$PEERID" >output
50 '
51
52 test_expect_success "resolve output looks good" '
53 - printf "/ipfs/%s/help\n" "$HASH_WELCOME_DOCS" >expected4 &&
54 - test_cmp expected4 output
53 + printf "/ipfs/%s/help\n" "$HASH_WELCOME_DOCS" >expected4 &&
54 + test_cmp expected4 output
55 '
56
57 test_expect_success "ipfs cat on published content succeeds" '
58 - ipfs cat "/ipfs/$HASH_WELCOME_DOCS/help" >expected &&
59 - ipfs cat "/ipns/$PEERID" >actual &&
60 - test_cmp expected actual
58 + ipfs cat "/ipfs/$HASH_WELCOME_DOCS/help" >expected &&
59 + ipfs cat "/ipns/$PEERID" >actual &&
60 + test_cmp expected actual
61 '
62
63 # publish with an explicit node ID
64
65 test_expect_failure "'ipfs name publish <local-id> <hash>' succeeds" '
66 - PEERID=`ipfs id --format="<id>"` &&
67 - test_check_peerid "${PEERID}" &&
68 - echo ipfs name publish "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" &&
69 - ipfs name publish "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish
66 + PEERID=`ipfs id --format="<id>"` &&
67 + test_check_peerid "${PEERID}" &&
68 + echo ipfs name publish "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" &&
69 + ipfs name publish "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish
70 '
71
72 test_expect_failure "publish with our explicit node ID looks good" '
73 - echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish &&
74 - test_cmp expected_node_id_publish actual_node_id_publish
73 + echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish &&
74 + test_cmp expected_node_id_publish actual_node_id_publish
75 '
76
77 # publish with an explicit node ID as key name
78
79 test_expect_success "generate and verify a new key" '
80 - NEWID=`ipfs key gen --type=rsa --size=2048 keyname` &&
81 - test_check_peerid "${NEWID}"
80 + NEWID=`ipfs key gen --type=rsa --size=2048 keyname` &&
81 + test_check_peerid "${NEWID}"
82 '
83
84 test_expect_success "'ipfs name publish --key=<peer-id> <hash>' succeeds" '
85 - ipfs name publish --key=${NEWID} "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish
85 + ipfs name publish --key=${NEWID} "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish
86 '
87
88 test_expect_success "publish an explicit node ID as key name looks good" '
89 - echo "Published to ${NEWID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish &&
90 - test_cmp expected_node_id_publish actual_node_id_publish
89 + echo "Published to ${NEWID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish &&
90 + test_cmp expected_node_id_publish actual_node_id_publish
91 '
92
93 test_done
test/sharness/t0101-iptb-name.sh
+10 -10
@@ -11,36 +11,36 @@ test_description="Test ipfs repo operations"
11 num_nodes=4
12
13 test_expect_success "set up an iptb cluster" '
14 - iptb init -n $num_nodes -p 0 -f --bootstrap=none
14 + iptb init -n $num_nodes -p 0 -f --bootstrap=none
15 '
16
17 startup_cluster $num_nodes
18
19 test_expect_success "add an obect on one node" '
20 - echo "ipns is super fun" > file &&
21 - HASH_FILE=$(ipfsi 1 add -q file)
20 + echo "ipns is super fun" > file &&
21 + HASH_FILE=$(ipfsi 1 add -q file)
22 '
23
24 test_expect_success "publish that object as an ipns entry" '
25 - ipfsi 1 name publish $HASH_FILE
25 + ipfsi 1 name publish $HASH_FILE
26 '
27
28 test_expect_success "add an entry on another node pointing to that one" '
29 - NODE1_ID=$(iptb get id 1) &&
30 - ipfsi 2 name publish /ipns/$NODE1_ID
29 + NODE1_ID=$(iptb get id 1) &&
30 + ipfsi 2 name publish /ipns/$NODE1_ID
31 '
32
33 test_expect_success "cat that entry on a third node" '
34 - NODE2_ID=$(iptb get id 2) &&
35 - ipfsi 3 cat /ipns/$NODE2_ID > output
34 + NODE2_ID=$(iptb get id 2) &&
35 + ipfsi 3 cat /ipns/$NODE2_ID > output
36 '
37
38 test_expect_success "ensure output was the same" '
39 - test_cmp file output
39 + test_cmp file output
40 '
41
42 test_expect_success "shut down iptb" '
43 - iptb stop
43 + iptb stop
44 '
45
46 test_done
test/sharness/t0110-gateway.sh
+48 -48
@@ -22,137 +22,137 @@ apiport=$API_PORT
22 # for now we check 5001 here as 5002 will be checked in gateway-writable.
23
24 test_expect_success "Make a file to test with" '
25 - echo "Hello Worlds!" >expected &&
26 - HASH=$(ipfs add -q expected) ||
27 - test_fsh cat daemon_err
25 + echo "Hello Worlds!" >expected &&
26 + HASH=$(ipfs add -q expected) ||
27 + test_fsh cat daemon_err
28 '
29
30 test_expect_success "GET IPFS path succeeds" '
31 - curl -sfo actual "http://127.0.0.1:$port/ipfs/$HASH"
31 + curl -sfo actual "http://127.0.0.1:$port/ipfs/$HASH"
32 '
33
34 test_expect_success "GET IPFS path output looks good" '
35 - test_cmp expected actual &&
36 - rm actual
35 + test_cmp expected actual &&
36 + rm actual
37 '
38
39 test_expect_success "GET IPFS directory path succeeds" '
40 - mkdir dir &&
41 - echo "12345" >dir/test &&
42 - ipfs add -r -q dir >actual &&
43 - HASH2=$(tail -n 1 actual) &&
44 - curl -sf "http://127.0.0.1:$port/ipfs/$HASH2"
40 + mkdir dir &&
41 + echo "12345" >dir/test &&
42 + ipfs add -r -q dir >actual &&
43 + HASH2=$(tail -n 1 actual) &&
44 + curl -sf "http://127.0.0.1:$port/ipfs/$HASH2"
45 '
46
47 test_expect_success "GET IPFS directory file succeeds" '
48 - curl -sfo actual "http://127.0.0.1:$port/ipfs/$HASH2/test"
48 + curl -sfo actual "http://127.0.0.1:$port/ipfs/$HASH2/test"
49 '
50
51 test_expect_success "GET IPFS directory file output looks good" '
52 - test_cmp dir/test actual
52 + test_cmp dir/test actual
53 '
54
55 test_expect_success "GET IPFS non existent file returns code expected (404)" '
56 - test_curl_resp_http_code "http://127.0.0.1:$port/ipfs/$HASH2/pleaseDontAddMe" "HTTP/1.1 404 Not Found"
56 + test_curl_resp_http_code "http://127.0.0.1:$port/ipfs/$HASH2/pleaseDontAddMe" "HTTP/1.1 404 Not Found"
57 '
58
59 test_expect_failure "GET IPNS path succeeds" '
60 - ipfs name publish "$HASH" &&
61 - PEERID=$(ipfs config Identity.PeerID) &&
62 - test_check_peerid "$PEERID" &&
63 - curl -sfo actual "http://127.0.0.1:$port/ipns/$PEERID"
60 + ipfs name publish "$HASH" &&
61 + PEERID=$(ipfs config Identity.PeerID) &&
62 + test_check_peerid "$PEERID" &&
63 + curl -sfo actual "http://127.0.0.1:$port/ipns/$PEERID"
64 '
65
66 test_expect_failure "GET IPNS path output looks good" '
67 - test_cmp expected actual
67 + test_cmp expected actual
68 '
69
70 test_expect_success "GET invalid IPFS path errors" '
71 - test_must_fail curl -sf "http://127.0.0.1:$port/ipfs/12345"
71 + test_must_fail curl -sf "http://127.0.0.1:$port/ipfs/12345"
72 '
73
74 test_expect_success "GET invalid path errors" '
75 - test_must_fail curl -sf "http://127.0.0.1:$port/12345"
75 + test_must_fail curl -sf "http://127.0.0.1:$port/12345"
76 '
77
78 test_expect_success "GET /webui returns code expected" '
79 - test_curl_resp_http_code "http://127.0.0.1:$apiport/webui" "HTTP/1.1 302 Found" "HTTP/1.1 301 Moved Permanently"
79 + test_curl_resp_http_code "http://127.0.0.1:$apiport/webui" "HTTP/1.1 302 Found" "HTTP/1.1 301 Moved Permanently"
80 '
81
82 test_expect_success "GET /webui/ returns code expected" '
83 - test_curl_resp_http_code "http://127.0.0.1:$apiport/webui/" "HTTP/1.1 302 Found" "HTTP/1.1 301 Moved Permanently"
83 + test_curl_resp_http_code "http://127.0.0.1:$apiport/webui/" "HTTP/1.1 302 Found" "HTTP/1.1 301 Moved Permanently"
84 '
85
86 test_expect_success "GET /logs returns logs" '
87 - test_expect_code 28 curl http://127.0.0.1:$apiport/logs -m1 > log_out
87 + test_expect_code 28 curl http://127.0.0.1:$apiport/logs -m1 > log_out
88 '
89
90 test_expect_success "log output looks good" '
91 - grep "log API client connected" log_out
91 + grep "log API client connected" log_out
92 '
93
94 test_expect_success "GET /api/v0/version succeeds" '
95 - curl -v "http://127.0.0.1:$apiport/api/v0/version" 2> version_out
95 + curl -v "http://127.0.0.1:$apiport/api/v0/version" 2> version_out
96 '
97
98 test_expect_success "output only has one transfer encoding header" '
99 - grep "Transfer-Encoding: chunked" version_out | wc -l | xargs echo > tecount_out &&
100 - echo "1" > tecount_exp &&
101 - test_cmp tecount_out tecount_exp
99 + grep "Transfer-Encoding: chunked" version_out | wc -l | xargs echo > tecount_out &&
100 + echo "1" > tecount_exp &&
101 + test_cmp tecount_out tecount_exp
102 '
103
104 test_expect_success "setup index hash" '
105 - mkdir index &&
106 - echo "<p></p>" > index/index.html &&
107 - INDEXHASH=$(ipfs add -q -r index | tail -n1)
108 - echo index: $INDEXHASH
105 + mkdir index &&
106 + echo "<p></p>" > index/index.html &&
107 + INDEXHASH=$(ipfs add -q -r index | tail -n1)
108 + echo index: $INDEXHASH
109 '
110
111 test_expect_success "GET 'index.html' has correct content type" '
112 - curl -I "http://127.0.0.1:$port/ipfs/$INDEXHASH/" > indexout
112 + curl -I "http://127.0.0.1:$port/ipfs/$INDEXHASH/" > indexout
113 '
114
115 test_expect_success "output looks good" '
116 - grep "Content-Type: text/html" indexout
116 + grep "Content-Type: text/html" indexout
117 '
118
119 test_expect_success "HEAD 'index.html' has no content" '
120 - curl -X HEAD --max-time 1 http://127.0.0.1:$port/ipfs/$INDEXHASH/ > output;
121 - [ ! -s output ]
120 + curl -X HEAD --max-time 1 http://127.0.0.1:$port/ipfs/$INDEXHASH/ > output;
121 + [ ! -s output ]
122 '
123
124 # test ipfs readonly api
125
126 test_curl_gateway_api() {
127 - curl -sfo actual "http://127.0.0.1:$port/api/v0/$1"
127 + curl -sfo actual "http://127.0.0.1:$port/api/v0/$1"
128 }
129
130 test_expect_success "get IPFS directory file through readonly API succeeds" '
131 - test_curl_gateway_api "cat?arg=$HASH2/test"
131 + test_curl_gateway_api "cat?arg=$HASH2/test"
132 '
133
134 test_expect_success "get IPFS directory file through readonly API output looks good" '
135 - test_cmp dir/test actual
135 + test_cmp dir/test actual
136 '
137
138 test_expect_success "refs IPFS directory file through readonly API succeeds" '
139 - test_curl_gateway_api "refs?arg=$HASH2/test"
139 + test_curl_gateway_api "refs?arg=$HASH2/test"
140 '
141
142 test_expect_success "test gateway api is sanitized" '
143 -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
144 - test_curl_resp_http_code "http://127.0.0.1:$port/api/v0/$cmd" "HTTP/1.1 404 Not Found"
145 - done
143 +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
144 + test_curl_resp_http_code "http://127.0.0.1:$port/api/v0/$cmd" "HTTP/1.1 404 Not Found"
145 + done
146 '
147
148 test_expect_success "create raw-leaves node" '
149 - echo "This is RAW!" > rfile &&
150 - echo "This is RAW!" | ipfs add --raw-leaves -q > rhash
149 + echo "This is RAW!" > rfile &&
150 + echo "This is RAW!" | ipfs add --raw-leaves -q > rhash
151 '
152
153 test_expect_success "try fetching it from gateway" '
154 - curl http://127.0.0.1:$port/ipfs/$(cat rhash) > ffile &&
155 - test_cmp rfile ffile
154 + curl http://127.0.0.1:$port/ipfs/$(cat rhash) > ffile &&
155 + test_cmp rfile ffile
156 '
157
158 test_kill_ipfs_daemon
test/sharness/t0111-gateway-writeable.sh
+50 -50
@@ -12,17 +12,17 @@ test_init_ipfs
12
13 test_launch_ipfs_daemon --writable
14 test_expect_success "ipfs daemon --writable overrides config" '
15 - curl -v -X POST http://$GWAY_ADDR/ipfs/ 2> outfile &&
16 - grep "HTTP/1.1 201 Created" outfile &&
17 - grep "Location: /ipfs/QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" outfile
15 + curl -v -X POST http://$GWAY_ADDR/ipfs/ 2> outfile &&
16 + grep "HTTP/1.1 201 Created" outfile &&
17 + grep "Location: /ipfs/QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" outfile
18 '
19 test_kill_ipfs_daemon
20
21 test_config_ipfs_gateway_writable
22 test_launch_ipfs_daemon --writable=false
23 test_expect_success "ipfs daemon --writable=false overrides Writable=true config" '
24 - curl -v -X POST http://$GWAY_ADDR/ipfs/ 2> outfile &&
25 - grep "HTTP/1.1 405 Method Not Allowed" outfile
24 + curl -v -X POST http://$GWAY_ADDR/ipfs/ 2> outfile &&
25 + grep "HTTP/1.1 405 Method Not Allowed" outfile
26 '
27 test_kill_ipfs_daemon
28 test_launch_ipfs_daemon
@@ -30,79 +30,79 @@ test_launch_ipfs_daemon
30 port=$GWAY_PORT
31
32 test_expect_success "ipfs daemon up" '
33 - pollEndpoint -host $GWAY_MADDR -ep=/version -v -tout=1s -tries=60 2>poll_apierr > poll_apiout ||
34 - test_fsh cat poll_apierr || test_fsh cat poll_apiout
33 + pollEndpoint -host $GWAY_MADDR -ep=/version -v -tout=1s -tries=60 2>poll_apierr > poll_apiout ||
34 + test_fsh cat poll_apierr || test_fsh cat poll_apiout
35 '
36
37 test_expect_success "HTTP gateway gives access to sample file" '
38 - curl -s -o welcome "http://$GWAY_ADDR/ipfs/$HASH_WELCOME_DOCS/readme" &&
39 - grep "Hello and Welcome to IPFS!" welcome
38 + curl -s -o welcome "http://$GWAY_ADDR/ipfs/$HASH_WELCOME_DOCS/readme" &&
39 + grep "Hello and Welcome to IPFS!" welcome
40 '
41
42 test_expect_success "HTTP POST file gives Hash" '
43 - echo "$RANDOM" >infile &&
44 - URL="http://localhost:$port/ipfs/" &&
45 - curl -svX POST --data-binary @infile "$URL" 2>curl_post.out &&
46 - grep "HTTP/1.1 201 Created" curl_post.out &&
47 - LOCATION=$(grep Location curl_post.out) &&
48 - HASH=$(echo $LOCATION | cut -d":" -f2- |tr -d " \n\r")
43 + echo "$RANDOM" >infile &&
44 + URL="http://localhost:$port/ipfs/" &&
45 + curl -svX POST --data-binary @infile "$URL" 2>curl_post.out &&
46 + grep "HTTP/1.1 201 Created" curl_post.out &&
47 + LOCATION=$(grep Location curl_post.out) &&
48 + HASH=$(echo $LOCATION | cut -d":" -f2- |tr -d " \n\r")
49 '
50
51 test_expect_success "We can HTTP GET file just created" '
52 - URL="http://localhost:${port}${HASH}" &&
53 - curl -so outfile "$URL" &&
54 - test_cmp infile outfile
52 + URL="http://localhost:${port}${HASH}" &&
53 + curl -so outfile "$URL" &&
54 + test_cmp infile outfile
55 '
56
57 test_expect_success "HTTP PUT empty directory" '
58 - URL="http://localhost:$port/ipfs/$HASH_EMPTY_DIR/" &&
59 - echo "PUT $URL" &&
60 - curl -svX PUT "$URL" 2>curl_putEmpty.out &&
61 - cat curl_putEmpty.out &&
62 - grep "Ipfs-Hash: $HASH_EMPTY_DIR" curl_putEmpty.out &&
63 - grep "Location: /ipfs/$HASH_EMPTY_DIR" curl_putEmpty.out &&
64 - grep "HTTP/1.1 201 Created" curl_putEmpty.out
58 + URL="http://localhost:$port/ipfs/$HASH_EMPTY_DIR/" &&
59 + echo "PUT $URL" &&
60 + curl -svX PUT "$URL" 2>curl_putEmpty.out &&
61 + cat curl_putEmpty.out &&
62 + grep "Ipfs-Hash: $HASH_EMPTY_DIR" curl_putEmpty.out &&
63 + grep "Location: /ipfs/$HASH_EMPTY_DIR" curl_putEmpty.out &&
64 + grep "HTTP/1.1 201 Created" curl_putEmpty.out
65 '
66
67 test_expect_success "HTTP GET empty directory" '
68 - echo "GET $URL" &&
69 - curl -so outfile "$URL" 2>curl_getEmpty.out &&
70 - grep "Index of /ipfs/$HASH_EMPTY_DIR/" outfile
68 + echo "GET $URL" &&
69 + curl -so outfile "$URL" 2>curl_getEmpty.out &&
70 + grep "Index of /ipfs/$HASH_EMPTY_DIR/" outfile
71 '
72
73 test_expect_success "HTTP PUT file to construct a hierarchy" '
74 - echo "$RANDOM" >infile &&
75 - URL="http://localhost:$port/ipfs/$HASH_EMPTY_DIR/test.txt" &&
76 - echo "PUT $URL" &&
77 - curl -svX PUT --data-binary @infile "$URL" 2>curl_put.out &&
78 - grep "HTTP/1.1 201 Created" curl_put.out &&
79 - LOCATION=$(grep Location curl_put.out) &&
80 - HASH=$(expr "$LOCATION" : "< Location: /ipfs/\(.*\)/test.txt")
74 + echo "$RANDOM" >infile &&
75 + URL="http://localhost:$port/ipfs/$HASH_EMPTY_DIR/test.txt" &&
76 + echo "PUT $URL" &&
77 + curl -svX PUT --data-binary @infile "$URL" 2>curl_put.out &&
78 + grep "HTTP/1.1 201 Created" curl_put.out &&
79 + LOCATION=$(grep Location curl_put.out) &&
80 + HASH=$(expr "$LOCATION" : "< Location: /ipfs/\(.*\)/test.txt")
81 '
82
83 test_expect_success "We can HTTP GET file just created" '
84 - URL="http://localhost:$port/ipfs/$HASH/test.txt" &&
85 - echo "GET $URL" &&
86 - curl -so outfile "$URL" &&
87 - test_cmp infile outfile
84 + URL="http://localhost:$port/ipfs/$HASH/test.txt" &&
85 + echo "GET $URL" &&
86 + curl -so outfile "$URL" &&
87 + test_cmp infile outfile
88 '
89
90 test_expect_success "HTTP PUT file to append to existing hierarchy" '
91 - echo "$RANDOM" >infile2 &&
92 - URL="http://localhost:$port/ipfs/$HASH/test/test.txt" &&
93 - echo "PUT $URL" &&
94 - curl -svX PUT --data-binary @infile2 "$URL" 2>curl_putAgain.out &&
95 - grep "HTTP/1.1 201 Created" curl_putAgain.out &&
96 - LOCATION=$(grep Location curl_putAgain.out) &&
97 - HASH=$(expr "$LOCATION" : "< Location: /ipfs/\(.*\)/test/test.txt")
91 + echo "$RANDOM" >infile2 &&
92 + URL="http://localhost:$port/ipfs/$HASH/test/test.txt" &&
93 + echo "PUT $URL" &&
94 + curl -svX PUT --data-binary @infile2 "$URL" 2>curl_putAgain.out &&
95 + grep "HTTP/1.1 201 Created" curl_putAgain.out &&
96 + LOCATION=$(grep Location curl_putAgain.out) &&
97 + HASH=$(expr "$LOCATION" : "< Location: /ipfs/\(.*\)/test/test.txt")
98 '
99
100
101 test_expect_success "We can HTTP GET file just updated" '
102 - URL="http://localhost:$port/ipfs/$HASH/test/test.txt" &&
103 - echo "GET $URL" &&
104 - curl -svo outfile2 "$URL" 2>curl_getAgain.out &&
105 - test_cmp infile2 outfile2
102 + URL="http://localhost:$port/ipfs/$HASH/test/test.txt" &&
103 + echo "GET $URL" &&
104 + curl -svo outfile2 "$URL" 2>curl_getAgain.out &&
105 + test_cmp infile2 outfile2
106 '
107
108 test_kill_ipfs_daemon
test/sharness/t0112-gateway-cors.sh
+15 -15
@@ -7,9 +7,9 @@
7 test_description="Test HTTP Gateway CORS Support"
8
9 test_config_ipfs_cors_headers() {
10 - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
11 - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
12 - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Headers '["X-Requested-With"]'
10 + ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
11 + ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
12 + ipfs config --json API.HTTPHeaders.Access-Control-Allow-Headers '["X-Requested-With"]'
13 }
14
15 . lib/test-lib.sh
@@ -26,48 +26,48 @@ thash='QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'
26
27 # HTTP GET Request
28 test_expect_success "GET to Gateway succeeds" '
29 - curl -svX GET "http://127.0.0.1:$gwport/ipfs/$thash" 2>curl_output
29 + curl -svX GET "http://127.0.0.1:$gwport/ipfs/$thash" 2>curl_output
30 '
31
32 cat curl_output
33 # GET Response from Gateway should contain CORS headers
34 test_expect_success "GET response for Gateway resource looks good" '
35 - grep "Access-Control-Allow-Origin:" curl_output | grep "\*" &&
36 - grep "Access-Control-Allow-Methods:" curl_output | grep " GET\b" &&
37 - grep "Access-Control-Allow-Headers:" curl_output
35 + grep "Access-Control-Allow-Origin:" curl_output | grep "\*" &&
36 + grep "Access-Control-Allow-Methods:" curl_output | grep " GET\b" &&
37 + grep "Access-Control-Allow-Headers:" curl_output
38 '
39
40 # HTTP OPTIONS Request
41 test_expect_success "OPTIONS to Gateway succeeds" '
42 - curl -svX OPTIONS "http://127.0.0.1:$gwport/ipfs/$thash" 2>curl_output
42 + curl -svX OPTIONS "http://127.0.0.1:$gwport/ipfs/$thash" 2>curl_output
43 '
44 # OPTION Response from Gateway should contain CORS headers
45 test_expect_success "OPTIONS response for Gateway resource looks good" '
46 - grep "Access-Control-Allow-Origin:" curl_output | grep "\*" &&
47 - grep "Access-Control-Allow-Methods:" curl_output | grep " GET\b" &&
48 - grep "Access-Control-Allow-Headers:" curl_output
46 + grep "Access-Control-Allow-Origin:" curl_output | grep "\*" &&
47 + grep "Access-Control-Allow-Methods:" curl_output | grep " GET\b" &&
48 + grep "Access-Control-Allow-Headers:" curl_output
49 '
50
51 # Read-Only API (at the Gateway Port)
52
53 # HTTP GET Request
54 test_expect_success "GET to API succeeds" '
55 - curl -svX GET "http://127.0.0.1:$gwport/api/v0/cat?arg=$thash" 2>curl_output
55 + curl -svX GET "http://127.0.0.1:$gwport/api/v0/cat?arg=$thash" 2>curl_output
56 '
57 # GET Response from the API should NOT contain CORS headers
58 # Blacklisting: https://git.io/vzaj2
59 # Rationale: https://git.io/vzajX
60 test_expect_success "OPTIONS response for API looks good" '
61 - grep -q "Access-Control-Allow-" curl_output && false || true
61 + grep -q "Access-Control-Allow-" curl_output && false || true
62 '
63
64 # HTTP OPTIONS Request
65 test_expect_success "OPTIONS to API succeeds" '
66 - curl -svX OPTIONS "http://127.0.0.1:$gwport/api/v0/cat?arg=$thash" 2>curl_output
66 + curl -svX OPTIONS "http://127.0.0.1:$gwport/api/v0/cat?arg=$thash" 2>curl_output
67 '
68 # OPTIONS Response from the API should NOT contain CORS headers
69 test_expect_success "OPTIONS response for API looks good" '
70 - grep -q "Access-Control-Allow-" curl_output && false || true
70 + grep -q "Access-Control-Allow-" curl_output && false || true
71 '
72
73 test_kill_ipfs_daemon
test/sharness/t0120-bootstrap.sh
+121 -121
@@ -27,132 +27,132 @@ test_init_ipfs
27
28 # we use a function so that we can run it both offline + online
29 test_bootstrap_list_cmd() {
30 - printf "" >list_expected
31 - for BP in "$@"
32 - do
33 - echo "$BP" >>list_expected
34 - done
35 -
36 - test_expect_success "'ipfs bootstrap' succeeds" '
37 - ipfs bootstrap >list_actual
38 - '
39 -
40 - test_expect_success "'ipfs bootstrap' output looks good" '
41 - test_cmp list_expected list_actual
42 - '
43 -
44 - test_expect_success "'ipfs bootstrap list' succeeds" '
45 - ipfs bootstrap list >list2_actual
46 - '
47 -
48 - test_expect_success "'ipfs bootstrap list' output looks good" '
49 - test_cmp list_expected list2_actual
50 - '
30 + printf "" >list_expected
31 + for BP in "$@"
32 + do
33 + echo "$BP" >>list_expected
34 + done
35 +
36 + test_expect_success "'ipfs bootstrap' succeeds" '
37 + ipfs bootstrap >list_actual
38 + '
39 +
40 + test_expect_success "'ipfs bootstrap' output looks good" '
41 + test_cmp list_expected list_actual
42 + '
43 +
44 + test_expect_success "'ipfs bootstrap list' succeeds" '
45 + ipfs bootstrap list >list2_actual
46 + '
47 +
48 + test_expect_success "'ipfs bootstrap list' output looks good" '
49 + test_cmp list_expected list2_actual
50 + '
51 }
52
53 # we use a function so that we can run it both offline + online
54 test_bootstrap_cmd() {
55
56 - # remove all peers just in case.
57 - # if this fails, the first listing may not be empty
58 - ipfs bootstrap rm --all
59 -
60 - test_bootstrap_list_cmd
61 -
62 - test_expect_success "'ipfs bootstrap add' succeeds" '
63 - ipfs bootstrap add "$BP1" "$BP2" "$BP3" >add_actual
64 - '
65 -
66 - test_expect_success "'ipfs bootstrap add' output looks good" '
67 - echo $BP1 >add_expected &&
68 - echo $BP2 >>add_expected &&
69 - echo $BP3 >>add_expected &&
70 - test_cmp add_expected add_actual
71 - '
72 -
73 - test_bootstrap_list_cmd $BP1 $BP2 $BP3
74 -
75 - test_expect_success "'ipfs bootstrap rm' succeeds" '
76 - ipfs bootstrap rm "$BP1" "$BP3" >rm_actual
77 - '
78 -
79 - test_expect_success "'ipfs bootstrap rm' output looks good" '
80 - echo $BP1 >rm_expected &&
81 - echo $BP3 >>rm_expected &&
82 - test_cmp rm_expected rm_actual
83 - '
84 -
85 - test_bootstrap_list_cmd $BP2
86 -
87 - test_expect_success "'ipfs bootstrap add --default' succeeds" '
88 - ipfs bootstrap add --default >add2_actual
89 - '
90 -
91 - test_expect_success "'ipfs bootstrap add --default' output has default BP" '
92 - echo $BP1 >add2_expected &&
93 - echo $BP2 >>add2_expected &&
94 - echo $BP3 >>add2_expected &&
95 - echo $BP4 >>add2_expected &&
96 - echo $BP5 >>add2_expected &&
97 - echo $BP6 >>add2_expected &&
98 - echo $BP7 >>add2_expected &&
99 - echo $BP8 >>add2_expected &&
100 - echo $BP9 >>add2_expected &&
101 - echo $BP10 >>add2_expected &&
102 - echo $BP11 >>add2_expected &&
103 - echo $BP12 >>add2_expected &&
104 - echo $BP13 >>add2_expected &&
105 - test_cmp add2_expected add2_actual
106 - '
107 -
108 - test_bootstrap_list_cmd $BP1 $BP2 $BP3 $BP4 $BP5 $BP6 $BP7 $BP8 $BP9 $BP10 $BP11 $BP12 $BP13 $BP14 $BP15 $BP16 $BP17
109 -
110 - test_expect_success "'ipfs bootstrap rm --all' succeeds" '
111 - ipfs bootstrap rm --all >rm2_actual
112 - '
113 -
114 - test_expect_success "'ipfs bootstrap rm' output looks good" '
115 - echo $BP1 >rm2_expected &&
116 - echo $BP2 >>rm2_expected &&
117 - echo $BP3 >>rm2_expected &&
118 - echo $BP4 >>rm2_expected &&
119 - echo $BP5 >>rm2_expected &&
120 - echo $BP6 >>rm2_expected &&
121 - echo $BP7 >>rm2_expected &&
122 - echo $BP8 >>rm2_expected &&
123 - echo $BP9 >>rm2_expected &&
124 - echo $BP10 >>rm2_expected &&
125 - echo $BP11 >>rm2_expected &&
126 - echo $BP12 >>rm2_expected &&
127 - echo $BP13 >>rm2_expected &&
128 - test_cmp rm2_expected rm2_actual
129 - '
130 -
131 - test_bootstrap_list_cmd
132 -
133 - test_expect_success "'ipfs bootstrap add' accepts args from stdin" '
134 - echo $BP1 > bpeers &&
135 - echo $BP2 >> bpeers &&
136 - echo $BP3 >> bpeers &&
137 - echo $BP4 >> bpeers &&
138 - cat bpeers | ipfs bootstrap add > add_stdin_actual
139 - '
140 -
141 - test_expect_success "output looks good" '
142 - test_cmp add_stdin_actual bpeers
143 - '
144 -
145 - test_bootstrap_list_cmd $BP1 $BP2 $BP3 $BP4
146 -
147 - test_expect_success "'ipfs bootstrap rm' accepts args from stdin" '
148 - cat bpeers | ipfs bootstrap rm > rm_stdin_actual
149 - '
150 -
151 - test_expect_success "output looks good" '
152 - test_cmp rm_stdin_actual bpeers
153 - '
154 -
155 - test_bootstrap_list_cmd
56 + # remove all peers just in case.
57 + # if this fails, the first listing may not be empty
58 + ipfs bootstrap rm --all
59 +
60 + test_bootstrap_list_cmd
61 +
62 + test_expect_success "'ipfs bootstrap add' succeeds" '
63 + ipfs bootstrap add "$BP1" "$BP2" "$BP3" >add_actual
64 + '
65 +
66 + test_expect_success "'ipfs bootstrap add' output looks good" '
67 + echo $BP1 >add_expected &&
68 + echo $BP2 >>add_expected &&
69 + echo $BP3 >>add_expected &&
70 + test_cmp add_expected add_actual
71 + '
72 +
73 + test_bootstrap_list_cmd $BP1 $BP2 $BP3
74 +
75 + test_expect_success "'ipfs bootstrap rm' succeeds" '
76 + ipfs bootstrap rm "$BP1" "$BP3" >rm_actual
77 + '
78 +
79 + test_expect_success "'ipfs bootstrap rm' output looks good" '
80 + echo $BP1 >rm_expected &&
81 + echo $BP3 >>rm_expected &&
82 + test_cmp rm_expected rm_actual
83 + '
84 +
85 + test_bootstrap_list_cmd $BP2
86 +
87 + test_expect_success "'ipfs bootstrap add --default' succeeds" '
88 + ipfs bootstrap add --default >add2_actual
89 + '
90 +
91 + test_expect_success "'ipfs bootstrap add --default' output has default BP" '
92 + echo $BP1 >add2_expected &&
93 + echo $BP2 >>add2_expected &&
94 + echo $BP3 >>add2_expected &&
95 + echo $BP4 >>add2_expected &&
96 + echo $BP5 >>add2_expected &&
97 + echo $BP6 >>add2_expected &&
98 + echo $BP7 >>add2_expected &&
99 + echo $BP8 >>add2_expected &&
100 + echo $BP9 >>add2_expected &&
101 + echo $BP10 >>add2_expected &&
102 + echo $BP11 >>add2_expected &&
103 + echo $BP12 >>add2_expected &&
104 + echo $BP13 >>add2_expected &&
105 + test_cmp add2_expected add2_actual
106 + '
107 +
108 + test_bootstrap_list_cmd $BP1 $BP2 $BP3 $BP4 $BP5 $BP6 $BP7 $BP8 $BP9 $BP10 $BP11 $BP12 $BP13 $BP14 $BP15 $BP16 $BP17
109 +
110 + test_expect_success "'ipfs bootstrap rm --all' succeeds" '
111 + ipfs bootstrap rm --all >rm2_actual
112 + '
113 +
114 + test_expect_success "'ipfs bootstrap rm' output looks good" '
115 + echo $BP1 >rm2_expected &&
116 + echo $BP2 >>rm2_expected &&
117 + echo $BP3 >>rm2_expected &&
118 + echo $BP4 >>rm2_expected &&
119 + echo $BP5 >>rm2_expected &&
120 + echo $BP6 >>rm2_expected &&
121 + echo $BP7 >>rm2_expected &&
122 + echo $BP8 >>rm2_expected &&
123 + echo $BP9 >>rm2_expected &&
124 + echo $BP10 >>rm2_expected &&
125 + echo $BP11 >>rm2_expected &&
126 + echo $BP12 >>rm2_expected &&
127 + echo $BP13 >>rm2_expected &&
128 + test_cmp rm2_expected rm2_actual
129 + '
130 +
131 + test_bootstrap_list_cmd
132 +
133 + test_expect_success "'ipfs bootstrap add' accepts args from stdin" '
134 + echo $BP1 > bpeers &&
135 + echo $BP2 >> bpeers &&
136 + echo $BP3 >> bpeers &&
137 + echo $BP4 >> bpeers &&
138 + cat bpeers | ipfs bootstrap add > add_stdin_actual
139 + '
140 +
141 + test_expect_success "output looks good" '
142 + test_cmp add_stdin_actual bpeers
143 + '
144 +
145 + test_bootstrap_list_cmd $BP1 $BP2 $BP3 $BP4
146 +
147 + test_expect_success "'ipfs bootstrap rm' accepts args from stdin" '
148 + cat bpeers | ipfs bootstrap rm > rm_stdin_actual
149 + '
150 +
151 + test_expect_success "output looks good" '
152 + test_cmp rm_stdin_actual bpeers
153 + '
154 +
155 + test_bootstrap_list_cmd
156 }
157
158 # should work offline
test/sharness/t0121-bootstrap-iptb.sh
+30 -30
@@ -12,76 +12,76 @@ test_description="test node bootstrapping"
12 test_init_ipfs
13
14 test_expect_success "disable mdns" '
15 - ipfs config Discovery.MDNS.Enabled false --json
15 + ipfs config Discovery.MDNS.Enabled false --json
16 '
17
18 test_launch_ipfs_daemon
19
20 test_expect_success "setup iptb nodes" '
21 - iptb init -n 5 -f --bootstrap=none --port=0
21 + iptb init -n 5 -f --bootstrap=none --port=0
22 '
23
24 test_expect_success "start up iptb nodes" '
25 - iptb start
25 + iptb start
26 '
27
28 test_expect_success "check peers works" '
29 - ipfs swarm peers >peers_out
29 + ipfs swarm peers >peers_out
30 '
31
32 test_expect_success "correct number of peers" '
33 - test -z "`cat peers_out`"
33 + test -z "`cat peers_out`"
34 '
35
36 betterwait() {
37 - while kill -0 $1; do true; done
37 + while kill -0 $1; do true; done
38 }
39
40 test_expect_success "bring down iptb nodes" '
41 - PID0=$(cat "$IPTB_ROOT/0/daemon.pid") &&
42 - PID1=$(cat "$IPTB_ROOT/1/daemon.pid") &&
43 - PID2=$(cat "$IPTB_ROOT/2/daemon.pid") &&
44 - PID3=$(cat "$IPTB_ROOT/3/daemon.pid") &&
45 - PID4=$(cat "$IPTB_ROOT/4/daemon.pid") &&
46 - iptb stop && # TODO: add --wait flag to iptb stop
47 - betterwait $PID0
48 - betterwait $PID1
49 - betterwait $PID2
50 - betterwait $PID3
51 - betterwait $PID4
41 + PID0=$(cat "$IPTB_ROOT/0/daemon.pid") &&
42 + PID1=$(cat "$IPTB_ROOT/1/daemon.pid") &&
43 + PID2=$(cat "$IPTB_ROOT/2/daemon.pid") &&
44 + PID3=$(cat "$IPTB_ROOT/3/daemon.pid") &&
45 + PID4=$(cat "$IPTB_ROOT/4/daemon.pid") &&
46 + iptb stop && # TODO: add --wait flag to iptb stop
47 + betterwait $PID0
48 + betterwait $PID1
49 + betterwait $PID2
50 + betterwait $PID3
51 + betterwait $PID4
52 '
53
54 test_expect_success "reset iptb nodes" '
55 - # the api doesnt seem to get cleaned up in sharness tests for some reason
56 - iptb init -n 5 -f --bootstrap=none --port=0
55 + # the api doesnt seem to get cleaned up in sharness tests for some reason
56 + iptb init -n 5 -f --bootstrap=none --port=0
57 '
58
59 test_expect_success "set bootstrap addrs" '
60 - bsn_peer_id=$(ipfs id -f "<id>") &&
61 - BADDR="/ip4/127.0.0.1/tcp/$SWARM_PORT/ipfs/$bsn_peer_id" &&
62 - ipfsi 0 bootstrap add $BADDR &&
63 - ipfsi 1 bootstrap add $BADDR &&
64 - ipfsi 2 bootstrap add $BADDR &&
65 - ipfsi 3 bootstrap add $BADDR &&
66 - ipfsi 4 bootstrap add $BADDR
60 + bsn_peer_id=$(ipfs id -f "<id>") &&
61 + BADDR="/ip4/127.0.0.1/tcp/$SWARM_PORT/ipfs/$bsn_peer_id" &&
62 + ipfsi 0 bootstrap add $BADDR &&
63 + ipfsi 1 bootstrap add $BADDR &&
64 + ipfsi 2 bootstrap add $BADDR &&
65 + ipfsi 3 bootstrap add $BADDR &&
66 + ipfsi 4 bootstrap add $BADDR
67 '
68
69 test_expect_success "start up iptb nodes" '
70 - iptb start --wait
70 + iptb start --wait
71 '
72
73 test_expect_success "check peers works" '
74 - ipfs swarm peers > peers_out
74 + ipfs swarm peers > peers_out
75 '
76
77 test_expect_success "correct number of peers" '
78 - test `cat peers_out | wc -l` = 5
78 + test `cat peers_out | wc -l` = 5
79 '
80
81 test_kill_ipfs_daemon
82
83 test_expect_success "bring down iptb nodes" '
84 - iptb stop
84 + iptb stop
85 '
86
87 test_done
test/sharness/t0125-twonode.sh
+57 -57
@@ -9,84 +9,84 @@ test_description="Test two ipfs nodes transferring a file"
9 . lib/test-lib.sh
10
11 check_file_fetch() {
12 - node=$1
13 - fhash=$2
14 - fname=$3
12 + node=$1
13 + fhash=$2
14 + fname=$3
15
16 - test_expect_success "can fetch file" '
17 - ipfsi $node cat $fhash > fetch_out
18 - '
16 + test_expect_success "can fetch file" '
17 + ipfsi $node cat $fhash > fetch_out
18 + '
19
20 - test_expect_success "file looks good" '
21 - test_cmp $fname fetch_out
22 - '
20 + test_expect_success "file looks good" '
21 + test_cmp $fname fetch_out
22 + '
23 }
24
25 check_dir_fetch() {
26 - node=$1
27 - ref=$2
26 + node=$1
27 + ref=$2
28
29 - test_expect_success "node can fetch all refs for dir" '
30 - ipfsi $node refs -r $ref > /dev/null
31 - '
29 + test_expect_success "node can fetch all refs for dir" '
30 + ipfsi $node refs -r $ref > /dev/null
31 + '
32 }
33
34 run_single_file_test() {
35 - test_expect_success "add a file on node1" '
36 - random 1000000 > filea &&
37 - FILEA_HASH=$(ipfsi 1 add -q filea)
38 - '
35 + test_expect_success "add a file on node1" '
36 + random 1000000 > filea &&
37 + FILEA_HASH=$(ipfsi 1 add -q filea)
38 + '
39
40 - check_file_fetch 0 $FILEA_HASH filea
40 + check_file_fetch 0 $FILEA_HASH filea
41 }
42
43 run_random_dir_test() {
44 - test_expect_success "create a bunch of random files" '
45 - random-files -depth=3 -dirs=4 -files=5 -seed=5 foobar > /dev/null
46 - '
44 + test_expect_success "create a bunch of random files" '
45 + random-files -depth=3 -dirs=4 -files=5 -seed=5 foobar > /dev/null
46 + '
47
48 - test_expect_success "add those on node 0" '
49 - DIR_HASH=$(ipfsi 0 add -r -q foobar | tail -n1)
50 - '
48 + test_expect_success "add those on node 0" '
49 + DIR_HASH=$(ipfsi 0 add -r -q foobar | tail -n1)
50 + '
51
52 - check_dir_fetch 1 $DIR_HASH
52 + check_dir_fetch 1 $DIR_HASH
53 }
54
55 run_advanced_test() {
56 - startup_cluster 2 "$@"
57 -
58 - test_expect_success "clean repo before test" '
59 - ipfsi 0 repo gc > /dev/null &&
60 - ipfsi 1 repo gc > /dev/null
61 - '
62 -
63 - run_single_file_test
64 -
65 - run_random_dir_test
66 -
67 - test_expect_success "node0 data transferred looks correct" '
68 - ipfsi 0 bitswap stat > stat0 &&
69 - grep "blocks sent: 126" stat0 > /dev/null &&
70 - grep "blocks received: 5" stat0 > /dev/null &&
71 - grep "data sent: 228113" stat0 > /dev/null &&
72 - grep "data received: 1000256" stat0 > /dev/null
73 - '
74 -
75 - test_expect_success "node1 data transferred looks correct" '
76 - ipfsi 1 bitswap stat > stat1 &&
77 - grep "blocks received: 126" stat1 > /dev/null &&
78 - grep "blocks sent: 5" stat1 > /dev/null &&
79 - grep "data received: 228113" stat1 > /dev/null &&
80 - grep "data sent: 1000256" stat1 > /dev/null
81 - '
82 -
83 - test_expect_success "shut down nodes" '
84 - iptb stop
85 - '
56 + startup_cluster 2 "$@"
57 +
58 + test_expect_success "clean repo before test" '
59 + ipfsi 0 repo gc > /dev/null &&
60 + ipfsi 1 repo gc > /dev/null
61 + '
62 +
63 + run_single_file_test
64 +
65 + run_random_dir_test
66 +
67 + test_expect_success "node0 data transferred looks correct" '
68 + ipfsi 0 bitswap stat > stat0 &&
69 + grep "blocks sent: 126" stat0 > /dev/null &&
70 + grep "blocks received: 5" stat0 > /dev/null &&
71 + grep "data sent: 228113" stat0 > /dev/null &&
72 + grep "data received: 1000256" stat0 > /dev/null
73 + '
74 +
75 + test_expect_success "node1 data transferred looks correct" '
76 + ipfsi 1 bitswap stat > stat1 &&
77 + grep "blocks received: 126" stat1 > /dev/null &&
78 + grep "blocks sent: 5" stat1 > /dev/null &&
79 + grep "data received: 228113" stat1 > /dev/null &&
80 + grep "data sent: 1000256" stat1 > /dev/null
81 + '
82 +
83 + test_expect_success "shut down nodes" '
84 + iptb stop
85 + '
86 }
87
88 test_expect_success "set up tcp testbed" '
89 - iptb init -n 2 -p 0 -f --bootstrap=none
89 + iptb init -n 2 -p 0 -f --bootstrap=none
90 '
91
92 # test multiplex muxer
test/sharness/t0130-multinode.sh
+51 -51
@@ -9,83 +9,83 @@ test_description="Test multiple ipfs nodes"
9 . lib/test-lib.sh
10
11 check_file_fetch() {
12 - node=$1
13 - fhash=$2
14 - fname=$3
12 + node=$1
13 + fhash=$2
14 + fname=$3
15
16 - test_expect_success "can fetch file" '
17 - ipfsi $node cat $fhash > fetch_out
18 - '
16 + test_expect_success "can fetch file" '
17 + ipfsi $node cat $fhash > fetch_out
18 + '
19
20 - test_expect_success "file looks good" '
21 - test_cmp $fname fetch_out
22 - '
20 + test_expect_success "file looks good" '
21 + test_cmp $fname fetch_out
22 + '
23 }
24
25 check_dir_fetch() {
26 - node=$1
27 - ref=$2
26 + node=$1
27 + ref=$2
28
29 - test_expect_success "node can fetch all refs for dir" '
30 - ipfsi $node refs -r $ref > /dev/null
31 - '
29 + test_expect_success "node can fetch all refs for dir" '
30 + ipfsi $node refs -r $ref > /dev/null
31 + '
32 }
33
34 run_single_file_test() {
35 - test_expect_success "add a file on node1" '
36 - random 1000000 > filea &&
37 - FILEA_HASH=$(ipfsi 1 add -q filea)
38 - '
39 -
40 - check_file_fetch 4 $FILEA_HASH filea
41 - check_file_fetch 3 $FILEA_HASH filea
42 - check_file_fetch 2 $FILEA_HASH filea
43 - check_file_fetch 1 $FILEA_HASH filea
44 - check_file_fetch 0 $FILEA_HASH filea
35 + test_expect_success "add a file on node1" '
36 + random 1000000 > filea &&
37 + FILEA_HASH=$(ipfsi 1 add -q filea)
38 + '
39 +
40 + check_file_fetch 4 $FILEA_HASH filea
41 + check_file_fetch 3 $FILEA_HASH filea
42 + check_file_fetch 2 $FILEA_HASH filea
43 + check_file_fetch 1 $FILEA_HASH filea
44 + check_file_fetch 0 $FILEA_HASH filea
45 }
46
47 run_random_dir_test() {
48 - test_expect_success "create a bunch of random files" '
49 - random-files -depth=4 -dirs=5 -files=8 foobar > /dev/null
50 - '
51 -
52 - test_expect_success "add those on node 2" '
53 - DIR_HASH=$(ipfsi 2 add -r -q foobar | tail -n1)
54 - '
55 -
56 - check_dir_fetch 0 $DIR_HASH
57 - check_dir_fetch 1 $DIR_HASH
58 - check_dir_fetch 2 $DIR_HASH
59 - check_dir_fetch 3 $DIR_HASH
60 - check_dir_fetch 4 $DIR_HASH
48 + test_expect_success "create a bunch of random files" '
49 + random-files -depth=4 -dirs=5 -files=8 foobar > /dev/null
50 + '
51 +
52 + test_expect_success "add those on node 2" '
53 + DIR_HASH=$(ipfsi 2 add -r -q foobar | tail -n1)
54 + '
55 +
56 + check_dir_fetch 0 $DIR_HASH
57 + check_dir_fetch 1 $DIR_HASH
58 + check_dir_fetch 2 $DIR_HASH
59 + check_dir_fetch 3 $DIR_HASH
60 + check_dir_fetch 4 $DIR_HASH
61 }
62
63
64 run_basic_test() {
65 - startup_cluster 5
65 + startup_cluster 5
66
67 - run_single_file_test
67 + run_single_file_test
68
69 - test_expect_success "shut down nodes" '
70 - iptb stop
71 - '
69 + test_expect_success "shut down nodes" '
70 + iptb stop
71 + '
72 }
73
74 run_advanced_test() {
75 - startup_cluster 5 "$@"
75 + startup_cluster 5 "$@"
76
77 - run_single_file_test
77 + run_single_file_test
78
79 - run_random_dir_test
79 + run_random_dir_test
80
81 - test_expect_success "shut down nodes" '
82 - iptb stop ||
83 - test_fsh tail -n +1 .iptb/*/daemon.std*
84 - '
81 + test_expect_success "shut down nodes" '
82 + iptb stop ||
83 + test_fsh tail -n +1 .iptb/*/daemon.std*
84 + '
85 }
86
87 test_expect_success "set up /tcp testbed" '
88 - iptb init -n 5 -p 0 -f --bootstrap=none
88 + iptb init -n 5 -p 0 -f --bootstrap=none
89 '
90
91 # test multiplex muxer
@@ -97,7 +97,7 @@ unset LIBP2P_MUX_PREFS
97 run_advanced_test
98
99 test_expect_success "set up /ws testbed" '
100 - iptb init -n 5 -ws -p 0 -f --bootstrap=none
100 + iptb init -n 5 -ws -p 0 -f --bootstrap=none
101 '
102
103 # test multiplex muxer
test/sharness/t0131-multinode-client-routing.sh
+32 -32
@@ -9,65 +9,65 @@ test_description="Test client mode dht"
9 . lib/test-lib.sh
10
11 check_file_fetch() {
12 - node=$1
13 - fhash=$2
14 - fname=$3
12 + node=$1
13 + fhash=$2
14 + fname=$3
15
16 - test_expect_success "can fetch file" '
17 - ipfsi $node cat $fhash > fetch_out
18 - '
16 + test_expect_success "can fetch file" '
17 + ipfsi $node cat $fhash > fetch_out
18 + '
19
20 - test_expect_success "file looks good" '
21 - test_cmp $fname fetch_out
22 - '
20 + test_expect_success "file looks good" '
21 + test_cmp $fname fetch_out
22 + '
23 }
24
25 run_single_file_test() {
26 - test_expect_success "add a file on node1" '
27 - random 1000000 > filea &&
28 - FILEA_HASH=$(ipfsi 1 add -q filea)
29 - '
30 -
31 - check_file_fetch 9 $FILEA_HASH filea
32 - check_file_fetch 8 $FILEA_HASH filea
33 - check_file_fetch 7 $FILEA_HASH filea
34 - check_file_fetch 6 $FILEA_HASH filea
35 - check_file_fetch 5 $FILEA_HASH filea
36 - check_file_fetch 4 $FILEA_HASH filea
37 - check_file_fetch 3 $FILEA_HASH filea
38 - check_file_fetch 2 $FILEA_HASH filea
39 - check_file_fetch 1 $FILEA_HASH filea
40 - check_file_fetch 0 $FILEA_HASH filea
26 + test_expect_success "add a file on node1" '
27 + random 1000000 > filea &&
28 + FILEA_HASH=$(ipfsi 1 add -q filea)
29 + '
30 +
31 + check_file_fetch 9 $FILEA_HASH filea
32 + check_file_fetch 8 $FILEA_HASH filea
33 + check_file_fetch 7 $FILEA_HASH filea
34 + check_file_fetch 6 $FILEA_HASH filea
35 + check_file_fetch 5 $FILEA_HASH filea
36 + check_file_fetch 4 $FILEA_HASH filea
37 + check_file_fetch 3 $FILEA_HASH filea
38 + check_file_fetch 2 $FILEA_HASH filea
39 + check_file_fetch 1 $FILEA_HASH filea
40 + check_file_fetch 0 $FILEA_HASH filea
41 }
42
43 NNODES=10
44
45 test_expect_success "set up testbed" '
46 - iptb init -n $NNODES -p 0 -f --bootstrap=none
46 + iptb init -n $NNODES -p 0 -f --bootstrap=none
47 '
48
49 test_expect_success "start up nodes" '
50 - iptb start [0-7] &&
51 - iptb start [8-9] --args="--routing=dhtclient"
50 + iptb start [0-7] &&
51 + iptb start [8-9] --args="--routing=dhtclient"
52 '
53
54 test_expect_success "connect up nodes" '
55 - iptb connect [1-9] 0
55 + iptb connect [1-9] 0
56 '
57
58 test_expect_success "add a file on a node in client mode" '
59 - random 1000000 > filea &&
60 - FILE_HASH=$(ipfsi 8 add -q filea)
59 + random 1000000 > filea &&
60 + FILE_HASH=$(ipfsi 8 add -q filea)
61 '
62
63 test_expect_success "retrieve that file on a client mode node" '
64 - check_file_fetch 9 $FILE_HASH filea
64 + check_file_fetch 9 $FILE_HASH filea
65 '
66
67 run_single_file_test
68
69 test_expect_success "shut down nodes" '
70 - iptb stop
70 + iptb stop
71 '
72
73 test_done
test/sharness/t0140-swarm.sh
+30 -30
@@ -13,86 +13,86 @@ test_init_ipfs
13 test_launch_ipfs_daemon
14
15 test_expect_success 'disconnected: peers is empty' '
16 - ipfs swarm peers >actual &&
17 - test_must_be_empty actual
16 + ipfs swarm peers >actual &&
17 + test_must_be_empty actual
18 '
19
20 test_expect_success 'disconnected: addrs local has localhost' '
21 - ipfs swarm addrs local >actual &&
22 - grep "/ip4/127.0.0.1" actual
21 + ipfs swarm addrs local >actual &&
22 + grep "/ip4/127.0.0.1" actual
23 '
24
25 test_expect_success 'disconnected: addrs local matches ipfs id' '
26 - ipfs id -f="<addrs>\\n" | sort >expected &&
27 - ipfs swarm addrs local --id | sort >actual &&
28 - test_cmp expected actual
26 + ipfs id -f="<addrs>\\n" | sort >expected &&
27 + ipfs swarm addrs local --id | sort >actual &&
28 + test_cmp expected actual
29 '
30
31 test_expect_success "ipfs id self works" '
32 - myid=$(ipfs id -f="<id>") &&
33 - ipfs id --timeout=1s $myid > output
32 + myid=$(ipfs id -f="<id>") &&
33 + ipfs id --timeout=1s $myid > output
34 '
35
36 test_expect_success "output looks good" '
37 - grep $myid output &&
38 - grep PublicKey output
37 + grep $myid output &&
38 + grep PublicKey output
39 '
40
41 addr="/ip4/127.0.0.1/tcp/9898/ipfs/QmUWKoHbjsqsSMesRC2Zoscs8edyFz6F77auBB1YBBhgpX"
42
43 test_expect_success "cant trigger a dial backoff with swarm connect" '
44 - test_expect_code 1 ipfs swarm connect $addr 2> connect_out
45 - test_expect_code 1 ipfs swarm connect $addr 2>> connect_out
46 - test_expect_code 1 ipfs swarm connect $addr 2>> connect_out
47 - test_expect_code 1 grep "backoff" connect_out
44 + test_expect_code 1 ipfs swarm connect $addr 2> connect_out
45 + test_expect_code 1 ipfs swarm connect $addr 2>> connect_out
46 + test_expect_code 1 ipfs swarm connect $addr 2>> connect_out
47 + test_expect_code 1 grep "backoff" connect_out
48 '
49
50 test_kill_ipfs_daemon
51
52 announceCfg='["/ip4/127.0.0.1/tcp/4001", "/ip4/1.2.3.4/tcp/1234"]'
53 test_expect_success "test_config_set succeeds" "
54 - ipfs config --json Addresses.Announce '$announceCfg'
54 + ipfs config --json Addresses.Announce '$announceCfg'
55 "
56
57 test_launch_ipfs_daemon
58
59 test_expect_success 'Addresses.Announce affects addresses' '
60 - ipfs swarm addrs local >actual &&
61 - grep "/ip4/1.2.3.4/tcp/1234" actual &&
62 - ipfs id -f"<addrs>" | xargs -n1 echo >actual &&
63 - grep "/ip4/1.2.3.4/tcp/1234" actual
60 + ipfs swarm addrs local >actual &&
61 + grep "/ip4/1.2.3.4/tcp/1234" actual &&
62 + ipfs id -f"<addrs>" | xargs -n1 echo >actual &&
63 + grep "/ip4/1.2.3.4/tcp/1234" actual
64 '
65
66 test_kill_ipfs_daemon
67
68 noAnnounceCfg='["/ip4/1.2.3.4/tcp/1234"]'
69 test_expect_success "test_config_set succeeds" "
70 - ipfs config --json Addresses.NoAnnounce '$noAnnounceCfg'
70 + ipfs config --json Addresses.NoAnnounce '$noAnnounceCfg'
71 "
72
73 test_launch_ipfs_daemon
74
75 test_expect_success "Addresses.NoAnnounce affects addresses" '
76 - ipfs swarm addrs local >actual &&
77 - grep -v "/ip4/1.2.3.4/tcp/1234" actual &&
78 - ipfs id -f"<addrs>" | xargs -n1 echo >actual &&
79 - grep -v "/ip4/1.2.3.4/tcp/1234" actual
76 + ipfs swarm addrs local >actual &&
77 + grep -v "/ip4/1.2.3.4/tcp/1234" actual &&
78 + ipfs id -f"<addrs>" | xargs -n1 echo >actual &&
79 + grep -v "/ip4/1.2.3.4/tcp/1234" actual
80 '
81
82 test_kill_ipfs_daemon
83
84 noAnnounceCfg='["/ip4/1.2.3.4/ipcidr/16"]'
85 test_expect_success "test_config_set succeeds" "
86 - ipfs config --json Addresses.NoAnnounce '$noAnnounceCfg'
86 + ipfs config --json Addresses.NoAnnounce '$noAnnounceCfg'
87 "
88
89 test_launch_ipfs_daemon
90
91 test_expect_success "Addresses.NoAnnounce with /ipcidr affects addresses" '
92 - ipfs swarm addrs local >actual &&
93 - grep -v "/ip4/1.2.3.4/tcp/1234" actual &&
94 - ipfs id -f"<addrs>" | xargs -n1 echo >actual &&
95 - grep -v "/ip4/1.2.3.4/tcp/1234" actual
92 + ipfs swarm addrs local >actual &&
93 + grep -v "/ip4/1.2.3.4/tcp/1234" actual &&
94 + ipfs id -f"<addrs>" | xargs -n1 echo >actual &&
95 + grep -v "/ip4/1.2.3.4/tcp/1234" actual
96 '
97
98 test_kill_ipfs_daemon
test/sharness/t0141-addfilter.sh
+64 -64
@@ -16,99 +16,99 @@ AF4="/ip4/172.16.0.0/ipcidr/12"
16 test_init_ipfs
17
18 test_swarm_filter_cmd() {
19 - printf "" > list_expected
20 - for AF in "$@"
21 - do
22 - echo "$AF" >>list_expected
23 - done
24 -
25 - test_expect_success "'ipfs swarm filters' succeeds" '
26 - ipfs swarm filters > list_actual
27 - '
28 -
29 - test_expect_success "'ipfs swarm filters' output looks good" '
30 - test_sort_cmp list_expected list_actual
31 - '
19 + printf "" > list_expected
20 + for AF in "$@"
21 + do
22 + echo "$AF" >>list_expected
23 + done
24 +
25 + test_expect_success "'ipfs swarm filters' succeeds" '
26 + ipfs swarm filters > list_actual
27 + '
28 +
29 + test_expect_success "'ipfs swarm filters' output looks good" '
30 + test_sort_cmp list_expected list_actual
31 + '
32 }
33
34 test_config_swarm_addrfilters_cmd() {
35 - printf "" > list_expected
36 - for AF in "$@"
37 - do
38 - echo "$AF" >>list_expected
39 - done
40 -
41 - test_expect_success "'ipfs config Swarm.AddrFilters' succeeds" '
42 - ipfs config Swarm.AddrFilters > list_actual
43 - '
44 -
45 - printf "" > list_actual_cleaned
46 - if [ "$( cat list_actual )" != "[]" -a "$( cat list_actual )" != "null" ];
47 - then
48 - grep -v "^\]" list_actual |
49 - grep -v "^\[" |
50 - tr -d '" ,' > list_actual_cleaned
51 - fi
52 -
53 - test_expect_success "'ipfs config Swarm.AddrFilters' output looks good" '
54 - test_sort_cmp list_expected list_actual_cleaned
55 - '
35 + printf "" > list_expected
36 + for AF in "$@"
37 + do
38 + echo "$AF" >>list_expected
39 + done
40 +
41 + test_expect_success "'ipfs config Swarm.AddrFilters' succeeds" '
42 + ipfs config Swarm.AddrFilters > list_actual
43 + '
44 +
45 + printf "" > list_actual_cleaned
46 + if [ "$( cat list_actual )" != "[]" -a "$( cat list_actual )" != "null" ];
47 + then
48 + grep -v "^\]" list_actual |
49 + grep -v "^\[" |
50 + tr -d '" ,' > list_actual_cleaned
51 + fi
52 +
53 + test_expect_success "'ipfs config Swarm.AddrFilters' output looks good" '
54 + test_sort_cmp list_expected list_actual_cleaned
55 + '
56 }
57
58 test_swarm_filters() {
59
60 - # expect first address from config
61 - test_swarm_filter_cmd $AF1 $AF4
60 + # expect first address from config
61 + test_swarm_filter_cmd $AF1 $AF4
62
63 - test_config_swarm_addrfilters_cmd $AF1 $AF4
63 + test_config_swarm_addrfilters_cmd $AF1 $AF4
64
65 - ipfs swarm filters rm all
65 + ipfs swarm filters rm all
66
67 - test_swarm_filter_cmd
67 + test_swarm_filter_cmd
68
69 - test_config_swarm_addrfilters_cmd
69 + test_config_swarm_addrfilters_cmd
70
71 - test_expect_success "'ipfs swarm filter add' succeeds" '
72 - ipfs swarm filters add $AF1 $AF2 $AF3
73 - '
71 + test_expect_success "'ipfs swarm filter add' succeeds" '
72 + ipfs swarm filters add $AF1 $AF2 $AF3
73 + '
74
75 - test_swarm_filter_cmd $AF1 $AF2 $AF3
75 + test_swarm_filter_cmd $AF1 $AF2 $AF3
76
77 - test_config_swarm_addrfilters_cmd $AF1 $AF2 $AF3
77 + test_config_swarm_addrfilters_cmd $AF1 $AF2 $AF3
78
79 - test_expect_success "'ipfs swarm filter rm' succeeds" '
80 - ipfs swarm filters rm $AF2 $AF3
81 - '
79 + test_expect_success "'ipfs swarm filter rm' succeeds" '
80 + ipfs swarm filters rm $AF2 $AF3
81 + '
82
83 - test_swarm_filter_cmd $AF1
83 + test_swarm_filter_cmd $AF1
84
85 - test_config_swarm_addrfilters_cmd $AF1
85 + test_config_swarm_addrfilters_cmd $AF1
86
87 - test_expect_success "'ipfs swarm filter add' succeeds" '
88 - ipfs swarm filters add $AF4 $AF2
89 - '
87 + test_expect_success "'ipfs swarm filter add' succeeds" '
88 + ipfs swarm filters add $AF4 $AF2
89 + '
90
91 - test_swarm_filter_cmd $AF1 $AF2 $AF4
91 + test_swarm_filter_cmd $AF1 $AF2 $AF4
92
93 - test_config_swarm_addrfilters_cmd $AF1 $AF2 $AF4
93 + test_config_swarm_addrfilters_cmd $AF1 $AF2 $AF4
94
95 - test_expect_success "'ipfs swarm filter rm' succeeds" '
96 - ipfs swarm filters rm $AF1 $AF2 $AF4
97 - '
95 + test_expect_success "'ipfs swarm filter rm' succeeds" '
96 + ipfs swarm filters rm $AF1 $AF2 $AF4
97 + '
98
99 - test_swarm_filter_cmd
99 + test_swarm_filter_cmd
100
101 - test_config_swarm_addrfilters_cmd
101 + test_config_swarm_addrfilters_cmd
102 }
103
104 test_expect_success "init without any filters" '
105 - echo "null" >expected &&
106 - ipfs config Swarm.AddrFilters >actual &&
107 - test_cmp expected actual
105 + echo "null" >expected &&
106 + ipfs config Swarm.AddrFilters >actual &&
107 + test_cmp expected actual
108 '
109
110 test_expect_success "adding addresses to the config to filter succeeds" '
111 - ipfs config --json Swarm.AddrFilters "[\"$AF1\", \"$AF4\"]"
111 + ipfs config --json Swarm.AddrFilters "[\"$AF1\", \"$AF4\"]"
112 '
113
114 test_launch_ipfs_daemon
test/sharness/t0150-clisuggest.sh
+20 -20
@@ -7,26 +7,26 @@ test_description="Test ipfs cli cmd suggest"
7 test_suggest() {
8
9
10 - test_expect_success "test command fails" '
11 - test_must_fail ipfs kog 2>actual
12 - '
13 -
14 - test_expect_success "test one command is suggested" '
15 - grep "Did you mean this?" actual &&
16 - grep "log" actual ||
17 - test_fsh cat actual
18 - '
19 -
20 - test_expect_success "test command fails" '
21 - test_must_fail ipfs lis 2>actual
22 - '
23 -
24 - test_expect_success "test multiple commands are suggested" '
25 - grep "Did you mean any of these?" actual &&
26 - grep "ls" actual &&
27 - grep "id" actual ||
28 - test_fsh cat actual
29 - '
10 + test_expect_success "test command fails" '
11 + test_must_fail ipfs kog 2>actual
12 + '
13 +
14 + test_expect_success "test one command is suggested" '
15 + grep "Did you mean this?" actual &&
16 + grep "log" actual ||
17 + test_fsh cat actual
18 + '
19 +
20 + test_expect_success "test command fails" '
21 + test_must_fail ipfs lis 2>actual
22 + '
23 +
24 + test_expect_success "test multiple commands are suggested" '
25 + grep "Did you mean any of these?" actual &&
26 + grep "ls" actual &&
27 + grep "id" actual ||
28 + test_fsh cat actual
29 + '
30
31 }
32
test/sharness/t0151-sysdiag.sh
+23 -23
@@ -11,38 +11,38 @@ test_description="test output of sysdiag command"
11 test_init_ipfs
12
13 test_expect_success "ipfs diag sys succeeds" '
14 - ipfs diag sys > output
14 + ipfs diag sys > output
15 '
16
17 test_expect_success "output contains some expected keys" '
18 - grep "virt" output &&
19 - grep "interface_addresses" output &&
20 - grep "arch" output &&
21 - grep "online" output
18 + grep "virt" output &&
19 + grep "interface_addresses" output &&
20 + grep "arch" output &&
21 + grep "online" output
22 '
23
24 test_expect_success "uname succeeds" '
25 - UOUT=$(uname)
25 + UOUT=$(uname)
26 '
27
28 test_expect_success "output is similar to uname" '
29 - case $UOUT in
30 - Linux)
31 - grep linux output > /dev/null
32 - ;;
33 - Darwin)
34 - grep darwin output > /dev/null
35 - ;;
36 - FreeBSD)
37 - grep freebsd output > /dev/null
38 - ;;
39 - CYGWIN*)
40 - grep windows output > /dev/null
41 - ;;
42 - *)
43 - test_fsh echo system check for $UOUT failed, unsupported system?
44 - ;;
45 - esac
29 + case $UOUT in
30 + Linux)
31 + grep linux output > /dev/null
32 + ;;
33 + Darwin)
34 + grep darwin output > /dev/null
35 + ;;
36 + FreeBSD)
37 + grep freebsd output > /dev/null
38 + ;;
39 + CYGWIN*)
40 + grep windows output > /dev/null
41 + ;;
42 + *)
43 + test_fsh echo system check for $UOUT failed, unsupported system?
44 + ;;
45 + esac
46 '
47
48 test_done
test/sharness/t0160-resolve.sh
+70 -70
@@ -7,103 +7,103 @@ test_description="Test resolve command"
7 test_init_ipfs
8
9 test_expect_success "resolve: prepare files" '
10 - mkdir -p a/b &&
11 - echo "a/b/c" >a/b/c &&
12 - a_hash=$(ipfs add -q -r a | tail -n1) &&
13 - b_hash=$(ipfs add -q -r a/b | tail -n1) &&
14 - c_hash=$(ipfs add -q -r a/b/c | tail -n1)
10 + mkdir -p a/b &&
11 + echo "a/b/c" >a/b/c &&
12 + a_hash=$(ipfs add -q -r a | tail -n1) &&
13 + b_hash=$(ipfs add -q -r a/b | tail -n1) &&
14 + c_hash=$(ipfs add -q -r a/b/c | tail -n1)
15 '
16
17 test_resolve_setup_name() {
18 - ref=$1
19 -
20 - test_expect_success "resolve: prepare name" '
21 - id_hash=$(ipfs id -f="<id>") &&
22 - ipfs name publish "$ref" &&
23 - printf "$ref\n" >expected_nameval &&
24 - ipfs name resolve >actual_nameval &&
25 - test_cmp expected_nameval actual_nameval
26 - '
18 + ref=$1
19 +
20 + test_expect_success "resolve: prepare name" '
21 + id_hash=$(ipfs id -f="<id>") &&
22 + ipfs name publish "$ref" &&
23 + printf "$ref\n" >expected_nameval &&
24 + ipfs name resolve >actual_nameval &&
25 + test_cmp expected_nameval actual_nameval
26 + '
27 }
28
29 test_resolve_setup_name_fail() {
30 - ref=$1
31 -
32 - test_expect_failure "resolve: prepare name" '
33 - id_hash=$(ipfs id -f="<id>") &&
34 - ipfs name publish "$ref" &&
35 - printf "$ref" >expected_nameval &&
36 - ipfs name resolve >actual_nameval &&
37 - test_cmp expected_nameval actual_nameval
38 - '
30 + ref=$1
31 +
32 + test_expect_failure "resolve: prepare name" '
33 + id_hash=$(ipfs id -f="<id>") &&
34 + ipfs name publish "$ref" &&
35 + printf "$ref" >expected_nameval &&
36 + ipfs name resolve >actual_nameval &&
37 + test_cmp expected_nameval actual_nameval
38 + '
39 }
40
41 test_resolve() {
42 - src=$1
43 - dst=$2
42 + src=$1
43 + dst=$2
44
45 - test_expect_success "resolve succeeds: $src" '
46 - ipfs resolve -r "$src" >actual
47 - '
45 + test_expect_success "resolve succeeds: $src" '
46 + ipfs resolve -r "$src" >actual
47 + '
48
49 - test_expect_success "resolved correctly: $src -> $dst" '
50 - printf "$dst\n" >expected &&
51 - test_cmp expected actual
52 - '
49 + test_expect_success "resolved correctly: $src -> $dst" '
50 + printf "$dst\n" >expected &&
51 + test_cmp expected actual
52 + '
53 }
54
55 test_resolve_cmd() {
56
57 - test_resolve "/ipfs/$a_hash" "/ipfs/$a_hash"
58 - test_resolve "/ipfs/$a_hash/b" "/ipfs/$b_hash"
59 - test_resolve "/ipfs/$a_hash/b/c" "/ipfs/$c_hash"
60 - test_resolve "/ipfs/$b_hash/c" "/ipfs/$c_hash"
57 + test_resolve "/ipfs/$a_hash" "/ipfs/$a_hash"
58 + test_resolve "/ipfs/$a_hash/b" "/ipfs/$b_hash"
59 + test_resolve "/ipfs/$a_hash/b/c" "/ipfs/$c_hash"
60 + test_resolve "/ipfs/$b_hash/c" "/ipfs/$c_hash"
61
62 - test_resolve_setup_name "/ipfs/$a_hash"
63 - test_resolve "/ipns/$id_hash" "/ipfs/$a_hash"
64 - test_resolve "/ipns/$id_hash/b" "/ipfs/$b_hash"
65 - test_resolve "/ipns/$id_hash/b/c" "/ipfs/$c_hash"
62 + test_resolve_setup_name "/ipfs/$a_hash"
63 + test_resolve "/ipns/$id_hash" "/ipfs/$a_hash"
64 + test_resolve "/ipns/$id_hash/b" "/ipfs/$b_hash"
65 + test_resolve "/ipns/$id_hash/b/c" "/ipfs/$c_hash"
66
67 - test_resolve_setup_name "/ipfs/$b_hash"
68 - test_resolve "/ipns/$id_hash" "/ipfs/$b_hash"
69 - test_resolve "/ipns/$id_hash/c" "/ipfs/$c_hash"
67 + test_resolve_setup_name "/ipfs/$b_hash"
68 + test_resolve "/ipns/$id_hash" "/ipfs/$b_hash"
69 + test_resolve "/ipns/$id_hash/c" "/ipfs/$c_hash"
70
71 - test_resolve_setup_name "/ipfs/$c_hash"
72 - test_resolve "/ipns/$id_hash" "/ipfs/$c_hash"
71 + test_resolve_setup_name "/ipfs/$c_hash"
72 + test_resolve "/ipns/$id_hash" "/ipfs/$c_hash"
73 }
74
75 #todo remove this once the online resolve is fixed
76 test_resolve_fail() {
77 - src=$1
78 - dst=$2
77 + src=$1
78 + dst=$2
79
80 - test_expect_failure "resolve succeeds: $src" '
81 - ipfs resolve "$src" >actual
82 - '
80 + test_expect_failure "resolve succeeds: $src" '
81 + ipfs resolve "$src" >actual
82 + '
83
84 - test_expect_failure "resolved correctly: $src -> $dst" '
85 - printf "$dst" >expected &&
86 - test_cmp expected actual
87 - '
84 + test_expect_failure "resolved correctly: $src -> $dst" '
85 + printf "$dst" >expected &&
86 + test_cmp expected actual
87 + '
88 }
89
90 test_resolve_cmd_fail() {
91 - test_resolve "/ipfs/$a_hash" "/ipfs/$a_hash"
92 - test_resolve "/ipfs/$a_hash/b" "/ipfs/$b_hash"
93 - test_resolve "/ipfs/$a_hash/b/c" "/ipfs/$c_hash"
94 - test_resolve "/ipfs/$b_hash/c" "/ipfs/$c_hash"
95 -
96 - test_resolve_setup_name_fail "/ipfs/$a_hash"
97 - test_resolve_fail "/ipns/$id_hash" "/ipfs/$a_hash"
98 - test_resolve_fail "/ipns/$id_hash/b" "/ipfs/$b_hash"
99 - test_resolve_fail "/ipns/$id_hash/b/c" "/ipfs/$c_hash"
100 -
101 - test_resolve_setup_name_fail "/ipfs/$b_hash"
102 - test_resolve_fail "/ipns/$id_hash" "/ipfs/$b_hash"
103 - test_resolve_fail "/ipns/$id_hash/c" "/ipfs/$c_hash"
104 -
105 - test_resolve_setup_name_fail "/ipfs/$c_hash"
106 - test_resolve_fail "/ipns/$id_hash" "/ipfs/$c_hash"
91 + test_resolve "/ipfs/$a_hash" "/ipfs/$a_hash"
92 + test_resolve "/ipfs/$a_hash/b" "/ipfs/$b_hash"
93 + test_resolve "/ipfs/$a_hash/b/c" "/ipfs/$c_hash"
94 + test_resolve "/ipfs/$b_hash/c" "/ipfs/$c_hash"
95 +
96 + test_resolve_setup_name_fail "/ipfs/$a_hash"
97 + test_resolve_fail "/ipns/$id_hash" "/ipfs/$a_hash"
98 + test_resolve_fail "/ipns/$id_hash/b" "/ipfs/$b_hash"
99 + test_resolve_fail "/ipns/$id_hash/b/c" "/ipfs/$c_hash"
100 +
101 + test_resolve_setup_name_fail "/ipfs/$b_hash"
102 + test_resolve_fail "/ipns/$id_hash" "/ipfs/$b_hash"
103 + test_resolve_fail "/ipns/$id_hash/c" "/ipfs/$c_hash"
104 +
105 + test_resolve_setup_name_fail "/ipfs/$c_hash"
106 + test_resolve_fail "/ipns/$id_hash" "/ipfs/$c_hash"
107 }
108
109 # should work offline
test/sharness/t0165-keystore.sh
+47 -47
@@ -11,62 +11,62 @@ test_description="Test keystore commands"
11 test_init_ipfs
12
13 test_key_cmd() {
14 - test_expect_success "create a new rsa key" '
15 - rsahash=$(ipfs key gen foobarsa --type=rsa --size=2048)
16 - '
14 + test_expect_success "create a new rsa key" '
15 + rsahash=$(ipfs key gen foobarsa --type=rsa --size=2048)
16 + '
17
18 - test_expect_success "create a new ed25519 key" '
19 - edhash=$(ipfs key gen bazed --type=ed25519)
20 - '
18 + test_expect_success "create a new ed25519 key" '
19 + edhash=$(ipfs key gen bazed --type=ed25519)
20 + '
21
22 - test_expect_success "both keys show up in list output" '
23 - echo bazed > list_exp &&
24 - echo foobarsa >> list_exp &&
25 - echo self >> list_exp
26 - ipfs key list | sort > list_out &&
27 - test_cmp list_exp list_out
28 - '
22 + test_expect_success "both keys show up in list output" '
23 + echo bazed > list_exp &&
24 + echo foobarsa >> list_exp &&
25 + echo self >> list_exp
26 + ipfs key list | sort > list_out &&
27 + test_cmp list_exp list_out
28 + '
29
30 - test_expect_success "key hashes show up in long list output" '
31 - ipfs key list -l | grep $edhash > /dev/null &&
32 - ipfs key list -l | grep $rsahash > /dev/null
33 - '
30 + test_expect_success "key hashes show up in long list output" '
31 + ipfs key list -l | grep $edhash > /dev/null &&
32 + ipfs key list -l | grep $rsahash > /dev/null
33 + '
34
35 - test_expect_success "key list -l contains self key with peerID" '
36 - PeerID="$(ipfs config Identity.PeerID)"
37 - ipfs key list -l | grep "$PeerID self"
38 - '
35 + test_expect_success "key list -l contains self key with peerID" '
36 + PeerID="$(ipfs config Identity.PeerID)"
37 + ipfs key list -l | grep "$PeerID self"
38 + '
39
40 - test_expect_success "key rm remove a key" '
41 - ipfs key rm foobarsa
42 - echo bazed > list_exp &&
43 - echo self >> list_exp
44 - ipfs key list | sort > list_out &&
45 - test_cmp list_exp list_out
46 - '
40 + test_expect_success "key rm remove a key" '
41 + ipfs key rm foobarsa
42 + echo bazed > list_exp &&
43 + echo self >> list_exp
44 + ipfs key list | sort > list_out &&
45 + test_cmp list_exp list_out
46 + '
47
48 - test_expect_success "key rm can't remove self" '
49 - test_must_fail ipfs key rm self 2>&1 | tee key_rm_out &&
50 - grep -q "Error: cannot remove key with name" key_rm_out
51 - '
48 + test_expect_success "key rm can't remove self" '
49 + test_must_fail ipfs key rm self 2>&1 | tee key_rm_out &&
50 + grep -q "Error: cannot remove key with name" key_rm_out
51 + '
52
53 - test_expect_success "key rename rename a key" '
54 - ipfs key rename bazed fooed
55 - echo fooed > list_exp &&
56 - echo self >> list_exp
57 - ipfs key list | sort > list_out &&
58 - test_cmp list_exp list_out
59 - '
53 + test_expect_success "key rename rename a key" '
54 + ipfs key rename bazed fooed
55 + echo fooed > list_exp &&
56 + echo self >> list_exp
57 + ipfs key list | sort > list_out &&
58 + test_cmp list_exp list_out
59 + '
60
61 - test_expect_success "key rename can't rename self" '
62 - test_must_fail ipfs key rename self bar 2>&1 | tee key_rename_out &&
63 - grep -q "Error: cannot rename key with name" key_rename_out
64 - '
61 + test_expect_success "key rename can't rename self" '
62 + test_must_fail ipfs key rename self bar 2>&1 | tee key_rename_out &&
63 + grep -q "Error: cannot rename key with name" key_rename_out
64 + '
65
66 - test_expect_success "key rename can't overwrite self, even with force" '
67 - test_must_fail ipfs key rename -f fooed self 2>&1 | tee key_rename_out &&
68 - grep -q "Error: cannot overwrite key with name" key_rename_out
69 - '
66 + test_expect_success "key rename can't overwrite self, even with force" '
67 + test_must_fail ipfs key rename -f fooed self 2>&1 | tee key_rename_out &&
68 + grep -q "Error: cannot overwrite key with name" key_rename_out
69 + '
70 }
71
72 test_key_cmd
test/sharness/t0170-dht.sh
+25 -25
@@ -7,48 +7,48 @@ test_description="Test dht command"
7 # start iptb + wait for peering
8 NUM_NODES=5
9 test_expect_success 'init iptb' '
10 - iptb init -n $NUM_NODES --bootstrap=none --port=0
10 + iptb init -n $NUM_NODES --bootstrap=none --port=0
11 '
12
13 startup_cluster $NUM_NODES
14
15 test_expect_success 'peer ids' '
16 - PEERID_0=$(iptb get id 0) &&
17 - PEERID_2=$(iptb get id 2)
16 + PEERID_0=$(iptb get id 0) &&
17 + PEERID_2=$(iptb get id 2)
18 '
19
20 # ipfs dht findpeer <peerID>
21 test_expect_success 'findpeer' '
22 - ipfsi 1 dht findpeer $PEERID_0 | sort >actual &&
23 - ipfsi 0 id -f "<addrs>" | cut -d / -f 1-5 | sort >expected &&
24 - test_cmp actual expected
22 + ipfsi 1 dht findpeer $PEERID_0 | sort >actual &&
23 + ipfsi 0 id -f "<addrs>" | cut -d / -f 1-5 | sort >expected &&
24 + test_cmp actual expected
25 '
26
27 # ipfs dht put <key> <value>
28 test_expect_success 'put' '
29 - ipfsi 1 dht put planet pluto | sort >putted &&
30 - [ -s putted ] ||
31 - test_fsh cat putted
29 + ipfsi 1 dht put planet pluto | sort >putted &&
30 + [ -s putted ] ||
31 + test_fsh cat putted
32 '
33
34 test_expect_success "add a ref so we can find providers for it" '
35 - echo "some stuff" > afile &&
36 - HASH=$(ipfsi 3 add -q afile)
35 + echo "some stuff" > afile &&
36 + HASH=$(ipfsi 3 add -q afile)
37 '
38
39 # ipfs dht findprovs <key>
40 test_expect_success 'findprovs' '
41 - ipfsi 4 dht findprovs $HASH > provs &&
42 - iptb get id 3 > expected &&
43 - test_cmp provs expected
41 + ipfsi 4 dht findprovs $HASH > provs &&
42 + iptb get id 3 > expected &&
43 + test_cmp provs expected
44 '
45
46 # ipfs dht get <key>
47 test_expect_success 'get' '
48 - ipfsi 0 dht put bar foo >actual &&
49 - ipfsi 4 dht get -v bar >actual &&
50 - egrep "error: record key does not have selectorfunc" actual > /dev//null ||
51 - test_fsh cat actual
48 + ipfsi 0 dht put bar foo >actual &&
49 + ipfsi 4 dht get -v bar >actual &&
50 + egrep "error: record key does not have selectorfunc" actual > /dev//null ||
51 + test_fsh cat actual
52 '
53
54 # ipfs dht query <peerID>
@@ -56,16 +56,16 @@ test_expect_success 'get' '
56 ## turns out to be the closest to what a key hashes to.
57 # TODO: flaky. tracked by https://github.com/ipfs/go-ipfs/issues/2620
58 test_expect_success 'query' '
59 - ipfsi 3 dht query banana >actual &&
60 - ipfsi 3 dht query apple >>actual &&
61 - ipfsi 3 dht query pear >>actual &&
62 - PEERS=$(wc -l actual | cut -d '"'"' '"'"' -f 1) &&
63 - [ -s actual ] ||
64 - test_might_fail test_fsh cat actual
59 + ipfsi 3 dht query banana >actual &&
60 + ipfsi 3 dht query apple >>actual &&
61 + ipfsi 3 dht query pear >>actual &&
62 + PEERS=$(wc -l actual | cut -d '"'"' '"'"' -f 1) &&
63 + [ -s actual ] ||
64 + test_might_fail test_fsh cat actual
65 '
66
67 test_expect_success 'stop iptb' '
68 - iptb stop
68 + iptb stop
69 '
70
71 test_done
test/sharness/t0175-reprovider.sh
+50 -50
@@ -7,59 +7,59 @@ test_description="Test reprovider"
7 NUM_NODES=6
8
9 init_strategy() {
10 - test_expect_success 'init iptb' '
11 - iptb init -f -n $NUM_NODES --bootstrap=none --port=0
12 - '
10 + test_expect_success 'init iptb' '
11 + iptb init -f -n $NUM_NODES --bootstrap=none --port=0
12 + '
13
14 - test_expect_success 'peer ids' '
15 - PEERID_0=$(iptb get id 0) &&
16 - PEERID_1=$(iptb get id 1)
17 - '
14 + test_expect_success 'peer ids' '
15 + PEERID_0=$(iptb get id 0) &&
16 + PEERID_1=$(iptb get id 1)
17 + '
18
19 - test_expect_success 'use pinning startegy for reprovider' '
20 - ipfsi 0 config Reprovider.Strategy '$1'
21 - '
19 + test_expect_success 'use pinning startegy for reprovider' '
20 + ipfsi 0 config Reprovider.Strategy '$1'
21 + '
22
23 - startup_cluster ${NUM_NODES}
23 + startup_cluster ${NUM_NODES}
24 }
25
26 findprovs_empty() {
27 - test_expect_success 'findprovs '$1' succeeds' '
28 - ipfsi 1 dht findprovs -n 1 '$1' > findprovsOut
29 - '
27 + test_expect_success 'findprovs '$1' succeeds' '
28 + ipfsi 1 dht findprovs -n 1 '$1' > findprovsOut
29 + '
30
31 - test_expect_success "findprovs $1 output is empty" '
32 - test_must_be_empty findprovsOut
33 - '
31 + test_expect_success "findprovs $1 output is empty" '
32 + test_must_be_empty findprovsOut
33 + '
34 }
35
36 findprovs_expect() {
37 - test_expect_success 'findprovs '$1' succeeds' '
38 - ipfsi 1 dht findprovs -n 1 '$1' > findprovsOut &&
39 - echo '$2' > expected
40 - '
41 -
42 - test_expect_success "findprovs $1 output looks good" '
43 - test_cmp findprovsOut expected
44 - '
37 + test_expect_success 'findprovs '$1' succeeds' '
38 + ipfsi 1 dht findprovs -n 1 '$1' > findprovsOut &&
39 + echo '$2' > expected
40 + '
41 +
42 + test_expect_success "findprovs $1 output looks good" '
43 + test_cmp findprovsOut expected
44 + '
45 }
46
47 reprovide() {
48 - test_expect_success 'reprovide' '
49 - # TODO: this hangs, though only after reprovision was done
50 - ipfsi 0 bitswap reprovide
51 - '
48 + test_expect_success 'reprovide' '
49 + # TODO: this hangs, though only after reprovision was done
50 + ipfsi 0 bitswap reprovide
51 + '
52 }
53
54 test_expect_success 'stop peer 1' '
55 - iptb stop 1
55 + iptb stop 1
56 '
57
58 # Test 'all' strategy
59 init_strategy 'all'
60
61 test_expect_success 'add test object' '
62 - HASH_0=$(echo "foo" | ipfsi 0 add -q --local)
62 + HASH_0=$(echo "foo" | ipfsi 0 add -q --local)
63 '
64
65 findprovs_empty '$HASH_0'
@@ -70,14 +70,14 @@ findprovs_expect '$HASH_0' '$PEERID_0'
70 init_strategy 'pinned'
71
72 test_expect_success 'prepare test files' '
73 - echo foo > f1 &&
74 - echo bar > f2
73 + echo foo > f1 &&
74 + echo bar > f2
75 '
76
77 test_expect_success 'add test objects' '
78 - HASH_FOO=$(ipfsi 0 add -q --local --pin=false f1) &&
79 - HASH_BAR=$(ipfsi 0 add -q --local --pin=false f2) &&
80 - HASH_BAR_DIR=$(ipfsi 0 add -q --local -w f2)
78 + HASH_FOO=$(ipfsi 0 add -q --local --pin=false f1) &&
79 + HASH_BAR=$(ipfsi 0 add -q --local --pin=false f2) &&
80 + HASH_BAR_DIR=$(ipfsi 0 add -q --local -w f2)
81 '
82
83 findprovs_empty '$HASH_FOO'
@@ -91,23 +91,23 @@ findprovs_expect '$HASH_BAR' '$PEERID_0'
91 findprovs_expect '$HASH_BAR_DIR' '$PEERID_0'
92
93 test_expect_success 'stop peer 1' '
94 - iptb stop 1
94 + iptb stop 1
95 '
96
97 # Test 'roots' strategy
98 init_strategy 'roots'
99
100 test_expect_success 'prepare test files' '
101 - echo foo > f1 &&
102 - echo bar > f2 &&
103 - echo baz > f3
101 + echo foo > f1 &&
102 + echo bar > f2 &&
103 + echo baz > f3
104 '
105
106 test_expect_success 'add test objects' '
107 - HASH_FOO=$(ipfsi 0 add -q --local --pin=false f1) &&
108 - HASH_BAR=$(ipfsi 0 add -q --local --pin=false f2) &&
109 - HASH_BAZ=$(ipfsi 0 add -q --local f3) &&
110 - HASH_BAR_DIR=$(ipfsi 0 add -q --local -w f2 | tail -1)
107 + HASH_FOO=$(ipfsi 0 add -q --local --pin=false f1) &&
108 + HASH_BAR=$(ipfsi 0 add -q --local --pin=false f2) &&
109 + HASH_BAZ=$(ipfsi 0 add -q --local f3) &&
110 + HASH_BAR_DIR=$(ipfsi 0 add -q --local -w f2 | tail -1)
111 '
112
113 findprovs_empty '$HASH_FOO'
@@ -122,27 +122,27 @@ findprovs_expect '$HASH_BAZ' '$PEERID_0'
122 findprovs_expect '$HASH_BAR_DIR' '$PEERID_0'
123
124 test_expect_success 'stop peer 1' '
125 - iptb stop 1
125 + iptb stop 1
126 '
127
128 # Test reprovider working with ticking disabled
129 test_expect_success 'init iptb' '
130 - iptb init -f -n $NUM_NODES --bootstrap=none --port=0
130 + iptb init -f -n $NUM_NODES --bootstrap=none --port=0
131 '
132
133 test_expect_success 'peer ids' '
134 - PEERID_0=$(iptb get id 0) &&
135 - PEERID_1=$(iptb get id 1)
134 + PEERID_0=$(iptb get id 0) &&
135 + PEERID_1=$(iptb get id 1)
136 '
137
138 test_expect_success 'Disable reprovider ticking' '
139 - ipfsi 0 config Reprovider.Interval 0
139 + ipfsi 0 config Reprovider.Interval 0
140 '
141
142 startup_cluster ${NUM_NODES}
143
144 test_expect_success 'add test object' '
145 - HASH_0=$(echo "foo" | ipfsi 0 add -q --local)
145 + HASH_0=$(echo "foo" | ipfsi 0 add -q --local)
146 '
147
148 findprovs_empty '$HASH_0'
test/sharness/t0180-p2p.sh
+68 -68
@@ -6,159 +6,159 @@ test_description="Test experimental p2p commands"
6
7 # start iptb + wait for peering
8 test_expect_success 'init iptb' '
9 - iptb init -n 2 --bootstrap=none --port=0
9 + iptb init -n 2 --bootstrap=none --port=0
10 '
11
12 test_expect_success 'generate test data' '
13 - echo "ABCDEF" > test0.bin &&
14 - echo "012345" > test1.bin
13 + echo "ABCDEF" > test0.bin &&
14 + echo "012345" > test1.bin
15 '
16
17 startup_cluster 2
18
19 test_expect_success 'peer ids' '
20 - PEERID_0=$(iptb get id 0) &&
21 - PEERID_1=$(iptb get id 1)
20 + PEERID_0=$(iptb get id 0) &&
21 + PEERID_1=$(iptb get id 1)
22 '
23
24 test_expect_success "test ports are closed" '
25 - (! (netstat -ln | grep "LISTEN" | grep ":10101 ")) &&
26 - (! (netstat -ln | grep "LISTEN" | grep ":10102 "))
25 + (! (netstat -ln | grep "LISTEN" | grep ":10101 ")) &&
26 + (! (netstat -ln | grep "LISTEN" | grep ":10102 "))
27 '
28
29 test_expect_success 'fail without config option being enabled' '
30 - test_must_fail ipfsi 0 p2p stream ls
30 + test_must_fail ipfsi 0 p2p stream ls
31 '
32
33 test_expect_success "enable filestore config setting" '
34 - ipfsi 0 config --json Experimental.Libp2pStreamMounting true
35 - ipfsi 1 config --json Experimental.Libp2pStreamMounting true
34 + ipfsi 0 config --json Experimental.Libp2pStreamMounting true
35 + ipfsi 1 config --json Experimental.Libp2pStreamMounting true
36 '
37
38 test_expect_success 'start p2p listener' '
39 - ipfsi 0 p2p listener open p2p-test /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log
39 + ipfsi 0 p2p listener open p2p-test /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log
40 '
41
42 test_expect_success 'Test server to client communications' '
43 - ma-pipe-unidir --listen --pidFile=listener.pid send /ip4/127.0.0.1/tcp/10101 < test0.bin &
43 + ma-pipe-unidir --listen --pidFile=listener.pid send /ip4/127.0.0.1/tcp/10101 < test0.bin &
44
45 - go-sleep 500ms &&
46 - kill -0 $(cat listener.pid) &&
45 + go-sleep 500ms &&
46 + kill -0 $(cat listener.pid) &&
47
48 - ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
49 - ma-pipe-unidir recv /ip4/127.0.0.1/tcp/10102 > client.out &&
50 - test ! -f listener.pid
48 + ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
49 + ma-pipe-unidir recv /ip4/127.0.0.1/tcp/10102 > client.out &&
50 + test ! -f listener.pid
51 '
52
53 test_expect_success 'Test client to server communications' '
54 - ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 > server.out &
54 + ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 > server.out &
55
56 - go-sleep 500ms &&
57 - kill -0 $(cat listener.pid) &&
56 + go-sleep 500ms &&
57 + kill -0 $(cat listener.pid) &&
58
59 - ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
60 - ma-pipe-unidir send /ip4/127.0.0.1/tcp/10102 < test1.bin &&
61 - go-sleep 250ms &&
62 - test ! -f listener.pid
59 + ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
60 + ma-pipe-unidir send /ip4/127.0.0.1/tcp/10102 < test1.bin &&
61 + go-sleep 250ms &&
62 + test ! -f listener.pid
63 '
64
65 test_expect_success 'server to client output looks good' '
66 - test_cmp client.out test0.bin
66 + test_cmp client.out test0.bin
67 '
68
69 test_expect_success 'client to server output looks good' '
70 - test_cmp server.out test1.bin
70 + test_cmp server.out test1.bin
71 '
72
73 test_expect_success "'ipfs listener p2p ls' succeeds" '
74 - echo "/ip4/127.0.0.1/tcp/10101 /p2p/p2p-test" > expected &&
75 - ipfsi 0 p2p listener ls > actual
74 + echo "/ip4/127.0.0.1/tcp/10101 /p2p/p2p-test" > expected &&
75 + ipfsi 0 p2p listener ls > actual
76 '
77
78 test_expect_success "'ipfs p2p listener ls' output looks good" '
79 - test_cmp expected actual
79 + test_cmp expected actual
80 '
81
82 test_expect_success "Cannot re-register app handler" '
83 - (! ipfsi 0 p2p listener open p2p-test /ip4/127.0.0.1/tcp/10101)
83 + (! ipfsi 0 p2p listener open p2p-test /ip4/127.0.0.1/tcp/10101)
84 '
85
86 test_expect_success "'ipfs p2p stream ls' output is empty" '
87 - ipfsi 0 p2p stream ls > actual &&
88 - test_must_be_empty actual
87 + ipfsi 0 p2p stream ls > actual &&
88 + test_must_be_empty actual
89 '
90
91 test_expect_success "Setup: Idle stream" '
92 - ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 &
92 + ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 &
93
94 - ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
95 - ma-pipe-unidir --pidFile=client.pid recv /ip4/127.0.0.1/tcp/10102 &
94 + ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
95 + ma-pipe-unidir --pidFile=client.pid recv /ip4/127.0.0.1/tcp/10102 &
96
97 - go-sleep 500ms &&
98 - kill -0 $(cat listener.pid) && kill -0 $(cat client.pid)
97 + go-sleep 500ms &&
98 + kill -0 $(cat listener.pid) && kill -0 $(cat client.pid)
99 '
100
101 test_expect_success "'ipfs p2p stream ls' succeeds" '
102 - echo "2 /p2p/p2p-test /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected
103 - ipfsi 0 p2p stream ls > actual
102 + echo "2 /p2p/p2p-test /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected
103 + ipfsi 0 p2p stream ls > actual
104 '
105
106 test_expect_success "'ipfs p2p stream ls' output looks good" '
107 - test_cmp expected actual
107 + test_cmp expected actual
108 '
109
110 test_expect_success "'ipfs p2p stream close' closes stream" '
111 - ipfsi 0 p2p stream close 2 &&
112 - ipfsi 0 p2p stream ls > actual &&
113 - [ ! -f listener.pid ] && [ ! -f client.pid ] &&
114 - test_must_be_empty actual
111 + ipfsi 0 p2p stream close 2 &&
112 + ipfsi 0 p2p stream ls > actual &&
113 + [ ! -f listener.pid ] && [ ! -f client.pid ] &&
114 + test_must_be_empty actual
115 '
116
117 test_expect_success "'ipfs p2p listener close' closes app handler" '
118 - ipfsi 0 p2p listener close p2p-test &&
119 - ipfsi 0 p2p listener ls > actual &&
120 - test_must_be_empty actual
118 + ipfsi 0 p2p listener close p2p-test &&
119 + ipfsi 0 p2p listener ls > actual &&
120 + test_must_be_empty actual
121 '
122
123 test_expect_success "Setup: Idle stream(2)" '
124 - ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 &
124 + ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 &
125
126 - ipfsi 0 p2p listener open p2p-test2 /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log &&
127 - ipfsi 1 p2p stream dial $PEERID_0 p2p-test2 /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
128 - ma-pipe-unidir --pidFile=client.pid recv /ip4/127.0.0.1/tcp/10102 &
126 + ipfsi 0 p2p listener open p2p-test2 /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log &&
127 + ipfsi 1 p2p stream dial $PEERID_0 p2p-test2 /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
128 + ma-pipe-unidir --pidFile=client.pid recv /ip4/127.0.0.1/tcp/10102 &
129
130 - go-sleep 500ms &&
131 - kill -0 $(cat listener.pid) && kill -0 $(cat client.pid)
130 + go-sleep 500ms &&
131 + kill -0 $(cat listener.pid) && kill -0 $(cat client.pid)
132 '
133
134 test_expect_success "'ipfs p2p stream ls' succeeds(2)" '
135 - echo "3 /p2p/p2p-test2 /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected
136 - ipfsi 0 p2p stream ls > actual
137 - test_cmp expected actual
135 + echo "3 /p2p/p2p-test2 /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected
136 + ipfsi 0 p2p stream ls > actual
137 + test_cmp expected actual
138 '
139
140 test_expect_success "'ipfs p2p listener close -a' closes app handlers" '
141 - ipfsi 0 p2p listener close -a &&
142 - ipfsi 0 p2p listener ls > actual &&
143 - test_must_be_empty actual
141 + ipfsi 0 p2p listener close -a &&
142 + ipfsi 0 p2p listener ls > actual &&
143 + test_must_be_empty actual
144 '
145
146 test_expect_success "'ipfs p2p stream close -a' closes streams" '
147 - ipfsi 0 p2p stream close -a &&
148 - ipfsi 0 p2p stream ls > actual &&
149 - [ ! -f listener.pid ] && [ ! -f client.pid ] &&
150 - test_must_be_empty actual
147 + ipfsi 0 p2p stream close -a &&
148 + ipfsi 0 p2p stream ls > actual &&
149 + [ ! -f listener.pid ] && [ ! -f client.pid ] &&
150 + test_must_be_empty actual
151 '
152
153 test_expect_success "'ipfs p2p listener close' closes app numeric handlers" '
154 - ipfsi 0 p2p listener open 1234 /ip4/127.0.0.1/tcp/10101 &&
155 - ipfsi 0 p2p listener close 1234 &&
156 - ipfsi 0 p2p listener ls > actual &&
157 - test_must_be_empty actual
154 + ipfsi 0 p2p listener open 1234 /ip4/127.0.0.1/tcp/10101 &&
155 + ipfsi 0 p2p listener close 1234 &&
156 + ipfsi 0 p2p listener ls > actual &&
157 + test_must_be_empty actual
158 '
159
160 test_expect_success 'stop iptb' '
161 - iptb stop
161 + iptb stop
162 '
163
164 test_done
test/sharness/t0180-pubsub.sh
+24 -24
@@ -7,58 +7,58 @@ test_description="Test dht command"
7 # start iptb + wait for peering
8 NUM_NODES=5
9 test_expect_success 'init iptb' '
10 - iptb init -n $NUM_NODES --bootstrap=none --port=0
10 + iptb init -n $NUM_NODES --bootstrap=none --port=0
11 '
12
13 startup_cluster $NUM_NODES --enable-pubsub-experiment
14
15 test_expect_success 'peer ids' '
16 - PEERID_0=$(iptb get id 0) &&
17 - PEERID_2=$(iptb get id 2)
16 + PEERID_0=$(iptb get id 0) &&
17 + PEERID_2=$(iptb get id 2)
18 '
19
20 # ipfs pubsub sub
21 test_expect_success 'pubsub' '
22 - echo "testOK" > expected &&
23 - touch empty &&
24 - mkfifo wait ||
25 - test_fsh echo init fail
22 + echo "testOK" > expected &&
23 + touch empty &&
24 + mkfifo wait ||
25 + test_fsh echo init fail
26
27 - # ipfs pubsub sub is long-running so we need to start it in the background and
28 - # wait put its output somewhere where we can access it
29 - (
30 - ipfsi 0 pubsub sub --enc=ndpayload testTopic | if read line; then
31 - echo $line > actual &&
32 - echo > wait
33 - fi
34 - ) &
27 + # ipfs pubsub sub is long-running so we need to start it in the background and
28 + # wait put its output somewhere where we can access it
29 + (
30 + ipfsi 0 pubsub sub --enc=ndpayload testTopic | if read line; then
31 + echo $line > actual &&
32 + echo > wait
33 + fi
34 + ) &
35 '
36
37 test_expect_success "wait until ipfs pubsub sub is ready to do work" '
38 - sleep 1
38 + sleep 1
39 '
40
41 test_expect_success "can see peer subscribed to testTopic" '
42 - ipfsi 1 pubsub peers testTopic > peers_out
42 + ipfsi 1 pubsub peers testTopic > peers_out
43 '
44
45 test_expect_success "output looks good" '
46 - echo $PEERID_0 > peers_exp &&
47 - test_cmp peers_exp peers_out
46 + echo $PEERID_0 > peers_exp &&
47 + test_cmp peers_exp peers_out
48 '
49
50 test_expect_success "publish something" '
51 - ipfsi 1 pubsub pub testTopic "testOK" &> pubErr
51 + ipfsi 1 pubsub pub testTopic "testOK" &> pubErr
52 '
53
54 test_expect_success "wait until echo > wait executed" '
55 - cat wait &&
56 - test_cmp pubErr empty &&
57 - test_cmp expected actual
55 + cat wait &&
56 + test_cmp pubErr empty &&
57 + test_cmp expected actual
58 '
59
60 test_expect_success 'stop iptb' '
61 - iptb stop
61 + iptb stop
62 '
63
64 test_done
test/sharness/t0181-private-network.sh
+42 -42
@@ -13,20 +13,20 @@ test_init_ipfs
13 export LIBP2P_FORCE_PNET=1
14
15 test_expect_success "daemon won't start with force pnet env but with no key" '
16 - test_must_fail go-timeout 5 ipfs daemon > stdout 2>&1
16 + test_must_fail go-timeout 5 ipfs daemon > stdout 2>&1
17 '
18
19 unset LIBP2P_FORCE_PNET
20
21 test_expect_success "daemon output incudes info about the reason" '
22 - grep "private network was not configured but is enforced by the environment" stdout ||
23 - test_fsh cat stdout
22 + grep "private network was not configured but is enforced by the environment" stdout ||
23 + test_fsh cat stdout
24 '
25
26 pnet_key() {
27 - echo '/key/swarm/psk/1.0.0/'
28 - echo '/bin/'
29 - random 16
27 + echo '/key/swarm/psk/1.0.0/'
28 + echo '/bin/'
29 + random 16
30 }
31
32 pnet_key > $IPFS_PATH/swarm.key
@@ -34,15 +34,15 @@ pnet_key > $IPFS_PATH/swarm.key
34 LIBP2P_FORCE_PNET=1 test_launch_ipfs_daemon
35
36 test_expect_success "set up iptb testbed" '
37 - iptb init -n 5 -p 0 -f --bootstrap=none &&
38 - iptb for-each ipfs config --json Addresses.Swarm '"'"'["/ip4/127.0.0.1/tcp/0"]'"'"'
37 + iptb init -n 5 -p 0 -f --bootstrap=none &&
38 + iptb for-each ipfs config --json Addresses.Swarm '"'"'["/ip4/127.0.0.1/tcp/0"]'"'"'
39 '
40
41 set_key() {
42 - node="$1"
43 - keyfile="$2"
42 + node="$1"
43 + keyfile="$2"
44
45 - cp "$keyfile" "$IPTB_ROOT/$node/swarm.key"
45 + cp "$keyfile" "$IPTB_ROOT/$node/swarm.key"
46 }
47
48 pnet_key > key1
@@ -57,68 +57,68 @@ set_key 4 key2
57 unset LIBP2P_FORCE_PNET
58
59 test_expect_success "start nodes" '
60 - iptb start [0-4]
60 + iptb start [0-4]
61 '
62
63 test_expect_success "try connecting node in public network with priv networks" '
64 - iptb connect [1-4] 0
64 + iptb connect [1-4] 0
65 '
66
67 test_expect_success "node 0 (public network) swarm is empty" '
68 - ipfsi 0 swarm peers &&
69 - [ $(ipfsi 0 swarm peers | wc -l) -eq 0 ]
68 + ipfsi 0 swarm peers &&
69 + [ $(ipfsi 0 swarm peers | wc -l) -eq 0 ]
70 '
71
72 test_expect_success "try connecting nodes in different private networks" '
73 - iptb connect 2 3
73 + iptb connect 2 3
74 '
75
76 test_expect_success "node 3 (pnet 2) swarm is empty" '
77 - ipfsi 3 swarm peers &&
78 - [ $(ipfsi 3 swarm peers | wc -l) -eq 0 ]
77 + ipfsi 3 swarm peers &&
78 + [ $(ipfsi 3 swarm peers | wc -l) -eq 0 ]
79 '
80
81 test_expect_success "connect nodes in the same pnet" '
82 - iptb connect 1 2 &&
83 - iptb connect 3 4
82 + iptb connect 1 2 &&
83 + iptb connect 3 4
84 '
85
86 test_expect_success "nodes 1 and 2 have connected" '
87 - ipfsi 2 swarm peers &&
88 - [ $(ipfsi 2 swarm peers | wc -l) -eq 1 ]
87 + ipfsi 2 swarm peers &&
88 + [ $(ipfsi 2 swarm peers | wc -l) -eq 1 ]
89 '
90
91 test_expect_success "nodes 3 and 4 have connected" '
92 - ipfsi 4 swarm peers &&
93 - [ $(ipfsi 4 swarm peers | wc -l) -eq 1 ]
92 + ipfsi 4 swarm peers &&
93 + [ $(ipfsi 4 swarm peers | wc -l) -eq 1 ]
94 '
95
96
97 run_single_file_test() {
98 - node1=$1
99 - node2=$2
98 + node1=$1
99 + node2=$2
100
101 - test_expect_success "add a file on node$node1" '
102 - random 1000000 > filea &&
103 - FILEA_HASH=$(ipfsi $node1 add -q filea)
104 - '
101 + test_expect_success "add a file on node$node1" '
102 + random 1000000 > filea &&
103 + FILEA_HASH=$(ipfsi $node1 add -q filea)
104 + '
105
106 - check_file_fetch $node1 $FILEA_HASH filea
107 - check_file_fetch $node2 $FILEA_HASH filea
106 + check_file_fetch $node1 $FILEA_HASH filea
107 + check_file_fetch $node2 $FILEA_HASH filea
108 }
109
110 check_file_fetch() {
111 - node="$1"
112 - fhash="$2"
113 - fname="$3"
111 + node="$1"
112 + fhash="$2"
113 + fname="$3"
114
115 - test_expect_success "can fetch file" '
116 - ipfsi $node cat $fhash > fetch_out
117 - '
115 + test_expect_success "can fetch file" '
116 + ipfsi $node cat $fhash > fetch_out
117 + '
118
119 - test_expect_success "file looks good" '
120 - test_cmp $fname fetch_out
121 - '
119 + test_expect_success "file looks good" '
120 + test_cmp $fname fetch_out
121 + '
122 }
123
124 run_single_file_test 1 2
@@ -129,7 +129,7 @@ run_single_file_test 4 3
129
130
131 test_expect_success "stop testbed" '
132 - iptb stop
132 + iptb stop
133 '
134
135 test_done
test/sharness/t0182-circuit-relay.sh
+26 -26
@@ -7,81 +7,81 @@ test_description="Test circuit relay"
7 # start iptb + wait for peering
8 NUM_NODES=3
9 test_expect_success 'init iptb' '
10 - iptb init -n $NUM_NODES --bootstrap=none --port=0
10 + iptb init -n $NUM_NODES --bootstrap=none --port=0
11 '
12
13 # Network toplogy: A <-> Relay <-> B
14 test_expect_success 'start up nodes for configuration' '
15 - iptb start --args --routing=none
15 + iptb start --args --routing=none
16 '
17
18 test_expect_success 'configure EnableRelayHop in relay node' '
19 - ipfsi 1 config --json Swarm.EnableRelayHop true
19 + ipfsi 1 config --json Swarm.EnableRelayHop true
20 '
21
22 test_expect_success 'restart nodes' '
23 - iptb stop &&
24 - iptb start --args --routing=none
23 + iptb stop &&
24 + iptb start --args --routing=none
25 '
26
27 test_expect_success 'connect A <-> Relay' '
28 - iptb connect 0 1
28 + iptb connect 0 1
29 '
30
31 test_expect_success 'connect B <-> Relay' '
32 - iptb connect 2 1
32 + iptb connect 2 1
33 '
34
35 test_expect_success 'wait until relay is ready to do work' '
36 - sleep 1
36 + sleep 1
37 '
38
39 test_expect_success 'peer ids' '
40 - PEERID_0=$(iptb get id 0) &&
41 - PEERID_1=$(iptb get id 1) &&
42 - PEERID_2=$(iptb get id 2)
40 + PEERID_0=$(iptb get id 0) &&
41 + PEERID_1=$(iptb get id 1) &&
42 + PEERID_2=$(iptb get id 2)
43 '
44
45 test_expect_success 'connect A <-Relay-> B' '
46 - ipfsi 0 swarm connect /p2p-circuit/ipfs/$PEERID_2 > peers_out
46 + ipfsi 0 swarm connect /p2p-circuit/ipfs/$PEERID_2 > peers_out
47 '
48
49 test_expect_success 'output looks good' '
50 - echo "connect $PEERID_2 success" > peers_exp &&
51 - test_cmp peers_exp peers_out
50 + echo "connect $PEERID_2 success" > peers_exp &&
51 + test_cmp peers_exp peers_out
52 '
53
54 test_expect_success 'peers for A look good' '
55 - ipfsi 0 swarm peers | grep p2p-circuit > peers_out &&
56 - echo "/ipfs/$PEERID_1/p2p-circuit/ipfs/$PEERID_2" > peers_exp &&
57 - test_cmp peers_exp peers_out
55 + ipfsi 0 swarm peers | grep p2p-circuit > peers_out &&
56 + echo "/ipfs/$PEERID_1/p2p-circuit/ipfs/$PEERID_2" > peers_exp &&
57 + test_cmp peers_exp peers_out
58 '
59
60 test_expect_success 'peers for B look good' '
61 - ipfsi 2 swarm peers | grep p2p-circuit > peers_out &&
62 - echo "/ipfs/$PEERID_1/p2p-circuit/ipfs/$PEERID_0" > peers_exp &&
63 - test_cmp peers_exp peers_out
61 + ipfsi 2 swarm peers | grep p2p-circuit > peers_out &&
62 + echo "/ipfs/$PEERID_1/p2p-circuit/ipfs/$PEERID_0" > peers_exp &&
63 + test_cmp peers_exp peers_out
64 '
65
66 test_expect_success 'add an object in A' '
67 - echo "hello relay" | ipfsi 0 add > peers_out
67 + echo "hello relay" | ipfsi 0 add > peers_out
68 '
69
70 test_expect_success 'object ID' '
71 - OBJID=$(cut -f3 -d " " peers_out)
71 + OBJID=$(cut -f3 -d " " peers_out)
72 '
73
74 test_expect_success 'cat the object in B' '
75 - ipfsi 2 cat $OBJID > peers_out
75 + ipfsi 2 cat $OBJID > peers_out
76 '
77
78 test_expect_success 'output looks good' '
79 - echo "hello relay" > peers_exp &&
80 - test_cmp peers_exp peers_out
79 + echo "hello relay" > peers_exp &&
80 + test_cmp peers_exp peers_out
81 '
82
83 test_expect_success 'stop iptb' '
84 - iptb stop
84 + iptb stop
85 '
86
87 test_done
test/sharness/t0200-unixfs-ls.sh
+113 -113
@@ -12,119 +12,119 @@ test_init_ipfs
12
13 test_ls_cmd() {
14
15 - test_expect_success "'ipfs add -r testData' succeeds" '
16 - mkdir -p testData testData/d1 testData/d2 &&
17 - echo "test" >testData/f1 &&
18 - echo "data" >testData/f2 &&
19 - echo "hello" >testData/d1/a &&
20 - random 128 42 >testData/d1/128 &&
21 - echo "world" >testData/d2/a &&
22 - random 1024 42 >testData/d2/1024 &&
23 - ipfs add -r testData >actual_add
24 - '
25 -
26 - test_expect_success "'ipfs add' output looks good" '
27 - cat <<-\EOF >expected_add &&
28 - added QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe testData/d1/128
29 - added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN testData/d1/a
30 - added QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd testData/d2/1024
31 - added QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL testData/d2/a
32 - added QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH testData/f1
33 - added QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M testData/f2
34 - added QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss testData/d1
35 - added QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy testData/d2
36 - added QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj testData
37 - EOF
38 - test_cmp expected_add actual_add
39 - '
40 -
41 - test_expect_success "'ipfs file ls <dir>' succeeds" '
42 - ipfs file ls QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy >actual_ls_one_directory
43 - '
44 -
45 - test_expect_success "'ipfs file ls <dir>' output looks good" '
46 - cat <<-\EOF >expected_ls_one_directory &&
47 - 1024
48 - a
49 - EOF
50 - test_cmp expected_ls_one_directory actual_ls_one_directory
51 - '
52 -
53 - test_expect_success "'ipfs file ls <three dir hashes>' succeeds" '
54 - ipfs file ls QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls_three_directories
55 - '
56 -
57 - test_expect_success "'ipfs file ls <three dir hashes>' output looks good" '
58 - cat <<-\EOF >expected_ls_three_directories &&
59 - QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy:
60 - 1024
61 - a
62 -
63 - QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss:
64 - 128
65 - a
66 -
67 - QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj:
68 - d1
69 - d2
70 - f1
71 - f2
72 - EOF
73 - test_cmp expected_ls_three_directories actual_ls_three_directories
74 - '
75 -
76 - test_expect_success "'ipfs file ls <file hashes>' succeeds" '
77 - ipfs file ls /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe >actual_ls_file
78 - '
79 -
80 - test_expect_success "'ipfs file ls <file hashes>' output looks good" '
81 - cat <<-\EOF >expected_ls_file &&
82 - /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024
83 - QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe
84 - EOF
85 - test_cmp expected_ls_file actual_ls_file
86 - '
87 -
88 - test_expect_success "'ipfs file ls <duplicates>' succeeds" '
89 - ipfs file ls /ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1 /ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 /ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd >actual_ls_duplicates_file
90 - '
91 -
92 - test_expect_success "'ipfs file ls <duplicates>' output looks good" '
93 - cat <<-\EOF >expected_ls_duplicates_file &&
94 - /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024
95 - /ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd
96 -
97 - /ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss:
98 - /ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1:
99 - 128
100 - a
101 - EOF
102 - test_cmp expected_ls_duplicates_file actual_ls_duplicates_file
103 - '
104 -
105 - test_expect_success "'ipfs --encoding=json file ls <file hashes>' succeeds" '
106 - ipfs --encoding=json file ls /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 >actual_json_ls_file
107 - '
108 -
109 - test_expect_success "'ipfs --encoding=json file ls <file hashes>' output looks good" '
110 - cat <<-\EOF >expected_json_ls_file_trailing_newline &&
111 - {"Arguments":{"/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd"},"Objects":{"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":{"Hash":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","Size":1024,"Type":"File","Links":null}}}
112 - EOF
113 - printf "%s\n" "$(cat expected_json_ls_file_trailing_newline)" >expected_json_ls_file &&
114 - test_cmp expected_json_ls_file actual_json_ls_file
115 - '
116 -
117 - test_expect_success "'ipfs --encoding=json file ls <duplicates>' succeeds" '
118 - ipfs --encoding=json file ls /ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1 /ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 /ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd >actual_json_ls_duplicates_file
119 - '
120 -
121 - test_expect_success "'ipfs --encoding=json file ls <duplicates>' output looks good" '
122 - cat <<-\EOF >expected_json_ls_duplicates_file_trailing_newline &&
123 - {"Arguments":{"/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","/ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss","/ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","/ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss"},"Objects":{"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss":{"Hash":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss","Size":0,"Type":"Directory","Links":[{"Name":"128","Hash":"QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe","Size":128,"Type":"File"},{"Name":"a","Hash":"QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN","Size":6,"Type":"File"}]},"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":{"Hash":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","Size":1024,"Type":"File","Links":null}}}
124 - EOF
125 - printf "%s\n" "$(cat expected_json_ls_duplicates_file_trailing_newline)" >expected_json_ls_duplicates_file &&
126 - test_cmp expected_json_ls_duplicates_file actual_json_ls_duplicates_file
127 - '
15 + test_expect_success "'ipfs add -r testData' succeeds" '
16 + mkdir -p testData testData/d1 testData/d2 &&
17 + echo "test" >testData/f1 &&
18 + echo "data" >testData/f2 &&
19 + echo "hello" >testData/d1/a &&
20 + random 128 42 >testData/d1/128 &&
21 + echo "world" >testData/d2/a &&
22 + random 1024 42 >testData/d2/1024 &&
23 + ipfs add -r testData >actual_add
24 + '
25 +
26 + test_expect_success "'ipfs add' output looks good" '
27 + cat <<-\EOF >expected_add &&
28 +added QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe testData/d1/128
29 +added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN testData/d1/a
30 +added QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd testData/d2/1024
31 +added QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL testData/d2/a
32 +added QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH testData/f1
33 +added QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M testData/f2
34 +added QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss testData/d1
35 +added QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy testData/d2
36 +added QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj testData
37 +EOF
38 + test_cmp expected_add actual_add
39 + '
40 +
41 + test_expect_success "'ipfs file ls <dir>' succeeds" '
42 + ipfs file ls QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy >actual_ls_one_directory
43 + '
44 +
45 + test_expect_success "'ipfs file ls <dir>' output looks good" '
46 + cat <<-\EOF >expected_ls_one_directory &&
47 +1024
48 +a
49 +EOF
50 + test_cmp expected_ls_one_directory actual_ls_one_directory
51 + '
52 +
53 + test_expect_success "'ipfs file ls <three dir hashes>' succeeds" '
54 + ipfs file ls QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls_three_directories
55 + '
56 +
57 + test_expect_success "'ipfs file ls <three dir hashes>' output looks good" '
58 + cat <<-\EOF >expected_ls_three_directories &&
59 +QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy:
60 +1024
61 +a
62 +
63 +QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss:
64 +128
65 +a
66 +
67 +QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj:
68 +d1
69 +d2
70 +f1
71 +f2
72 +EOF
73 + test_cmp expected_ls_three_directories actual_ls_three_directories
74 + '
75 +
76 + test_expect_success "'ipfs file ls <file hashes>' succeeds" '
77 + ipfs file ls /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe >actual_ls_file
78 + '
79 +
80 + test_expect_success "'ipfs file ls <file hashes>' output looks good" '
81 + cat <<-\EOF >expected_ls_file &&
82 +/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024
83 +QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe
84 +EOF
85 + test_cmp expected_ls_file actual_ls_file
86 + '
87 +
88 + test_expect_success "'ipfs file ls <duplicates>' succeeds" '
89 + ipfs file ls /ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1 /ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 /ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd >actual_ls_duplicates_file
90 + '
91 +
92 + test_expect_success "'ipfs file ls <duplicates>' output looks good" '
93 + cat <<-\EOF >expected_ls_duplicates_file &&
94 +/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024
95 +/ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd
96 +
97 +/ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss:
98 +/ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1:
99 +128
100 +a
101 +EOF
102 + test_cmp expected_ls_duplicates_file actual_ls_duplicates_file
103 + '
104 +
105 + test_expect_success "'ipfs --encoding=json file ls <file hashes>' succeeds" '
106 + ipfs --encoding=json file ls /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 >actual_json_ls_file
107 + '
108 +
109 + test_expect_success "'ipfs --encoding=json file ls <file hashes>' output looks good" '
110 + cat <<-\EOF >expected_json_ls_file_trailing_newline &&
111 +{"Arguments":{"/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd"},"Objects":{"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":{"Hash":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","Size":1024,"Type":"File","Links":null}}}
112 +EOF
113 + printf "%s\n" "$(cat expected_json_ls_file_trailing_newline)" >expected_json_ls_file &&
114 + test_cmp expected_json_ls_file actual_json_ls_file
115 + '
116 +
117 + test_expect_success "'ipfs --encoding=json file ls <duplicates>' succeeds" '
118 + ipfs --encoding=json file ls /ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1 /ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 /ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd >actual_json_ls_duplicates_file
119 + '
120 +
121 + test_expect_success "'ipfs --encoding=json file ls <duplicates>' output looks good" '
122 + cat <<-\EOF >expected_json_ls_duplicates_file_trailing_newline &&
123 +{"Arguments":{"/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","/ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss","/ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","/ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss"},"Objects":{"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss":{"Hash":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss","Size":0,"Type":"Directory","Links":[{"Name":"128","Hash":"QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe","Size":128,"Type":"File"},{"Name":"a","Hash":"QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN","Size":6,"Type":"File"}]},"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":{"Hash":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","Size":1024,"Type":"File","Links":null}}}
124 +EOF
125 + printf "%s\n" "$(cat expected_json_ls_duplicates_file_trailing_newline)" >expected_json_ls_duplicates_file &&
126 + test_cmp expected_json_ls_duplicates_file actual_json_ls_duplicates_file
127 + '
128
129 }
130
test/sharness/t0210-tar.sh
+18 -18
@@ -11,39 +11,39 @@ test_description="Test tar commands"
11 test_init_ipfs
12
13 test_expect_success "create some random files" '
14 - mkdir foo &&
15 - random 10000 > foo/a &&
16 - random 12345 > foo/b &&
17 - mkdir foo/bar &&
18 - random 5432 > foo/bar/baz &&
19 - ln -s ../a foo/bar/link &&
20 - echo "exit" > foo/script &&
21 - chmod +x foo/script
14 + mkdir foo &&
15 + random 10000 > foo/a &&
16 + random 12345 > foo/b &&
17 + mkdir foo/bar &&
18 + random 5432 > foo/bar/baz &&
19 + ln -s ../a foo/bar/link &&
20 + echo "exit" > foo/script &&
21 + chmod +x foo/script
22 '
23
24 test_expect_success "tar those random files up" '
25 - tar cf files.tar foo/
25 + tar cf files.tar foo/
26 '
27
28 test_expect_success "'ipfs tar add' succeeds" '
29 - TAR_HASH=$(ipfs tar add files.tar)
29 + TAR_HASH=$(ipfs tar add files.tar)
30 '
31
32 test_expect_success "'ipfs tar cat' succeeds" '
33 - mkdir output &&
34 - ipfs tar cat $TAR_HASH > output/out.tar
33 + mkdir output &&
34 + ipfs tar cat $TAR_HASH > output/out.tar
35 '
36
37 test_expect_success "can extract tar" '
38 - tar xf output/out.tar -C output/
38 + tar xf output/out.tar -C output/
39 '
40
41 test_expect_success "files look right" '
42 - diff foo/a output/foo/a &&
43 - diff foo/b output/foo/b &&
44 - diff foo/bar/baz output/foo/bar/baz &&
45 - [ -L output/foo/bar/link ] &&
46 - [ -x foo/script ]
42 + diff foo/a output/foo/a &&
43 + diff foo/b output/foo/b &&
44 + diff foo/bar/baz output/foo/bar/baz &&
45 + [ -L output/foo/bar/link ] &&
46 + [ -x foo/script ]
47 '
48
49 test_done
test/sharness/t0220-bitswap.sh
+32 -32
@@ -12,69 +12,69 @@ test_init_ipfs
12 test_launch_ipfs_daemon
13
14 test_expect_success "'ipfs bitswap stat' succeeds" '
15 - ipfs bitswap stat >stat_out
15 + ipfs bitswap stat >stat_out
16 '
17
18 test_expect_success "'ipfs bitswap stat' output looks good" '
19 - cat >expected <<EOF &&
19 + cat <<EOF | sed "s/ /\\t/g" >expected &&
20 bitswap status
21 - provides buffer: 0 / 256
22 - blocks received: 0
23 - blocks sent: 0
24 - data received: 0
25 - data sent: 0
26 - dup blocks received: 0
27 - dup data received: 0 B
28 - wantlist [0 keys]
29 - partners [0]
21 + provides buffer: 0 / 256
22 + blocks received: 0
23 + blocks sent: 0
24 + data received: 0
25 + data sent: 0
26 + dup blocks received: 0
27 + dup data received: 0 B
28 + wantlist [0 keys]
29 + partners [0]
30 EOF
31 - test_cmp expected stat_out
31 + test_cmp expected stat_out
32 '
33
34 test_expect_success "ipfs peer id looks good" '
35 - PEERID=$(ipfs config Identity.PeerID) &&
36 - test_check_peerid "$PEERID"
35 + PEERID=$(ipfs config Identity.PeerID) &&
36 + test_check_peerid "$PEERID"
37 '
38
39 test_expect_success "'ipfs bitswap wantlist -p' works" '
40 - ipfs bitswap wantlist -p "$PEERID" >wantlist_p_out
40 + ipfs bitswap wantlist -p "$PEERID" >wantlist_p_out
41 '
42
43 test_expect_success "'ipfs bitswap wantlist -p' output looks good" '
44 - test_must_be_empty wantlist_p_out
44 + test_must_be_empty wantlist_p_out
45 '
46
47 test_expect_success "hash was removed from wantlist" '
48 - ipfs bitswap wantlist > wantlist_out &&
49 - test_must_be_empty wantlist_out
48 + ipfs bitswap wantlist > wantlist_out &&
49 + test_must_be_empty wantlist_out
50 '
51
52 test_expect_success "'ipfs bitswap stat' succeeds" '
53 - ipfs bitswap stat >stat_out
53 + ipfs bitswap stat >stat_out
54 '
55
56 test_expect_success "'ipfs bitswap stat' output looks good" '
57 - cat >expected <<EOF &&
57 + cat <<EOF | sed "s/ /\\t/g" >expected &&
58 bitswap status
59 - provides buffer: 0 / 256
60 - blocks received: 0
61 - blocks sent: 0
62 - data received: 0
63 - data sent: 0
64 - dup blocks received: 0
65 - dup data received: 0 B
66 - wantlist [0 keys]
67 - partners [0]
59 + provides buffer: 0 / 256
60 + blocks received: 0
61 + blocks sent: 0
62 + data received: 0
63 + data sent: 0
64 + dup blocks received: 0
65 + dup data received: 0 B
66 + wantlist [0 keys]
67 + partners [0]
68 EOF
69 - test_cmp expected stat_out
69 + test_cmp expected stat_out
70 '
71
72 test_expect_success "'ipfs bitswap wantlist -p' works" '
73 - ipfs bitswap wantlist -p "$PEERID" >wantlist_p_out
73 + ipfs bitswap wantlist -p "$PEERID" >wantlist_p_out
74 '
75
76 test_expect_success "'ipfs bitswap wantlist -p' output looks good" '
77 - test_cmp wantlist_out wantlist_p_out
77 + test_cmp wantlist_out wantlist_p_out
78 '
79
80 test_kill_ipfs_daemon
test/sharness/t0230-channel-streaming-http-content-type.sh
+46 -46
@@ -12,55 +12,55 @@ test_init_ipfs
12
13 test_ls_cmd() {
14
15 - test_expect_success "Text encoded channel-streaming command succeeds" '
16 - mkdir -p testdir &&
17 - echo "hello test" >testdir/test.txt &&
18 - ipfs add -r testdir &&
19 - curl -i "http://$API_ADDR/api/v0/refs?arg=QmTcJAn3JP8ZMAKS6WS75q8sbTyojWKbxcUHgLYGWur4Ym&stream-channels=true&encoding=text" >actual_output
20 - '
15 + test_expect_success "Text encoded channel-streaming command succeeds" '
16 + mkdir -p testdir &&
17 + echo "hello test" >testdir/test.txt &&
18 + ipfs add -r testdir &&
19 + curl -i "http://$API_ADDR/api/v0/refs?arg=QmTcJAn3JP8ZMAKS6WS75q8sbTyojWKbxcUHgLYGWur4Ym&stream-channels=true&encoding=text" >actual_output
20 + '
21
22 - test_expect_success "Text encoded channel-streaming command output looks good" '
23 - printf "HTTP/1.1 200 OK\r\n" >expected_output &&
24 - printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output &&
25 - printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output &&
26 - printf "Content-Type: text/plain\r\n" >>expected_output &&
27 - printf "Server: go-ipfs/%s\r\n" $(ipfs version -n) >>expected_output &&
28 - printf "Trailer: X-Stream-Error\r\n" >>expected_output &&
29 - printf "Vary: Origin\r\n" >>expected_output &&
30 - printf "X-Chunked-Output: 1\r\n" >>expected_output &&
31 - printf "Transfer-Encoding: chunked\r\n" >>expected_output &&
32 - printf "\r\n" >>expected_output &&
33 - echo QmRmPLc1FsPAn8F8F9DQDEYADNX5ER2sgqiokEvqnYknVW >>expected_output &&
34 - cat actual_output | grep -vE Date > cleaned_output &&
35 - test_cmp expected_output cleaned_output
36 - '
22 + test_expect_success "Text encoded channel-streaming command output looks good" '
23 + printf "HTTP/1.1 200 OK\r\n" >expected_output &&
24 + printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output &&
25 + printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output &&
26 + printf "Content-Type: text/plain\r\n" >>expected_output &&
27 + printf "Server: go-ipfs/%s\r\n" $(ipfs version -n) >>expected_output &&
28 + printf "Trailer: X-Stream-Error\r\n" >>expected_output &&
29 + printf "Vary: Origin\r\n" >>expected_output &&
30 + printf "X-Chunked-Output: 1\r\n" >>expected_output &&
31 + printf "Transfer-Encoding: chunked\r\n" >>expected_output &&
32 + printf "\r\n" >>expected_output &&
33 + echo QmRmPLc1FsPAn8F8F9DQDEYADNX5ER2sgqiokEvqnYknVW >>expected_output &&
34 + cat actual_output | grep -vE Date > cleaned_output &&
35 + test_cmp expected_output cleaned_output
36 + '
37
38 - test_expect_success "JSON encoded channel-streaming command succeeds" '
39 - mkdir -p testdir &&
40 - echo "hello test" >testdir/test.txt &&
41 - ipfs add -r testdir &&
42 - curl -i "http://$API_ADDR/api/v0/refs?arg=QmTcJAn3JP8ZMAKS6WS75q8sbTyojWKbxcUHgLYGWur4Ym&stream-channels=true&encoding=json" >actual_output
43 - '
38 + test_expect_success "JSON encoded channel-streaming command succeeds" '
39 + mkdir -p testdir &&
40 + echo "hello test" >testdir/test.txt &&
41 + ipfs add -r testdir &&
42 + curl -i "http://$API_ADDR/api/v0/refs?arg=QmTcJAn3JP8ZMAKS6WS75q8sbTyojWKbxcUHgLYGWur4Ym&stream-channels=true&encoding=json" >actual_output
43 + '
44
45 - test_expect_success "JSON encoded channel-streaming command output looks good" '
46 - printf "HTTP/1.1 200 OK\r\n" >expected_output &&
47 - printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output &&
48 - printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output &&
49 - printf "Content-Type: application/json\r\n" >>expected_output &&
50 - printf "Server: go-ipfs/%s\r\n" $(ipfs version -n) >>expected_output &&
51 - printf "Trailer: X-Stream-Error\r\n" >>expected_output &&
52 - printf "Vary: Origin\r\n" >>expected_output &&
53 - printf "X-Chunked-Output: 1\r\n" >>expected_output &&
54 - printf "Transfer-Encoding: chunked\r\n" >>expected_output &&
55 - printf "\r\n" >>expected_output &&
56 - cat <<-\EOF >>expected_output &&
57 - {"Ref":"QmRmPLc1FsPAn8F8F9DQDEYADNX5ER2sgqiokEvqnYknVW","Err":""}
58 - EOF
59 - printf "\n" >> expected_output &&
60 - perl -pi -e '"'"'chomp if eof'"'"' expected_output &&
61 - cat actual_output | grep -vE Date > cleaned_output &&
62 - test_cmp expected_output cleaned_output
63 - '
45 + test_expect_success "JSON encoded channel-streaming command output looks good" '
46 + printf "HTTP/1.1 200 OK\r\n" >expected_output &&
47 + printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output &&
48 + printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length\r\n" >>expected_output &&
49 + printf "Content-Type: application/json\r\n" >>expected_output &&
50 + printf "Server: go-ipfs/%s\r\n" $(ipfs version -n) >>expected_output &&
51 + printf "Trailer: X-Stream-Error\r\n" >>expected_output &&
52 + printf "Vary: Origin\r\n" >>expected_output &&
53 + printf "X-Chunked-Output: 1\r\n" >>expected_output &&
54 + printf "Transfer-Encoding: chunked\r\n" >>expected_output &&
55 + printf "\r\n" >>expected_output &&
56 + cat <<-\EOF >>expected_output &&
57 +{"Ref":"QmRmPLc1FsPAn8F8F9DQDEYADNX5ER2sgqiokEvqnYknVW","Err":""}
58 +EOF
59 + printf "\n" >> expected_output &&
60 + perl -pi -e '"'"'chomp if eof'"'"' expected_output &&
61 + cat actual_output | grep -vE Date > cleaned_output &&
62 + test_cmp expected_output cleaned_output
63 + '
64 }
65
66 # should work online (only)
test/sharness/t0231-channel-streaming.sh
+14 -14
@@ -11,23 +11,23 @@ test_description="Test output of streaming json commands"
11 test_init_ipfs
12
13 get_api_port() {
14 - cat "$IPFS_PATH/api" | awk -F/ '{ print $5 }'
14 + cat "$IPFS_PATH/api" | awk -F/ '{ print $5 }'
15 }
16
17 test_ls_cmd() {
18 - test_expect_success "make a file with multiple refs" '
19 - HASH=$(random 1000000 | ipfs add -q)
20 - '
21 -
22 - test_expect_success "can get refs through curl" '
23 - PORT=$(get_api_port) &&
24 - curl http://localhost:$PORT/api/v0/refs/$HASH > output
25 - '
26 -
27 - # make sure newlines are printed between each object
28 - test_expect_success "output looks good" '
29 - test_expect_code 1 grep "}{" output > /dev/null
30 - '
18 + test_expect_success "make a file with multiple refs" '
19 + HASH=$(random 1000000 | ipfs add -q)
20 + '
21 +
22 + test_expect_success "can get refs through curl" '
23 + PORT=$(get_api_port) &&
24 + curl http://localhost:$PORT/api/v0/refs/$HASH > output
25 + '
26 +
27 + # make sure newlines are printed between each object
28 + test_expect_success "output looks good" '
29 + test_expect_code 1 grep "}{" output > /dev/null
30 + '
31 }
32
33 # should work online (only)
test/sharness/t0235-cli-request.sh
+7 -7
@@ -11,22 +11,22 @@ test_description="test http requests made by cli"
11 test_init_ipfs
12
13 test_expect_success "can make http request against nc server" '
14 - nc -ld 5005 > nc_out &
15 - NCPID=$!
16 - go-sleep 0.5s && kill "$NCPID" &
17 - ipfs cat /ipfs/Qmabcdef --api /ip4/127.0.0.1/tcp/5005 || true
14 + nc -ld 5005 > nc_out &
15 + NCPID=$!
16 + go-sleep 0.5s && kill "$NCPID" &
17 + ipfs cat /ipfs/Qmabcdef --api /ip4/127.0.0.1/tcp/5005 || true
18 '
19
20 test_expect_success "output does not contain multipart info" '
21 - test_expect_code 1 grep multipart nc_out
21 + test_expect_code 1 grep multipart nc_out
22 '
23
24 test_expect_success "request looks good" '
25 - grep "POST /api/v0/cat" nc_out
25 + grep "POST /api/v0/cat" nc_out
26 '
27
28 test_expect_success "api flag does not appear in request" '
29 - test_expect_code 1 grep "api=/ip4" nc_out
29 + test_expect_code 1 grep "api=/ip4" nc_out
30 '
31
32 test_done
test/sharness/t0240-republisher.sh
+54 -54
@@ -11,64 +11,64 @@ test_description="Test ipfs repo operations"
11 export DEBUG=true
12
13 setup_iptb() {
14 - num_nodes="$1"
15 - bound=$(expr "$num_nodes" - 1)
16 -
17 - test_expect_success "iptb init" '
18 - iptb init -n $num_nodes --bootstrap none --port 0
19 - '
20 -
21 - for i in $(test_seq 0 "$bound")
22 - do
23 - test_expect_success "set configs up for node $i" '
24 - ipfsi "$i" config Ipns.RepublishPeriod 20s &&
25 - ipfsi "$i" config --json Ipns.ResolveCacheSize 0
26 - '
27 - done
28 -
29 - startup_cluster "$num_nodes"
14 + num_nodes="$1"
15 + bound=$(expr "$num_nodes" - 1)
16 +
17 + test_expect_success "iptb init" '
18 + iptb init -n $num_nodes --bootstrap none --port 0
19 + '
20 +
21 + for i in $(test_seq 0 "$bound")
22 + do
23 + test_expect_success "set configs up for node $i" '
24 + ipfsi "$i" config Ipns.RepublishPeriod 20s &&
25 + ipfsi "$i" config --json Ipns.ResolveCacheSize 0
26 + '
27 + done
28 +
29 + startup_cluster "$num_nodes"
30 }
31
32 teardown_iptb() {
33 - test_expect_success "shut down nodes" '
34 - iptb kill
35 - '
33 + test_expect_success "shut down nodes" '
34 + iptb kill
35 + '
36 }
37
38 verify_can_resolve() {
39 - num_nodes="$1"
40 - bound=$(expr "$num_nodes" - 1)
41 - name="$2"
42 - expected="$3"
43 - msg="$4"
44 -
45 - for node in $(test_seq 0 "$bound")
46 - do
47 - test_expect_success "$msg: node $node can resolve entry" '
48 - ipfsi "$node" name resolve "$name" > resolve
49 - '
50 -
51 - test_expect_success "$msg: output for node $node looks right" '
52 - printf "/ipfs/$expected\n" > expected &&
53 - test_cmp expected resolve
54 - '
55 - done
39 + num_nodes="$1"
40 + bound=$(expr "$num_nodes" - 1)
41 + name="$2"
42 + expected="$3"
43 + msg="$4"
44 +
45 + for node in $(test_seq 0 "$bound")
46 + do
47 + test_expect_success "$msg: node $node can resolve entry" '
48 + ipfsi "$node" name resolve "$name" > resolve
49 + '
50 +
51 + test_expect_success "$msg: output for node $node looks right" '
52 + printf "/ipfs/$expected\n" > expected &&
53 + test_cmp expected resolve
54 + '
55 + done
56 }
57
58 verify_cannot_resolve() {
59 - num_nodes="$1"
60 - bound=$(expr "$num_nodes" - 1)
61 - name="$2"
62 - msg="$3"
63 -
64 - for node in $(test_seq 0 "$bound")
65 - do
66 - test_expect_success "$msg: resolution fails on node $node" '
67 - # TODO: this should work without the timeout option
68 - # but it currently hangs for some reason every so often
69 - test_expect_code 1 ipfsi "$node" name resolve --timeout=300ms "$name"
70 - '
71 - done
59 + num_nodes="$1"
60 + bound=$(expr "$num_nodes" - 1)
61 + name="$2"
62 + msg="$3"
63 +
64 + for node in $(test_seq 0 "$bound")
65 + do
66 + test_expect_success "$msg: resolution fails on node $node" '
67 + # TODO: this should work without the timeout option
68 + # but it currently hangs for some reason every so often
69 + test_expect_code 1 ipfsi "$node" name resolve --timeout=300ms "$name"
70 + '
71 + done
72 }
73
74 num_test_nodes=4
@@ -76,12 +76,12 @@ num_test_nodes=4
76 setup_iptb "$num_test_nodes"
77
78 test_expect_success "publish succeeds" '
79 - HASH=$(echo "foobar" | ipfsi 1 add -q) &&
80 - ipfsi 1 name publish -t 5s $HASH
79 + HASH=$(echo "foobar" | ipfsi 1 add -q) &&
80 + ipfsi 1 name publish -t 5s $HASH
81 '
82
83 test_expect_success "get id succeeds" '
84 - id=$(ipfsi 1 id -f "<id>")
84 + id=$(ipfsi 1 id -f "<id>")
85 '
86
87 verify_can_resolve "$num_test_nodes" "$id" "$HASH" "just after publishing"
@@ -101,8 +101,8 @@ KEY2=`ipfsi 1 key gen beepboop --type ed25519`
101 '
102
103 test_expect_success "publish with new key succeeds" '
104 - HASH=$(echo "barfoo" | ipfsi 1 add -q) &&
105 - ipfsi 1 name publish -t 5s -k "$KEY2" $HASH
104 + HASH=$(echo "barfoo" | ipfsi 1 add -q) &&
105 + ipfsi 1 name publish -t 5s -k "$KEY2" $HASH
106 '
107
108 verify_can_resolve "$num_test_nodes" "$KEY2" "$HASH" "new key just after publishing"
test/sharness/t0250-files-api.sh
+518 -518
@@ -11,541 +11,541 @@ test_description="test the unix files api"
11 test_init_ipfs
12
13 create_files() {
14 - FILE1=$(echo foo | ipfs add "$@" -q) &&
15 - FILE2=$(echo bar | ipfs add "$@" -q) &&
16 - FILE3=$(echo baz | ipfs add "$@" -q) &&
17 - mkdir -p stuff_test &&
18 - echo cats > stuff_test/a &&
19 - echo dogs > stuff_test/b &&
20 - echo giraffes > stuff_test/c &&
21 - DIR1=$(ipfs add -r "$@" -q stuff_test | tail -n1)
14 + FILE1=$(echo foo | ipfs add "$@" -q) &&
15 + FILE2=$(echo bar | ipfs add "$@" -q) &&
16 + FILE3=$(echo baz | ipfs add "$@" -q) &&
17 + mkdir -p stuff_test &&
18 + echo cats > stuff_test/a &&
19 + echo dogs > stuff_test/b &&
20 + echo giraffes > stuff_test/c &&
21 + DIR1=$(ipfs add -r "$@" -q stuff_test | tail -n1)
22 }
23
24 verify_path_exists() {
25 - # simply running ls on a file should be a good 'check'
26 - ipfs files ls $1
25 + # simply running ls on a file should be a good 'check'
26 + ipfs files ls $1
27 }
28
29 verify_dir_contents() {
30 - dir=$1
31 - shift
32 - rm -f expected
33 - touch expected
34 - for e in $@
35 - do
36 - echo $e >> expected
37 - done
38 -
39 - test_expect_success "can list dir" '
40 - ipfs files ls $dir > output
41 - '
42 -
43 - test_expect_success "dir entries look good" '
44 - test_sort_cmp output expected
45 - '
30 + dir=$1
31 + shift
32 + rm -f expected
33 + touch expected
34 + for e in $@
35 + do
36 + echo $e >> expected
37 + done
38 +
39 + test_expect_success "can list dir" '
40 + ipfs files ls $dir > output
41 + '
42 +
43 + test_expect_success "dir entries look good" '
44 + test_sort_cmp output expected
45 + '
46 }
47
48 test_sharding() {
49 - test_expect_success "make a directory" '
50 - ipfs files mkdir /foo
51 - '
52 -
53 - test_expect_success "can make 100 files in a directory" '
54 - printf "" > list_exp_raw
55 - for i in `seq 100`
56 - do
57 - echo $i | ipfs files write --create /foo/file$i
58 - echo file$i >> list_exp_raw
59 - done
60 - '
61 -
62 - test_expect_success "listing works" '
63 - ipfs files ls /foo |sort > list_out &&
64 - sort list_exp_raw > list_exp &&
65 - test_cmp list_exp list_out
66 - '
67 -
68 - test_expect_success "can read a file from sharded directory" '
69 - ipfs files read /foo/file65 > file_out &&
70 - echo "65" > file_exp &&
71 - test_cmp file_out file_exp
72 - '
73 -
74 - test_expect_success "can pin a file from sharded directory" '
75 - ipfs files stat --hash /foo/file42 > pin_file_hash &&
76 - ipfs pin add < pin_file_hash > pin_hash
77 - '
78 -
79 - test_expect_success "can unpin a file from sharded directory" '
80 - read -r _ HASH _ < pin_hash &&
81 - ipfs pin rm $HASH
82 - '
83 -
84 - test_expect_success "output object was really sharded" '
85 - ipfs files stat --hash /foo > expected_foo_hash &&
86 - echo QmPkwLJTYZRGPJ8Lazr9qPdrLmswPtUjaDbEpmR9jEh1se > actual_foo_hash &&
87 - test_cmp expected_foo_hash actual_foo_hash
88 - '
49 + test_expect_success "make a directory" '
50 + ipfs files mkdir /foo
51 + '
52 +
53 + test_expect_success "can make 100 files in a directory" '
54 + printf "" > list_exp_raw
55 + for i in `seq 100`
56 + do
57 + echo $i | ipfs files write --create /foo/file$i
58 + echo file$i >> list_exp_raw
59 + done
60 + '
61 +
62 + test_expect_success "listing works" '
63 + ipfs files ls /foo |sort > list_out &&
64 + sort list_exp_raw > list_exp &&
65 + test_cmp list_exp list_out
66 + '
67 +
68 + test_expect_success "can read a file from sharded directory" '
69 + ipfs files read /foo/file65 > file_out &&
70 + echo "65" > file_exp &&
71 + test_cmp file_out file_exp
72 + '
73 +
74 + test_expect_success "can pin a file from sharded directory" '
75 + ipfs files stat --hash /foo/file42 > pin_file_hash &&
76 + ipfs pin add < pin_file_hash > pin_hash
77 + '
78 +
79 + test_expect_success "can unpin a file from sharded directory" '
80 + read -r _ HASH _ < pin_hash &&
81 + ipfs pin rm $HASH
82 + '
83 +
84 + test_expect_success "output object was really sharded" '
85 + ipfs files stat --hash /foo > expected_foo_hash &&
86 + echo QmPkwLJTYZRGPJ8Lazr9qPdrLmswPtUjaDbEpmR9jEh1se > actual_foo_hash &&
87 + test_cmp expected_foo_hash actual_foo_hash
88 + '
89 }
90
91 test_files_api() {
92 - ROOT_HASH=$1
93 -
94 - test_expect_success "can mkdir in root" '
95 - ipfs files mkdir /cats
96 - '
97 -
98 - test_expect_success "'files ls' lists root by default" '
99 - ipfs files ls >actual &&
100 - echo "cats" >expected &&
101 - test_cmp expected actual
102 - '
103 -
104 - test_expect_success "directory was created" '
105 - verify_path_exists /cats
106 - '
107 -
108 - test_expect_success "directory is empty" '
109 - verify_dir_contents /cats
110 - '
111 - # we do verification of stat formatting now as we depend on it
112 -
113 - test_expect_success "stat works" '
114 - ipfs files stat / >stat
115 - '
116 -
117 - test_expect_success "hash is first line of stat" '
118 - ipfs ls $(head -1 stat) | grep "cats"
119 - '
120 -
121 - test_expect_success "stat --hash gives only hash" '
122 - ipfs files stat --hash / >actual &&
123 - head -n1 stat >expected &&
124 - test_cmp expected actual
125 - '
126 -
127 - test_expect_success "stat with multiple format options should fail" '
128 - test_must_fail ipfs files stat --hash --size /
129 - '
130 -
131 - test_expect_success "compare hash option with format" '
132 - ipfs files stat --hash / >expected &&
133 - ipfs files stat --format='"'"'<hash>'"'"' / >actual &&
134 - test_cmp expected actual
135 - '
136 - test_expect_success "compare size option with format" '
137 - ipfs files stat --size / >expected &&
138 - ipfs files stat --format='"'"'<cumulsize>'"'"' / >actual &&
139 - test_cmp expected actual
140 - '
141 -
142 - test_expect_success "check root hash" '
143 - ipfs files stat --hash / > roothash
144 - '
145 -
146 - test_expect_success "cannot mkdir /" '
147 - test_expect_code 1 ipfs files mkdir /
148 - '
149 -
150 - test_expect_success "check root hash was not changed" '
151 - ipfs files stat --hash / > roothashafter &&
152 - test_cmp roothash roothashafter
153 - '
154 -
155 - test_expect_success "can put files into directory" '
156 - ipfs files cp /ipfs/$FILE1 /cats/file1
157 - '
158 -
159 - test_expect_success "file shows up in directory" '
160 - verify_dir_contents /cats file1
161 - '
162 -
163 - test_expect_success "file has correct hash and size in directory" '
164 - echo "file1 $FILE1 4" > ls_l_expected &&
165 - ipfs files ls -l /cats > ls_l_actual &&
166 - test_cmp ls_l_expected ls_l_actual
167 - '
168 -
169 - test_expect_success "can read file" '
170 - ipfs files read /cats/file1 > file1out
171 - '
172 -
173 - test_expect_success "output looks good" '
174 - echo foo > expected &&
175 - test_cmp expected file1out
176 - '
177 -
178 - test_expect_success "can put another file into root" '
179 - ipfs files cp /ipfs/$FILE2 /file2
180 - '
181 -
182 - test_expect_success "file shows up in root" '
183 - verify_dir_contents / file2 cats
184 - '
185 -
186 - test_expect_success "can read file" '
187 - ipfs files read /file2 > file2out
188 - '
189 -
190 - test_expect_success "output looks good" '
191 - echo bar > expected &&
192 - test_cmp expected file2out
193 - '
194 -
195 - test_expect_success "can make deep directory" '
196 - ipfs files mkdir -p /cats/this/is/a/dir
197 - '
198 -
199 - test_expect_success "directory was created correctly" '
200 - verify_path_exists /cats/this/is/a/dir &&
201 - verify_dir_contents /cats this file1 &&
202 - verify_dir_contents /cats/this is &&
203 - verify_dir_contents /cats/this/is a &&
204 - verify_dir_contents /cats/this/is/a dir &&
205 - verify_dir_contents /cats/this/is/a/dir
206 - '
207 -
208 - test_expect_success "can copy file into new dir" '
209 - ipfs files cp /ipfs/$FILE3 /cats/this/is/a/dir/file3
210 - '
211 -
212 - test_expect_success "can read file" '
213 - ipfs files read /cats/this/is/a/dir/file3 > output
214 - '
215 -
216 - test_expect_success "output looks good" '
217 - echo baz > expected &&
218 - test_cmp expected output
219 - '
220 -
221 - test_expect_success "file shows up in dir" '
222 - verify_dir_contents /cats/this/is/a/dir file3
223 - '
224 -
225 - test_expect_success "can remove file" '
226 - ipfs files rm /cats/this/is/a/dir/file3
227 - '
228 -
229 - test_expect_success "file no longer appears" '
230 - verify_dir_contents /cats/this/is/a/dir
231 - '
232 -
233 - test_expect_success "can remove dir" '
234 - ipfs files rm -r /cats/this/is/a/dir
235 - '
236 -
237 - test_expect_success "dir no longer appears" '
238 - verify_dir_contents /cats/this/is/a
239 - '
240 -
241 - test_expect_success "can remove file from root" '
242 - ipfs files rm /file2
243 - '
244 -
245 - test_expect_success "file no longer appears" '
246 - verify_dir_contents / cats
247 - '
248 -
249 - test_expect_success "check root hash" '
250 - ipfs files stat --hash / > roothash
251 - '
252 -
253 - test_expect_success "cannot remove root" '
254 - test_expect_code 1 ipfs files rm -r /
255 - '
256 -
257 - test_expect_success "check root hash was not changed" '
258 - ipfs files stat --hash / > roothashafter &&
259 - test_cmp roothash roothashafter
260 - '
261 -
262 - # test read options
263 -
264 - test_expect_success "read from offset works" '
265 - ipfs files read -o 1 /cats/file1 > output
266 - '
267 -
268 - test_expect_success "output looks good" '
269 - echo oo > expected &&
270 - test_cmp expected output
271 - '
272 -
273 - test_expect_success "read with size works" '
274 - ipfs files read -n 2 /cats/file1 > output
275 - '
276 -
277 - test_expect_success "output looks good" '
278 - printf fo > expected &&
279 - test_cmp expected output
280 - '
281 -
282 - test_expect_success "cannot read from negative offset" '
283 - test_expect_code 1 ipfs files read --offset -3 /cats/file1
284 - '
285 -
286 - test_expect_success "read from offset 0 works" '
287 - ipfs files read --offset 0 /cats/file1 > output
288 - '
289 -
290 - test_expect_success "output looks good" '
291 - echo foo > expected &&
292 - test_cmp expected output
293 - '
294 -
295 - test_expect_success "read last byte works" '
296 - ipfs files read --offset 2 /cats/file1 > output
297 - '
298 -
299 - test_expect_success "output looks good" '
300 - echo o > expected &&
301 - test_cmp expected output
302 - '
303 -
304 - test_expect_success "offset past end of file fails" '
305 - test_expect_code 1 ipfs files read --offset 5 /cats/file1
306 - '
307 -
308 - test_expect_success "cannot read negative count bytes" '
309 - test_expect_code 1 ipfs read --count -1 /cats/file1
310 - '
311 -
312 - test_expect_success "reading zero bytes prints nothing" '
313 - ipfs files read --count 0 /cats/file1 > output
314 - '
315 -
316 - test_expect_success "output looks good" '
317 - printf "" > expected &&
318 - test_cmp expected output
319 - '
320 -
321 - test_expect_success "count > len(file) prints entire file" '
322 - ipfs files read --count 200 /cats/file1 > output
323 - '
324 -
325 - test_expect_success "output looks good" '
326 - echo foo > expected &&
327 - test_cmp expected output
328 - '
329 -
330 - # test write
331 -
332 - test_expect_success "can write file" '
333 - echo "ipfs rocks" > tmpfile &&
334 - cat tmpfile | ipfs files write --create /cats/ipfs
335 - '
336 -
337 - test_expect_success "file was created" '
338 - verify_dir_contents /cats ipfs file1 this
339 - '
340 -
341 - test_expect_success "can read file we just wrote" '
342 - ipfs files read /cats/ipfs > output
343 - '
344 -
345 - test_expect_success "can write to offset" '
346 - echo "is super cool" | ipfs files write -o 5 /cats/ipfs
347 - '
348 -
349 - test_expect_success "file looks correct" '
350 - echo "ipfs is super cool" > expected &&
351 - ipfs files read /cats/ipfs > output &&
352 - test_cmp expected output
353 - '
354 -
355 - test_expect_success "cant write to negative offset" '
356 - ipfs files stat --hash /cats/ipfs > filehash &&
357 - test_expect_code 1 ipfs files write --offset -1 /cats/ipfs < output
358 - '
359 -
360 - test_expect_success "verify file was not changed" '
361 - ipfs files stat --hash /cats/ipfs > afterhash &&
362 - test_cmp filehash afterhash
363 - '
364 -
365 - test_expect_success "write new file for testing" '
366 - echo foobar | ipfs files write --create /fun
367 - '
368 -
369 - test_expect_success "write to offset past end works" '
370 - echo blah | ipfs files write --offset 50 /fun
371 - '
372 -
373 - test_expect_success "can read file" '
374 - ipfs files read /fun > sparse_output
375 - '
376 -
377 - test_expect_success "output looks good" '
378 - echo foobar > sparse_expected &&
379 - echo blah | dd of=sparse_expected bs=50 seek=1 &&
380 - test_cmp sparse_expected sparse_output
381 - '
382 -
383 - test_expect_success "cleanup" '
384 - ipfs files rm /fun
385 - '
386 -
387 - test_expect_success "cannot write to directory" '
388 - ipfs files stat --hash /cats > dirhash &&
389 - test_expect_code 1 ipfs files write /cats < output
390 - '
391 -
392 - test_expect_success "verify dir was not changed" '
393 - ipfs files stat --hash /cats > afterdirhash &&
394 - test_cmp dirhash afterdirhash
395 - '
396 -
397 - test_expect_success "cannot write to nonexistant path" '
398 - test_expect_code 1 ipfs files write /cats/bar/ < output
399 - '
400 -
401 - test_expect_success "no new paths were created" '
402 - verify_dir_contents /cats file1 ipfs this
403 - '
404 -
405 - test_expect_success "write 'no-flush' succeeds" '
406 - echo "testing" | ipfs files write -f=false -e /cats/walrus
407 - '
408 -
409 - test_expect_success "root hash not bubbled up yet" '
410 - test -z "$ONLINE" ||
411 - (ipfs refs local > refsout &&
412 - test_expect_code 1 grep $ROOT_HASH refsout)
413 - '
414 -
415 - test_expect_success "changes bubbled up to root on inspection" '
416 - ipfs files stat --hash / > root_hash
417 - '
418 -
419 - test_expect_success "root hash looks good" '
420 - export EXP_ROOT_HASH="$ROOT_HASH" &&
421 - echo $EXP_ROOT_HASH > root_hash_exp &&
422 - test_cmp root_hash_exp root_hash
423 - '
424 -
425 - test_expect_success "flush root succeeds" '
426 - ipfs files flush /
427 - '
428 -
429 - # test mv
430 - test_expect_success "can mv dir" '
431 - ipfs files mv /cats/this/is /cats/
432 - '
433 -
434 - test_expect_success "mv worked" '
435 - verify_dir_contents /cats file1 ipfs this is walrus &&
436 - verify_dir_contents /cats/this
437 - '
438 -
439 - test_expect_success "cleanup, remove 'cats'" '
440 - ipfs files rm -r /cats
441 - '
442 -
443 - test_expect_success "cleanup looks good" '
444 - verify_dir_contents /
445 - '
446 -
447 - # test truncating
448 - test_expect_success "create a new file" '
449 - echo "some content" | ipfs files write --create /cats
450 - '
451 -
452 - test_expect_success "truncate and write over that file" '
453 - echo "fish" | ipfs files write --truncate /cats
454 - '
455 -
456 - test_expect_success "output looks good" '
457 - ipfs files read /cats > file_out &&
458 - echo "fish" > file_exp &&
459 - test_cmp file_out file_exp
460 - '
461 -
462 - test_expect_success "cleanup" '
463 - ipfs files rm /cats
464 - '
465 -
466 - # test flush flags
467 - test_expect_success "mkdir --flush works" '
468 - ipfs files mkdir --flush --parents /flushed/deep
469 - '
470 -
471 - test_expect_success "mkdir --flush works a second time" '
472 - ipfs files mkdir --flush --parents /flushed/deep
473 - '
474 -
475 - test_expect_success "dir looks right" '
476 - verify_dir_contents / flushed
477 - '
478 -
479 - test_expect_success "child dir looks right" '
480 - verify_dir_contents /flushed deep
481 - '
482 -
483 - test_expect_success "cleanup" '
484 - ipfs files rm -r /flushed
485 - '
486 -
487 - test_expect_success "child dir looks right" '
488 - verify_dir_contents /
489 - '
490 -
491 - # test for https://github.com/ipfs/go-ipfs/issues/2654
492 - test_expect_success "create and remove dir" '
493 - ipfs files mkdir /test_dir &&
494 - ipfs files rm -r "/test_dir"
495 - '
496 -
497 - test_expect_success "create test file" '
498 - echo "content" | ipfs files write -e "/test_file"
499 - '
500 -
501 - test_expect_success "copy test file onto test dir" '
502 - ipfs files cp "/test_file" "/test_dir"
503 - '
504 -
505 - test_expect_success "test /test_dir" '
506 - ipfs files stat "/test_dir" | grep -q "^Type: file"
507 - '
508 -
509 - test_expect_success "clean up /test_dir and /test_file" '
510 - ipfs files rm -r /test_dir &&
511 - ipfs files rm -r /test_file
512 - '
513 -
514 - test_expect_success "make a directory and a file" '
515 - ipfs files mkdir /adir &&
516 - echo "blah" | ipfs files write --create /foobar
517 - '
518 -
519 - test_expect_success "copy a file into a directory" '
520 - ipfs files cp /foobar /adir/
521 - '
522 -
523 - test_expect_success "file made it into directory" '
524 - ipfs files ls /adir | grep foobar
525 - '
526 -
527 - test_expect_success "clean up" '
528 - ipfs files rm -r /foobar &&
529 - ipfs files rm -r /adir
530 - '
531 -
532 - test_expect_success "root mfs entry is empty" '
533 - verify_dir_contents /
534 - '
535 -
536 - test_expect_success "repo gc" '
537 - ipfs repo gc
538 - '
92 + ROOT_HASH=$1
93 +
94 + test_expect_success "can mkdir in root" '
95 + ipfs files mkdir /cats
96 + '
97 +
98 + test_expect_success "'files ls' lists root by default" '
99 + ipfs files ls >actual &&
100 + echo "cats" >expected &&
101 + test_cmp expected actual
102 + '
103 +
104 + test_expect_success "directory was created" '
105 + verify_path_exists /cats
106 + '
107 +
108 + test_expect_success "directory is empty" '
109 + verify_dir_contents /cats
110 + '
111 + # we do verification of stat formatting now as we depend on it
112 +
113 + test_expect_success "stat works" '
114 + ipfs files stat / >stat
115 + '
116 +
117 + test_expect_success "hash is first line of stat" '
118 + ipfs ls $(head -1 stat) | grep "cats"
119 + '
120 +
121 + test_expect_success "stat --hash gives only hash" '
122 + ipfs files stat --hash / >actual &&
123 + head -n1 stat >expected &&
124 + test_cmp expected actual
125 + '
126 +
127 + test_expect_success "stat with multiple format options should fail" '
128 + test_must_fail ipfs files stat --hash --size /
129 + '
130 +
131 + test_expect_success "compare hash option with format" '
132 + ipfs files stat --hash / >expected &&
133 + ipfs files stat --format='"'"'<hash>'"'"' / >actual &&
134 + test_cmp expected actual
135 + '
136 + test_expect_success "compare size option with format" '
137 + ipfs files stat --size / >expected &&
138 + ipfs files stat --format='"'"'<cumulsize>'"'"' / >actual &&
139 + test_cmp expected actual
140 + '
141 +
142 + test_expect_success "check root hash" '
143 + ipfs files stat --hash / > roothash
144 + '
145 +
146 + test_expect_success "cannot mkdir /" '
147 + test_expect_code 1 ipfs files mkdir /
148 + '
149 +
150 + test_expect_success "check root hash was not changed" '
151 + ipfs files stat --hash / > roothashafter &&
152 + test_cmp roothash roothashafter
153 + '
154 +
155 + test_expect_success "can put files into directory" '
156 + ipfs files cp /ipfs/$FILE1 /cats/file1
157 + '
158 +
159 + test_expect_success "file shows up in directory" '
160 + verify_dir_contents /cats file1
161 + '
162 +
163 + test_expect_success "file has correct hash and size in directory" '
164 + echo "file1 $FILE1 4" > ls_l_expected &&
165 + ipfs files ls -l /cats > ls_l_actual &&
166 + test_cmp ls_l_expected ls_l_actual
167 + '
168 +
169 + test_expect_success "can read file" '
170 + ipfs files read /cats/file1 > file1out
171 + '
172 +
173 + test_expect_success "output looks good" '
174 + echo foo > expected &&
175 + test_cmp expected file1out
176 + '
177 +
178 + test_expect_success "can put another file into root" '
179 + ipfs files cp /ipfs/$FILE2 /file2
180 + '
181 +
182 + test_expect_success "file shows up in root" '
183 + verify_dir_contents / file2 cats
184 + '
185 +
186 + test_expect_success "can read file" '
187 + ipfs files read /file2 > file2out
188 + '
189 +
190 + test_expect_success "output looks good" '
191 + echo bar > expected &&
192 + test_cmp expected file2out
193 + '
194 +
195 + test_expect_success "can make deep directory" '
196 + ipfs files mkdir -p /cats/this/is/a/dir
197 + '
198 +
199 + test_expect_success "directory was created correctly" '
200 + verify_path_exists /cats/this/is/a/dir &&
201 + verify_dir_contents /cats this file1 &&
202 + verify_dir_contents /cats/this is &&
203 + verify_dir_contents /cats/this/is a &&
204 + verify_dir_contents /cats/this/is/a dir &&
205 + verify_dir_contents /cats/this/is/a/dir
206 + '
207 +
208 + test_expect_success "can copy file into new dir" '
209 + ipfs files cp /ipfs/$FILE3 /cats/this/is/a/dir/file3
210 + '
211 +
212 + test_expect_success "can read file" '
213 + ipfs files read /cats/this/is/a/dir/file3 > output
214 + '
215 +
216 + test_expect_success "output looks good" '
217 + echo baz > expected &&
218 + test_cmp expected output
219 + '
220 +
221 + test_expect_success "file shows up in dir" '
222 + verify_dir_contents /cats/this/is/a/dir file3
223 + '
224 +
225 + test_expect_success "can remove file" '
226 + ipfs files rm /cats/this/is/a/dir/file3
227 + '
228 +
229 + test_expect_success "file no longer appears" '
230 + verify_dir_contents /cats/this/is/a/dir
231 + '
232 +
233 + test_expect_success "can remove dir" '
234 + ipfs files rm -r /cats/this/is/a/dir
235 + '
236 +
237 + test_expect_success "dir no longer appears" '
238 + verify_dir_contents /cats/this/is/a
239 + '
240 +
241 + test_expect_success "can remove file from root" '
242 + ipfs files rm /file2
243 + '
244 +
245 + test_expect_success "file no longer appears" '
246 + verify_dir_contents / cats
247 + '
248 +
249 + test_expect_success "check root hash" '
250 + ipfs files stat --hash / > roothash
251 + '
252 +
253 + test_expect_success "cannot remove root" '
254 + test_expect_code 1 ipfs files rm -r /
255 + '
256 +
257 + test_expect_success "check root hash was not changed" '
258 + ipfs files stat --hash / > roothashafter &&
259 + test_cmp roothash roothashafter
260 + '
261 +
262 + # test read options
263 +
264 + test_expect_success "read from offset works" '
265 + ipfs files read -o 1 /cats/file1 > output
266 + '
267 +
268 + test_expect_success "output looks good" '
269 + echo oo > expected &&
270 + test_cmp expected output
271 + '
272 +
273 + test_expect_success "read with size works" '
274 + ipfs files read -n 2 /cats/file1 > output
275 + '
276 +
277 + test_expect_success "output looks good" '
278 + printf fo > expected &&
279 + test_cmp expected output
280 + '
281 +
282 + test_expect_success "cannot read from negative offset" '
283 + test_expect_code 1 ipfs files read --offset -3 /cats/file1
284 + '
285 +
286 + test_expect_success "read from offset 0 works" '
287 + ipfs files read --offset 0 /cats/file1 > output
288 + '
289 +
290 + test_expect_success "output looks good" '
291 + echo foo > expected &&
292 + test_cmp expected output
293 + '
294 +
295 + test_expect_success "read last byte works" '
296 + ipfs files read --offset 2 /cats/file1 > output
297 + '
298 +
299 + test_expect_success "output looks good" '
300 + echo o > expected &&
301 + test_cmp expected output
302 + '
303 +
304 + test_expect_success "offset past end of file fails" '
305 + test_expect_code 1 ipfs files read --offset 5 /cats/file1
306 + '
307 +
308 + test_expect_success "cannot read negative count bytes" '
309 + test_expect_code 1 ipfs read --count -1 /cats/file1
310 + '
311 +
312 + test_expect_success "reading zero bytes prints nothing" '
313 + ipfs files read --count 0 /cats/file1 > output
314 + '
315 +
316 + test_expect_success "output looks good" '
317 + printf "" > expected &&
318 + test_cmp expected output
319 + '
320 +
321 + test_expect_success "count > len(file) prints entire file" '
322 + ipfs files read --count 200 /cats/file1 > output
323 + '
324 +
325 + test_expect_success "output looks good" '
326 + echo foo > expected &&
327 + test_cmp expected output
328 + '
329 +
330 + # test write
331 +
332 + test_expect_success "can write file" '
333 + echo "ipfs rocks" > tmpfile &&
334 + cat tmpfile | ipfs files write --create /cats/ipfs
335 + '
336 +
337 + test_expect_success "file was created" '
338 + verify_dir_contents /cats ipfs file1 this
339 + '
340 +
341 + test_expect_success "can read file we just wrote" '
342 + ipfs files read /cats/ipfs > output
343 + '
344 +
345 + test_expect_success "can write to offset" '
346 + echo "is super cool" | ipfs files write -o 5 /cats/ipfs
347 + '
348 +
349 + test_expect_success "file looks correct" '
350 + echo "ipfs is super cool" > expected &&
351 + ipfs files read /cats/ipfs > output &&
352 + test_cmp expected output
353 + '
354 +
355 + test_expect_success "cant write to negative offset" '
356 + ipfs files stat --hash /cats/ipfs > filehash &&
357 + test_expect_code 1 ipfs files write --offset -1 /cats/ipfs < output
358 + '
359 +
360 + test_expect_success "verify file was not changed" '
361 + ipfs files stat --hash /cats/ipfs > afterhash &&
362 + test_cmp filehash afterhash
363 + '
364 +
365 + test_expect_success "write new file for testing" '
366 + echo foobar | ipfs files write --create /fun
367 + '
368 +
369 + test_expect_success "write to offset past end works" '
370 + echo blah | ipfs files write --offset 50 /fun
371 + '
372 +
373 + test_expect_success "can read file" '
374 + ipfs files read /fun > sparse_output
375 + '
376 +
377 + test_expect_success "output looks good" '
378 + echo foobar > sparse_expected &&
379 + echo blah | dd of=sparse_expected bs=50 seek=1 &&
380 + test_cmp sparse_expected sparse_output
381 + '
382 +
383 + test_expect_success "cleanup" '
384 + ipfs files rm /fun
385 + '
386 +
387 + test_expect_success "cannot write to directory" '
388 + ipfs files stat --hash /cats > dirhash &&
389 + test_expect_code 1 ipfs files write /cats < output
390 + '
391 +
392 + test_expect_success "verify dir was not changed" '
393 + ipfs files stat --hash /cats > afterdirhash &&
394 + test_cmp dirhash afterdirhash
395 + '
396 +
397 + test_expect_success "cannot write to nonexistant path" '
398 + test_expect_code 1 ipfs files write /cats/bar/ < output
399 + '
400 +
401 + test_expect_success "no new paths were created" '
402 + verify_dir_contents /cats file1 ipfs this
403 + '
404 +
405 + test_expect_success "write 'no-flush' succeeds" '
406 + echo "testing" | ipfs files write -f=false -e /cats/walrus
407 + '
408 +
409 + test_expect_success "root hash not bubbled up yet" '
410 + test -z "$ONLINE" ||
411 + (ipfs refs local > refsout &&
412 + test_expect_code 1 grep $ROOT_HASH refsout)
413 + '
414 +
415 + test_expect_success "changes bubbled up to root on inspection" '
416 + ipfs files stat --hash / > root_hash
417 + '
418 +
419 + test_expect_success "root hash looks good" '
420 + export EXP_ROOT_HASH="$ROOT_HASH" &&
421 + echo $EXP_ROOT_HASH > root_hash_exp &&
422 + test_cmp root_hash_exp root_hash
423 + '
424 +
425 + test_expect_success "flush root succeeds" '
426 + ipfs files flush /
427 + '
428 +
429 + # test mv
430 + test_expect_success "can mv dir" '
431 + ipfs files mv /cats/this/is /cats/
432 + '
433 +
434 + test_expect_success "mv worked" '
435 + verify_dir_contents /cats file1 ipfs this is walrus &&
436 + verify_dir_contents /cats/this
437 + '
438 +
439 + test_expect_success "cleanup, remove 'cats'" '
440 + ipfs files rm -r /cats
441 + '
442 +
443 + test_expect_success "cleanup looks good" '
444 + verify_dir_contents /
445 + '
446 +
447 + # test truncating
448 + test_expect_success "create a new file" '
449 + echo "some content" | ipfs files write --create /cats
450 + '
451 +
452 + test_expect_success "truncate and write over that file" '
453 + echo "fish" | ipfs files write --truncate /cats
454 + '
455 +
456 + test_expect_success "output looks good" '
457 + ipfs files read /cats > file_out &&
458 + echo "fish" > file_exp &&
459 + test_cmp file_out file_exp
460 + '
461 +
462 + test_expect_success "cleanup" '
463 + ipfs files rm /cats
464 + '
465 +
466 + # test flush flags
467 + test_expect_success "mkdir --flush works" '
468 + ipfs files mkdir --flush --parents /flushed/deep
469 + '
470 +
471 + test_expect_success "mkdir --flush works a second time" '
472 + ipfs files mkdir --flush --parents /flushed/deep
473 + '
474 +
475 + test_expect_success "dir looks right" '
476 + verify_dir_contents / flushed
477 + '
478 +
479 + test_expect_success "child dir looks right" '
480 + verify_dir_contents /flushed deep
481 + '
482 +
483 + test_expect_success "cleanup" '
484 + ipfs files rm -r /flushed
485 + '
486 +
487 + test_expect_success "child dir looks right" '
488 + verify_dir_contents /
489 + '
490 +
491 + # test for https://github.com/ipfs/go-ipfs/issues/2654
492 + test_expect_success "create and remove dir" '
493 + ipfs files mkdir /test_dir &&
494 + ipfs files rm -r "/test_dir"
495 + '
496 +
497 + test_expect_success "create test file" '
498 + echo "content" | ipfs files write -e "/test_file"
499 + '
500 +
501 + test_expect_success "copy test file onto test dir" '
502 + ipfs files cp "/test_file" "/test_dir"
503 + '
504 +
505 + test_expect_success "test /test_dir" '
506 + ipfs files stat "/test_dir" | grep -q "^Type: file"
507 + '
508 +
509 + test_expect_success "clean up /test_dir and /test_file" '
510 + ipfs files rm -r /test_dir &&
511 + ipfs files rm -r /test_file
512 + '
513 +
514 + test_expect_success "make a directory and a file" '
515 + ipfs files mkdir /adir &&
516 + echo "blah" | ipfs files write --create /foobar
517 + '
518 +
519 + test_expect_success "copy a file into a directory" '
520 + ipfs files cp /foobar /adir/
521 + '
522 +
523 + test_expect_success "file made it into directory" '
524 + ipfs files ls /adir | grep foobar
525 + '
526 +
527 + test_expect_success "clean up" '
528 + ipfs files rm -r /foobar &&
529 + ipfs files rm -r /adir
530 + '
531 +
532 + test_expect_success "root mfs entry is empty" '
533 + verify_dir_contents /
534 + '
535 +
536 + test_expect_success "repo gc" '
537 + ipfs repo gc
538 + '
539 }
540
541 # test offline and online
542 test_expect_success "can create some files for testing" '
543 - create_files
543 + create_files
544 '
545 test_files_api QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt
546
547 test_expect_success "can create some files for testing with raw-leaves" '
548 - create_files --raw-leaves
548 + create_files --raw-leaves
549 '
550 test_files_api QmTpKiKcAj4sbeesN6vrs5w3QeVmd4QmGpxRL81hHut4dZ
551
@@ -553,19 +553,19 @@ test_launch_ipfs_daemon --offline
553
554 ONLINE=1 # set online flag so tests can easily tell
555 test_expect_success "can create some files for testing" '
556 - create_files
556 + create_files
557 '
558 test_files_api QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt
559
560 test_expect_success "can create some files for testing with raw-leaves" '
561 - create_files --raw-leaves
561 + create_files --raw-leaves
562 '
563 test_files_api QmTpKiKcAj4sbeesN6vrs5w3QeVmd4QmGpxRL81hHut4dZ
564
565 test_kill_ipfs_daemon --offline
566
567 test_expect_success "enable sharding in config" '
568 - ipfs config --json Experimental.ShardingEnabled true
568 + ipfs config --json Experimental.ShardingEnabled true
569 '
570
571 test_launch_ipfs_daemon --offline
test/sharness/t0251-files-flushing.sh
+21 -21
@@ -11,41 +11,41 @@ test_description="test the unix files api flushing"
11 test_init_ipfs
12
13 verify_path_exists() {
14 - # simply running ls on a file should be a good 'check'
15 - ipfs files ls $1
14 + # simply running ls on a file should be a good 'check'
15 + ipfs files ls $1
16 }
17
18 verify_dir_contents() {
19 - dir=$1
20 - shift
21 - rm -f expected
22 - touch expected
23 - for e in $@
24 - do
25 - echo $e >> expected
26 - done
27 -
28 - test_expect_success "can list dir" '
29 - ipfs files ls $dir > output
30 - '
31 -
32 - test_expect_success "dir entries look good" '
33 - test_sort_cmp output expected
34 - '
19 + dir=$1
20 + shift
21 + rm -f expected
22 + touch expected
23 + for e in $@
24 + do
25 + echo $e >> expected
26 + done
27 +
28 + test_expect_success "can list dir" '
29 + ipfs files ls $dir > output
30 + '
31 +
32 + test_expect_success "dir entries look good" '
33 + test_sort_cmp output expected
34 + '
35 }
36
37 test_launch_ipfs_daemon
38
39 test_expect_success "can copy a file in" '
40 - HASH=$(echo "foo" | ipfs add -q) &&
41 - ipfs files cp /ipfs/$HASH /file
40 + HASH=$(echo "foo" | ipfs add -q) &&
41 + ipfs files cp /ipfs/$HASH /file
42 '
43
44 test_kill_ipfs_daemon
45 test_launch_ipfs_daemon
46
47 test_expect_success "file is still there" '
48 - verify_path_exists /file
48 + verify_path_exists /file
49 '
50
51 test_kill_ipfs_daemon
test/sharness/t0252-files-gc.sh
+33 -33
@@ -11,66 +11,66 @@ test_description="test how the unix files api interacts with the gc"
11 test_init_ipfs
12
13 test_expect_success "object not removed after gc" '
14 - echo "hello world" > hello.txt &&
15 - cat hello.txt | ipfs files write --create /hello.txt &&
16 - ipfs repo gc &&
17 - ipfs cat QmVib14uvPnCP73XaCDpwugRuwfTsVbGyWbatHAmLSdZUS
14 + echo "hello world" > hello.txt &&
15 + cat hello.txt | ipfs files write --create /hello.txt &&
16 + ipfs repo gc &&
17 + ipfs cat QmVib14uvPnCP73XaCDpwugRuwfTsVbGyWbatHAmLSdZUS
18 '
19
20 test_expect_success "/hello.txt still accessible after gc" '
21 - ipfs files read /hello.txt > hello-actual &&
22 - test_cmp hello.txt hello-actual
21 + ipfs files read /hello.txt > hello-actual &&
22 + test_cmp hello.txt hello-actual
23 '
24
25 ADIR_HASH=QmbCgoMYVuZq8m1vK31JQx9DorwQdLMF1M3sJ7kygLLqnW
26 FILE1_HASH=QmX4eaSJz39mNhdu5ACUwTDpyA6y24HmrQNnAape6u3buS
27
28 test_expect_success "gc okay after adding incomplete node -- prep" '
29 - ipfs files mkdir /adir &&
30 - echo "file1" | ipfs files write --create /adir/file1 &&
31 - echo "file2" | ipfs files write --create /adir/file2 &&
32 - ipfs pin add --recursive=false $ADIR_HASH &&
33 - ipfs files rm -r /adir &&
34 - ipfs repo gc && # will remove /adir/file1 and /adir/file2 but not /adir
35 - test_must_fail ipfs cat $FILE1_HASH &&
36 - ipfs files cp /ipfs/$ADIR_HASH /adir &&
37 - ipfs pin rm $ADIR_HASH
29 + ipfs files mkdir /adir &&
30 + echo "file1" | ipfs files write --create /adir/file1 &&
31 + echo "file2" | ipfs files write --create /adir/file2 &&
32 + ipfs pin add --recursive=false $ADIR_HASH &&
33 + ipfs files rm -r /adir &&
34 + ipfs repo gc && # will remove /adir/file1 and /adir/file2 but not /adir
35 + test_must_fail ipfs cat $FILE1_HASH &&
36 + ipfs files cp /ipfs/$ADIR_HASH /adir &&
37 + ipfs pin rm $ADIR_HASH
38 '
39
40 test_expect_success "gc okay after adding incomplete node" '
41 - ipfs refs $ADIR_HASH &&
42 - ipfs repo gc &&
43 - ipfs refs $ADIR_HASH
41 + ipfs refs $ADIR_HASH &&
42 + ipfs repo gc &&
43 + ipfs refs $ADIR_HASH
44 '
45
46 test_expect_success "add directory with direct pin" '
47 - mkdir mydir/ &&
48 - echo "hello world!" > mydir/hello.txt &&
49 - FILE_UNPINNED=$(ipfs add --pin=false -q -r mydir/hello.txt) &&
50 - DIR_PINNED=$(ipfs add --pin=false -q -r mydir | tail -n1) &&
51 - ipfs add --pin=false -r mydir &&
52 - ipfs pin add --recursive=false $DIR_PINNED &&
53 - ipfs cat $FILE_UNPINNED
47 + mkdir mydir/ &&
48 + echo "hello world!" > mydir/hello.txt &&
49 + FILE_UNPINNED=$(ipfs add --pin=false -q -r mydir/hello.txt) &&
50 + DIR_PINNED=$(ipfs add --pin=false -q -r mydir | tail -n1) &&
51 + ipfs add --pin=false -r mydir &&
52 + ipfs pin add --recursive=false $DIR_PINNED &&
53 + ipfs cat $FILE_UNPINNED
54 '
55
56 test_expect_success "run gc and make sure directory contents are removed" '
57 - ipfs repo gc &&
58 - test_must_fail ipfs cat $FILE_UNPINNED
57 + ipfs repo gc &&
58 + test_must_fail ipfs cat $FILE_UNPINNED
59 '
60
61 test_expect_success "add incomplete directory and make sure gc is okay" '
62 - ipfs files cp /ipfs/$DIR_PINNED /mydir &&
63 - ipfs repo gc &&
64 - test_must_fail ipfs cat $FILE_UNPINNED
62 + ipfs files cp /ipfs/$DIR_PINNED /mydir &&
63 + ipfs repo gc &&
64 + test_must_fail ipfs cat $FILE_UNPINNED
65 '
66
67 test_expect_success "add back directory contents and run gc" '
68 - ipfs add --pin=false mydir/hello.txt &&
69 - ipfs repo gc
68 + ipfs add --pin=false mydir/hello.txt &&
69 + ipfs repo gc
70 '
71
72 test_expect_success "make sure directory contents are not removed" '
73 - ipfs cat $FILE_UNPINNED
73 + ipfs cat $FILE_UNPINNED
74 '
75
76 test_done
test/sharness/t0260-sharding-flag.sh
+29 -29
@@ -9,20 +9,20 @@ test_description="Test global enable sharding flag"
9 . lib/test-lib.sh
10
11 test_expect_success "set up test data" '
12 - mkdir testdata
13 - for i in `seq 2000`
14 - do
15 - echo $i > testdata/file$i
16 - done
12 + mkdir testdata
13 + for i in `seq 2000`
14 + do
15 + echo $i > testdata/file$i
16 + done
17 '
18
19 test_add_large_dir() {
20 - exphash="$1"
21 - test_expect_success "ipfs add on very large directory succeeds" '
22 - ipfs add -r -q testdata | tail -n1 > sharddir_out &&
23 - echo "$exphash" > sharddir_exp &&
24 - test_cmp sharddir_exp sharddir_out
25 - '
20 + exphash="$1"
21 + test_expect_success "ipfs add on very large directory succeeds" '
22 + ipfs add -r -q testdata | tail -n1 > sharddir_out &&
23 + echo "$exphash" > sharddir_exp &&
24 + test_cmp sharddir_exp sharddir_out
25 + '
26 }
27
28 test_init_ipfs
@@ -37,7 +37,7 @@ test_add_large_dir "$UNSHARDED"
37 test_kill_ipfs_daemon
38
39 test_expect_success "enable sharding" '
40 - ipfs config --json Experimental.ShardingEnabled true
40 + ipfs config --json Experimental.ShardingEnabled true
41 '
42
43 SHARDED="QmSCJD1KYLhVVHqBK3YyXuoEqHt7vggyJhzoFYbT8v1XYL"
@@ -50,29 +50,29 @@ test_add_large_dir "$SHARDED"
50 test_kill_ipfs_daemon
51
52 test_expect_success "sharded and unsharded output look the same" '
53 - ipfs ls "$SHARDED" | sort > sharded_out &&
54 - ipfs ls "$UNSHARDED" | sort > unsharded_out &&
55 - test_cmp sharded_out unsharded_out
53 + ipfs ls "$SHARDED" | sort > sharded_out &&
54 + ipfs ls "$UNSHARDED" | sort > unsharded_out &&
55 + test_cmp sharded_out unsharded_out
56 '
57
58 test_expect_success "ipfs cat error output the same" '
59 - test_expect_code 1 ipfs cat "$SHARDED" 2> sharded_err &&
60 - test_expect_code 1 ipfs cat "$UNSHARDED" 2> unsharded_err &&
61 - test_cmp sharded_err unsharded_err
59 + test_expect_code 1 ipfs cat "$SHARDED" 2> sharded_err &&
60 + test_expect_code 1 ipfs cat "$UNSHARDED" 2> unsharded_err &&
61 + test_cmp sharded_err unsharded_err
62 '
63
64 test_add_large_dir_v1() {
65 - exphash="$1"
66 - test_expect_success "ipfs add (CIDv1) on very large directory succeeds" '
67 - ipfs add -r -q --cid-version=1 testdata | tail -n1 > sharddir_out &&
68 - echo "$exphash" > sharddir_exp &&
69 - test_cmp sharddir_exp sharddir_out
70 - '
71 -
72 - test_expect_success "can access a path under the dir" '
73 - ipfs cat "$exphash/file20" > file20_out &&
74 - test_cmp testdata/file20 file20_out
75 - '
65 + exphash="$1"
66 + test_expect_success "ipfs add (CIDv1) on very large directory succeeds" '
67 + ipfs add -r -q --cid-version=1 testdata | tail -n1 > sharddir_out &&
68 + echo "$exphash" > sharddir_exp &&
69 + test_cmp sharddir_exp sharddir_out
70 + '
71 +
72 + test_expect_success "can access a path under the dir" '
73 + ipfs cat "$exphash/file20" > file20_out &&
74 + test_cmp testdata/file20 file20_out
75 + '
76 }
77
78 # this hash implies both the directory and the leaf entries are CIDv1
test/sharness/t0270-filestore.sh
+39 -39
@@ -10,73 +10,73 @@ test_description="Test out the filestore nocopy functionality"
10
11
12 test_expect_success "create a dataset" '
13 - random-files -seed=483 -depth=3 -dirs=4 -files=6 -filesize=1000000 somedir > /dev/null
13 + random-files -seed=483 -depth=3 -dirs=4 -files=6 -filesize=1000000 somedir > /dev/null
14 '
15
16 EXPHASH="QmW4JLyeTxEWGwa4mkE9mHzdtAkyhMX2ToGFEKZNjCiJud"
17
18 get_repo_size() {
19 - disk_usage "$IPFS_PATH"
19 + disk_usage "$IPFS_PATH"
20 }
21
22 assert_repo_size_less_than() {
23 - expval="$1"
23 + expval="$1"
24
25 - test_expect_success "check repo size" '
26 - test "$(get_repo_size)" -lt "$expval" ||
27 - { echo should be bellow "$expval" && test_fsh get_repo_size; }
28 - '
25 + test_expect_success "check repo size" '
26 + test "$(get_repo_size)" -lt "$expval" ||
27 + { echo should be bellow "$expval" && test_fsh get_repo_size; }
28 + '
29 }
30
31 assert_repo_size_greater_than() {
32 - expval="$1"
32 + expval="$1"
33
34 - test_expect_success "check repo size" '
35 - test "$(get_repo_size)" -gt "$expval" ||
36 - { echo should be above "$expval" && test_fsh get_repo_size; }
37 - '
34 + test_expect_success "check repo size" '
35 + test "$(get_repo_size)" -gt "$expval" ||
36 + { echo should be above "$expval" && test_fsh get_repo_size; }
37 + '
38 }
39
40 test_filestore_adds() {
41 - test_expect_success "nocopy add succeeds" '
42 - HASH=$(ipfs add --raw-leaves --nocopy -r -q somedir | tail -n1)
43 - '
41 + test_expect_success "nocopy add succeeds" '
42 + HASH=$(ipfs add --raw-leaves --nocopy -r -q somedir | tail -n1)
43 + '
44
45 - test_expect_success "nocopy add has right hash" '
46 - test "$HASH" = "$EXPHASH"
47 - '
45 + test_expect_success "nocopy add has right hash" '
46 + test "$HASH" = "$EXPHASH"
47 + '
48
49 - assert_repo_size_less_than 1000000
49 + assert_repo_size_less_than 1000000
50
51 - test_expect_success "normal add with fscache doesnt duplicate data" '
52 - ipfs add --raw-leaves --fscache -r -q somedir > /dev/null
53 - '
51 + test_expect_success "normal add with fscache doesnt duplicate data" '
52 + ipfs add --raw-leaves --fscache -r -q somedir > /dev/null
53 + '
54
55 - assert_repo_size_less_than 1000000
55 + assert_repo_size_less_than 1000000
56
57 - test_expect_success "normal add without fscache duplicates data" '
58 - ipfs add --raw-leaves -r -q somedir > /dev/null
59 - '
57 + test_expect_success "normal add without fscache duplicates data" '
58 + ipfs add --raw-leaves -r -q somedir > /dev/null
59 + '
60
61 - assert_repo_size_greater_than 1000000
61 + assert_repo_size_greater_than 1000000
62 }
63
64 init_ipfs_filestore() {
65 - test_expect_success "clean up old node" '
66 - rm -rf "$IPFS_PATH" mountdir ipfs ipns
67 - '
65 + test_expect_success "clean up old node" '
66 + rm -rf "$IPFS_PATH" mountdir ipfs ipns
67 + '
68
69 - test_init_ipfs
69 + test_init_ipfs
70
71 - test_expect_success "nocopy add errors and has right message" '
72 - test_must_fail ipfs add --nocopy -r somedir 2> add_out &&
73 - grep "filestore is not enabled" add_out
74 - '
71 + test_expect_success "nocopy add errors and has right message" '
72 + test_must_fail ipfs add --nocopy -r somedir 2> add_out &&
73 + grep "filestore is not enabled" add_out
74 + '
75
76
77 - test_expect_success "enable filestore config setting" '
78 - ipfs config --json Experimental.FilestoreEnabled true
79 - '
77 + test_expect_success "enable filestore config setting" '
78 + ipfs config --json Experimental.FilestoreEnabled true
79 + '
80 }
81
82 init_ipfs_filestore
@@ -84,7 +84,7 @@ init_ipfs_filestore
84 test_filestore_adds
85
86 test_debug '
87 - echo "pwd=$(pwd)"; echo "IPFS_PATH=$IPFS_PATH"
87 + echo "pwd=$(pwd)"; echo "IPFS_PATH=$IPFS_PATH"
88 '
89
90
test/sharness/t0271-filestore-utils.sh
+105 -105
@@ -9,30 +9,30 @@ test_description="Test out the filestore nocopy functionality"
9 . lib/test-lib.sh
10
11 test_init_filestore() {
12 - test_expect_success "clean up old node" '
13 - rm -rf "$IPFS_PATH" mountdir ipfs ipns
14 - '
12 + test_expect_success "clean up old node" '
13 + rm -rf "$IPFS_PATH" mountdir ipfs ipns
14 + '
15
16 - test_init_ipfs
16 + test_init_ipfs
17
18 - test_expect_success "enable filestore config setting" '
19 - ipfs config --json Experimental.FilestoreEnabled true
20 - '
18 + test_expect_success "enable filestore config setting" '
19 + ipfs config --json Experimental.FilestoreEnabled true
20 + '
21 }
22
23 test_init_dataset() {
24 - test_expect_success "create a dataset" '
25 - rm -r somedir
26 - mkdir somedir &&
27 - random 1000 1 > somedir/file1 &&
28 - random 10000 2 > somedir/file2 &&
29 - random 1000000 3 > somedir/file3
30 - '
24 + test_expect_success "create a dataset" '
25 + rm -r somedir
26 + mkdir somedir &&
27 + random 1000 1 > somedir/file1 &&
28 + random 10000 2 > somedir/file2 &&
29 + random 1000000 3 > somedir/file3
30 + '
31 }
32
33 test_init() {
34 - test_init_filestore
35 - test_init_dataset
34 + test_init_filestore
35 + test_init_dataset
36 }
37
38 EXPHASH="QmRueCuPMYYvdxWz1vWncF7wzCScEx4qasZXo5aVBb1R4V"
@@ -64,105 +64,105 @@ EOF
64 sort < verify_expect_file_order > verify_expect_key_order
65
66 test_filestore_adds() {
67 - test_expect_success "nocopy add succeeds" '
68 - HASH=$(ipfs add --raw-leaves --nocopy -r -q somedir | tail -n1)
69 - '
70 -
71 - test_expect_success "nocopy add has right hash" '
72 - test "$HASH" = "$EXPHASH"
73 - '
74 -
75 - test_expect_success "'ipfs filestore ls' output looks good'" '
76 - ipfs filestore ls | sort > ls_actual &&
77 - test_cmp ls_expect_key_order ls_actual
78 - '
79 -
80 - test_expect_success "'ipfs filestore ls --file-order' output looks good'" '
81 - ipfs filestore ls --file-order > ls_actual &&
82 - test_cmp ls_expect_file_order ls_actual
83 - '
84 -
85 - test_expect_success "'ipfs filestore ls HASH' works" '
86 - ipfs filestore ls $FILE1_HASH > ls_actual &&
87 - grep -q somedir/file1 ls_actual
88 - '
89 -
90 - test_expect_success "can retrieve multi-block file" '
91 - ipfs cat $FILE3_HASH > file3.data &&
92 - test_cmp somedir/file3 file3.data
93 - '
67 + test_expect_success "nocopy add succeeds" '
68 + HASH=$(ipfs add --raw-leaves --nocopy -r -q somedir | tail -n1)
69 + '
70 +
71 + test_expect_success "nocopy add has right hash" '
72 + test "$HASH" = "$EXPHASH"
73 + '
74 +
75 + test_expect_success "'ipfs filestore ls' output looks good'" '
76 + ipfs filestore ls | sort > ls_actual &&
77 + test_cmp ls_expect_key_order ls_actual
78 + '
79 +
80 + test_expect_success "'ipfs filestore ls --file-order' output looks good'" '
81 + ipfs filestore ls --file-order > ls_actual &&
82 + test_cmp ls_expect_file_order ls_actual
83 + '
84 +
85 + test_expect_success "'ipfs filestore ls HASH' works" '
86 + ipfs filestore ls $FILE1_HASH > ls_actual &&
87 + grep -q somedir/file1 ls_actual
88 + '
89 +
90 + test_expect_success "can retrieve multi-block file" '
91 + ipfs cat $FILE3_HASH > file3.data &&
92 + test_cmp somedir/file3 file3.data
93 + '
94 }
95
96 # check that the filestore is in a clean state
97 test_filestore_state() {
98 - test_expect_success "ipfs filestore verify' output looks good'" '
99 - ipfs filestore verify | LC_ALL=C sort > verify_actual
100 - test_cmp verify_expect_key_order verify_actual
101 - '
98 + test_expect_success "ipfs filestore verify' output looks good'" '
99 + ipfs filestore verify | LC_ALL=C sort > verify_actual
100 + test_cmp verify_expect_key_order verify_actual
101 + '
102 }
103
104 test_filestore_verify() {
105 - test_filestore_state
106 -
107 - test_expect_success "ipfs filestore verify --file-order' output looks good'" '
108 - ipfs filestore verify --file-order > verify_actual
109 - test_cmp verify_expect_file_order verify_actual
110 - '
111 -
112 - test_expect_success "'ipfs filestore verify HASH' works" '
113 - ipfs filestore verify $FILE1_HASH > verify_actual &&
114 - grep -q somedir/file1 verify_actual
115 - '
116 -
117 - test_expect_success "rename a file" '
118 - mv somedir/file1 somedir/file1.bk
119 - '
120 -
121 - test_expect_success "can not retrieve block after backing file moved" '
122 - test_must_fail ipfs cat $FILE1_HASH
123 - '
124 -
125 - test_expect_success "'ipfs filestore verify' shows file as missing" '
126 - ipfs filestore verify > verify_actual &&
127 - grep no-file verify_actual | grep -q somedir/file1
128 - '
129 -
130 - test_expect_success "move file back" '
131 - mv somedir/file1.bk somedir/file1
132 - '
133 -
134 - test_expect_success "block okay now" '
135 - ipfs cat $FILE1_HASH > file1.data &&
136 - test_cmp somedir/file1 file1.data
137 - '
138 -
139 - test_expect_success "change first bit of file" '
140 - dd if=/dev/zero of=somedir/file3 bs=1024 count=1
141 - '
142 -
143 - test_expect_success "can not retrieve block after backing file changed" '
144 - test_must_fail ipfs cat $FILE3_HASH
145 - '
146 -
147 - test_expect_success "'ipfs filestore verify' shows file as changed" '
148 - ipfs filestore verify > verify_actual &&
149 - grep changed verify_actual | grep -q somedir/file3
150 - '
151 -
152 - # reset the state for the next test
153 - test_init_dataset
105 + test_filestore_state
106 +
107 + test_expect_success "ipfs filestore verify --file-order' output looks good'" '
108 + ipfs filestore verify --file-order > verify_actual
109 + test_cmp verify_expect_file_order verify_actual
110 + '
111 +
112 + test_expect_success "'ipfs filestore verify HASH' works" '
113 + ipfs filestore verify $FILE1_HASH > verify_actual &&
114 + grep -q somedir/file1 verify_actual
115 + '
116 +
117 + test_expect_success "rename a file" '
118 + mv somedir/file1 somedir/file1.bk
119 + '
120 +
121 + test_expect_success "can not retrieve block after backing file moved" '
122 + test_must_fail ipfs cat $FILE1_HASH
123 + '
124 +
125 + test_expect_success "'ipfs filestore verify' shows file as missing" '
126 + ipfs filestore verify > verify_actual &&
127 + grep no-file verify_actual | grep -q somedir/file1
128 + '
129 +
130 + test_expect_success "move file back" '
131 + mv somedir/file1.bk somedir/file1
132 + '
133 +
134 + test_expect_success "block okay now" '
135 + ipfs cat $FILE1_HASH > file1.data &&
136 + test_cmp somedir/file1 file1.data
137 + '
138 +
139 + test_expect_success "change first bit of file" '
140 + dd if=/dev/zero of=somedir/file3 bs=1024 count=1
141 + '
142 +
143 + test_expect_success "can not retrieve block after backing file changed" '
144 + test_must_fail ipfs cat $FILE3_HASH
145 + '
146 +
147 + test_expect_success "'ipfs filestore verify' shows file as changed" '
148 + ipfs filestore verify > verify_actual &&
149 + grep changed verify_actual | grep -q somedir/file3
150 + '
151 +
152 + # reset the state for the next test
153 + test_init_dataset
154 }
155
156 test_filestore_dups() {
157 - # make sure the filestore is in a clean state
158 - test_filestore_state
159 -
160 - test_expect_success "'ipfs filestore dups'" '
161 - ipfs add --raw-leaves somedir/file1 &&
162 - ipfs filestore dups > dups_actual &&
163 - echo "$FILE1_HASH" > dups_expect
164 - test_cmp dups_expect dups_actual
165 - '
157 + # make sure the filestore is in a clean state
158 + test_filestore_state
159 +
160 + test_expect_success "'ipfs filestore dups'" '
161 + ipfs add --raw-leaves somedir/file1 &&
162 + ipfs filestore dups > dups_actual &&
163 + echo "$FILE1_HASH" > dups_expect
164 + test_cmp dups_expect dups_actual
165 + '
166 }
167
168 #
test/sharness/t0280-plugin-git.sh
+21 -21
@@ -10,40 +10,40 @@ test_description="Test git plugin"
10
11 # if in travis CI, dont test mount (no fuse)
12 if ! test_have_prereq PLUGIN; then
13 - skip_all='skipping git plugin tests, plugins not available'
13 + skip_all='skipping git plugin tests, plugins not available'
14
15 - test_done
15 + test_done
16 fi
17
18 test_init_ipfs
19
20 test_expect_success "copy plugin" '
21 - mkdir -p "$IPFS_PATH/plugins" &&
22 - cp ../plugins/git.so "$IPFS_PATH/plugins/"
21 + mkdir -p "$IPFS_PATH/plugins" &&
22 + cp ../plugins/git.so "$IPFS_PATH/plugins/"
23 '
24
25 # from https://github.com/ipfs/go-ipld-git/blob/master/make-test-repo.sh
26 test_expect_success "prepare test data" '
27 - tar xzf ../t0280-plugin-git-data/git.tar.gz
27 + tar xzf ../t0280-plugin-git-data/git.tar.gz
28 '
29
30 test_dag_git() {
31 - test_expect_success "add objects via dag put" '
32 - find objects -type f -exec ipfs dag put --format=git --input-enc=zlib {} \; -exec echo \; > hashes
33 - '
34 -
35 - test_expect_success "successfully get added objects" '
36 - cat hashes | xargs -i ipfs dag get -- {} > /dev/null
37 - '
38 -
39 - test_expect_success "path traversals work" '
40 - echo \"YmxvYiA3ACcsLnB5Zgo=\" > file1 &&
41 - ipfs dag get z8mWaJh5RLq16Zwgtd8gZxd63P4hgwNNx/object/parents/0/tree/dir2/hash/f3/hash > out1
42 - '
43 -
44 - test_expect_success "outputs look correct" '
45 - test_cmp file1 out1
46 - '
31 + test_expect_success "add objects via dag put" '
32 + find objects -type f -exec ipfs dag put --format=git --input-enc=zlib {} \; -exec echo \; > hashes
33 + '
34 +
35 + test_expect_success "successfully get added objects" '
36 + cat hashes | xargs -i ipfs dag get -- {} > /dev/null
37 + '
38 +
39 + test_expect_success "path traversals work" '
40 + echo \"YmxvYiA3ACcsLnB5Zgo=\" > file1 &&
41 + ipfs dag get z8mWaJh5RLq16Zwgtd8gZxd63P4hgwNNx/object/parents/0/tree/dir2/hash/f3/hash > out1
42 + '
43 +
44 + test_expect_success "outputs look correct" '
45 + test_cmp file1 out1
46 + '
47 }
48
49 # should work offline
test/sharness/t0300-docker-image.sh
+29 -29
@@ -10,21 +10,21 @@ test_description="Test docker image"
10
11 # if in travis CI on OSX, docker is not available
12 if ! test_have_prereq DOCKER; then
13 - skip_all='skipping docker tests, docker not available'
13 + skip_all='skipping docker tests, docker not available'
14
15 - test_done
15 + test_done
16 fi
17
18 test_expect_success "'docker --version' works" '
19 - docker --version >actual
19 + docker --version >actual
20 '
21
22 test_expect_success "'docker --version' output looks good" '
23 - egrep "^Docker version" actual
23 + egrep "^Docker version" actual
24 '
25
26 test_expect_success "current user is in the 'docker' group" '
27 - groups | egrep "\bdocker\b"
27 + groups | egrep "\bdocker\b"
28 '
29
30 TEST_TRASH_DIR=$(pwd)
@@ -33,52 +33,52 @@ TEST_TESTS_DIR=$(dirname "$TEST_SCRIPTS_DIR")
33 APP_ROOT_DIR=$(dirname "$TEST_TESTS_DIR")
34
35 test_expect_success "docker image build succeeds" '
36 - docker_build "$TEST_TESTS_DIR/../Dockerfile.fast" "$APP_ROOT_DIR" >actual ||
37 - test_fsh echo "TEST_TESTS_DIR: $TEST_TESTS_DIR" ||
38 - test_fsh echo "APP_ROOT_DIR : $APP_ROOT_DIR" ||
39 - test_fsh cat actual
36 + docker_build "$TEST_TESTS_DIR/../Dockerfile.fast" "$APP_ROOT_DIR" >actual ||
37 + test_fsh echo "TEST_TESTS_DIR: $TEST_TESTS_DIR" ||
38 + test_fsh echo "APP_ROOT_DIR : $APP_ROOT_DIR" ||
39 + test_fsh cat actual
40 '
41
42 test_expect_success "docker image build output looks good" '
43 - SUCCESS_LINE=$(egrep "^Successfully built" actual) &&
44 - IMAGE_ID=$(expr "$SUCCESS_LINE" : "^Successfully built \(.*\)") ||
45 - test_fsh cat actual
43 + SUCCESS_LINE=$(egrep "^Successfully built" actual) &&
44 + IMAGE_ID=$(expr "$SUCCESS_LINE" : "^Successfully built \(.*\)") ||
45 + test_fsh cat actual
46 '
47
48 test_expect_success "docker image runs" '
49 - DOC_ID=$(docker_run "$IMAGE_ID")
49 + DOC_ID=$(docker_run "$IMAGE_ID")
50 '
51
52 test_expect_success "docker image gateway is up" '
53 - docker_exec "$DOC_ID" "wget --retry-connrefused --waitretry=1 --timeout=30 -t 30 \
54 - -q -O - http://localhost:8080/version >/dev/null"
53 + docker_exec "$DOC_ID" "wget --retry-connrefused --waitretry=1 --timeout=30 -t 30 \
54 + -q -O - http://localhost:8080/version >/dev/null"
55 '
56
57 test_expect_success "docker image API is up" '
58 - docker_exec "$DOC_ID" "wget --retry-connrefused --waitretry=1 --timeout=30 -t 30 \
59 - -q -O - http://localhost:5001/api/v0/version >/dev/null"
58 + docker_exec "$DOC_ID" "wget --retry-connrefused --waitretry=1 --timeout=30 -t 30 \
59 + -q -O - http://localhost:5001/api/v0/version >/dev/null"
60 '
61
62 test_expect_success "simple ipfs add/cat can be run in docker container" '
63 - expected="Hello Worlds" &&
64 - HASH=$(docker_exec "$DOC_ID" "echo $(cat expected) | ipfs add | cut -d' ' -f2") &&
65 - docker_exec "$DOC_ID" "ipfs cat $HASH" >actual &&
66 - test_cmp expected actual
63 + expected="Hello Worlds" &&
64 + HASH=$(docker_exec "$DOC_ID" "echo $(cat expected) | ipfs add | cut -d' ' -f2") &&
65 + docker_exec "$DOC_ID" "ipfs cat $HASH" >actual &&
66 + test_cmp expected actual
67 '
68
69 read testcode <<EOF
70 - docker exec -i "$DOC_ID" wget --retry-connrefused --waitretry=1 --timeout=30 -t 30 \
71 - -q -O - http://localhost:8080/version | grep Commit | cut -d" " -f2 >actual ; \
72 - test -s actual ; \
73 - docker exec -i "$DOC_ID" ipfs version --enc json \
74 - | sed 's/^.*"Commit":"\\\([^"]*\\\)".*$/\\\1/g' >expected ; \
75 - test -s expected ; \
76 - test_cmp expected actual
70 + docker exec -i "$DOC_ID" wget --retry-connrefused --waitretry=1 --timeout=30 -t 30 \
71 + -q -O - http://localhost:8080/version | grep Commit | cut -d" " -f2 >actual ; \
72 + test -s actual ; \
73 + docker exec -i "$DOC_ID" ipfs version --enc json \
74 + | sed 's/^.*"Commit":"\\\([^"]*\\\)".*$/\\\1/g' >expected ; \
75 + test -s expected ; \
76 + test_cmp expected actual
77 EOF
78 test_expect_success "version CurrentCommit is set" "$testcode"
79
80 test_expect_success "stop docker container" '
81 - docker_stop "$DOC_ID"
81 + docker_stop "$DOC_ID"
82 '
83
84 test_done
test/sharness/t0301-docker-migrate.sh
+19 -19
@@ -10,9 +10,9 @@ test_description="Test docker image migration"
10
11 # if in travis CI on OSX, docker is not available
12 if ! test_have_prereq DOCKER; then
13 - skip_all='skipping docker tests, docker not available'
13 + skip_all='skipping docker tests, docker not available'
14
15 - test_done
15 + test_done
16 fi
17
18 TEST_TRASH_DIR=$(pwd)
@@ -21,55 +21,55 @@ TEST_TESTS_DIR=$(dirname "$TEST_SCRIPTS_DIR")
21 APP_ROOT_DIR=$(dirname "$TEST_TESTS_DIR")
22
23 test_expect_success "docker image build succeeds" '
24 - docker_build "$TEST_TESTS_DIR/../Dockerfile.fast" "$APP_ROOT_DIR" >actual &&
25 - IMAGE_ID=$(tail -n1 actual | cut -d " " -f 3)
24 + docker_build "$TEST_TESTS_DIR/../Dockerfile.fast" "$APP_ROOT_DIR" >actual &&
25 + IMAGE_ID=$(tail -n1 actual | cut -d " " -f 3)
26 '
27
28 test_init_ipfs
29
30 test_expect_success "make repo be version 4" '
31 - echo 4 > "$IPFS_PATH/version"
31 + echo 4 > "$IPFS_PATH/version"
32 '
33
34 test_expect_success "setup http response" '
35 - echo "HTTP/1.1 200 OK" > vers_resp &&
36 - echo "Content-Length: 7" >> vers_resp &&
37 - echo "" >> vers_resp &&
38 - echo "v1.1.1" >> vers_resp
35 + echo "HTTP/1.1 200 OK" > vers_resp &&
36 + echo "Content-Length: 7" >> vers_resp &&
37 + echo "" >> vers_resp &&
38 + echo "v1.1.1" >> vers_resp
39 '
40
41 pretend_server() {
42 - cat vers_resp | nc -l -i 1 -p 17233
42 + cat vers_resp | nc -l -i 1 -p 17233
43 }
44
45 test_expect_success "startup fake dists server" '
46 - pretend_server > dist_serv_out &
47 - echo $! > netcat_pid
46 + pretend_server > dist_serv_out &
47 + echo $! > netcat_pid
48 '
49
50 test_expect_success "docker image runs" '
51 - DOC_ID=$(docker run -d -v "$IPFS_PATH":/data/ipfs --net=host -e IPFS_DIST_PATH="http://localhost:17233" "$IMAGE_ID" --migrate)
51 + DOC_ID=$(docker run -d -v "$IPFS_PATH":/data/ipfs --net=host -e IPFS_DIST_PATH="http://localhost:17233" "$IMAGE_ID" --migrate)
52 '
53
54 test_expect_success "docker container tries to pull migrations from netcat" '
55 - sleep 4 &&
56 - cat dist_serv_out
55 + sleep 4 &&
56 + cat dist_serv_out
57 '
58
59 test_expect_success "see logs" '
60 - docker logs $DOC_ID
60 + docker logs $DOC_ID
61 '
62
63 test_expect_success "stop docker container" '
64 - docker_stop "$DOC_ID"
64 + docker_stop "$DOC_ID"
65 '
66
67 test_expect_success "kill the net cat" '
68 - kill $(cat netcat_pid) || true
68 + kill $(cat netcat_pid) || true
69 '
70
71 test_expect_success "correct version was requested" '
72 - grep "/fs-repo-migrations/v1.1.1/fs-repo-migrations_v1.1.1_linux-amd64.tar.gz" dist_serv_out > /dev/null
72 + grep "/fs-repo-migrations/v1.1.1/fs-repo-migrations_v1.1.1_linux-amd64.tar.gz" dist_serv_out > /dev/null
73 '
74
75 test_done
test/sharness/t0400-api-security.sh
+4 -4
@@ -17,15 +17,15 @@ test_init_ipfs
17
18 test_launch_ipfs_daemon
19 test_expect_success "Gateway on API unavailable" '
20 - HASH=$(echo "testing" | ipfs add -q)
21 - test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 404 Not Found"
20 + HASH=$(echo "testing" | ipfs add -q)
21 + test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 404 Not Found"
22 '
23 test_kill_ipfs_daemon
24
25 test_launch_ipfs_daemon --unrestricted-api
26 test_expect_success "Gateway on --unrestricted-api API available" '
27 - HASH=$(echo "testing" | ipfs add -q)
28 - test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 200 OK"
27 + HASH=$(echo "testing" | ipfs add -q)
28 + test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 200 OK"
29 '
30 test_kill_ipfs_daemon
31
test/sharness/t0410-api-add.sh
+1 -1
@@ -14,7 +14,7 @@ test_init_ipfs
14
15 test_launch_ipfs_daemon
16 test_expect_success "API Add response includes size field" '
17 - echo "hi" | curl -s -F file=@- "http://localhost:$API_PORT/api/v0/add" | grep "\"Size\": *\"11\""
17 + echo "hi" | curl -s -F file=@- "http://localhost:$API_PORT/api/v0/add" | grep "\"Size\": *\"11\""
18 '
19 test_kill_ipfs_daemon
20
test/sharness/t0500-issues-and-regressions-offline.sh
+11 -11
@@ -7,36 +7,36 @@ test_description="Tests for various fixed issues and regressions."
7 # Tests go here
8
9 test_expect_success "ipfs init with occupied input works - #2748" '
10 - export IPFS_PATH="ipfs_path"
11 - echo "" | go-timeout 10 ipfs init &&
12 - rm -rf ipfs_path
10 + export IPFS_PATH="ipfs_path"
11 + echo "" | go-timeout 10 ipfs init &&
12 + rm -rf ipfs_path
13 '
14 test_init_ipfs
15
16 test_expect_success "ipfs cat --help succeeds when input remains open" '
17 - yes | go-timeout 1 ipfs cat --help
17 + yes | go-timeout 1 ipfs cat --help
18 '
19
20 test_expect_success "ipfs pin ls --help succeeds when input remains open" '
21 - yes | go-timeout 1 ipfs pin ls --help
21 + yes | go-timeout 1 ipfs pin ls --help
22 '
23
24 test_expect_success "ipfs add on 1MB from stdin woks" '
25 - random 1048576 42 | ipfs add -q > 1MB.hash
25 + random 1048576 42 | ipfs add -q > 1MB.hash
26 '
27
28 test_expect_success "'ipfs refs -r -e \$(cat 1MB.hash)' succeeds" '
29 - ipfs refs -r -e $(cat 1MB.hash) > refs-e.out
29 + ipfs refs -r -e $(cat 1MB.hash) > refs-e.out
30 '
31
32 test_expect_success "output of 'ipfs refs -e' links to separate blocks" '
33 - grep "$(cat 1MB.hash) ->" refs-e.out
33 + grep "$(cat 1MB.hash) ->" refs-e.out
34 '
35
36 test_expect_success "output of 'ipfs refs -e' contains all first level links" '
37 - grep "$(cat 1MB.hash) ->" refs-e.out | sed -e '\''s/.* -> //'\'' | sort > refs-s.out &&
38 - ipfs refs "$(cat 1MB.hash)" | sort > refs-one.out &&
39 - test_cmp refs-s.out refs-one.out
37 + grep "$(cat 1MB.hash) ->" refs-e.out | sed -e '\''s/.* -> //'\'' | sort > refs-s.out &&
38 + ipfs refs "$(cat 1MB.hash)" | sort > refs-one.out &&
39 + test_cmp refs-s.out refs-one.out
40 '
41
42 test_done
test/sharness/t0600-issues-and-regressions-online.sh
+20 -20
@@ -11,52 +11,52 @@ test_launch_ipfs_daemon
11 # Tests go here
12
13 test_expect_success "commands command with flag flags works via HTTP API - #2301" '
14 - curl "http://$API_ADDR/api/v0/commands?flags" | grep "verbose"
14 + curl "http://$API_ADDR/api/v0/commands?flags" | grep "verbose"
15 '
16
17 test_expect_success "ipfs refs local over HTTP API returns NDJOSN not flat - #2803" '
18 - echo "Hello World" | ipfs add &&
19 - curl "http://$API_ADDR/api/v0/refs/local" | grep "Ref" | grep "Err"
18 + echo "Hello World" | ipfs add &&
19 + curl "http://$API_ADDR/api/v0/refs/local" | grep "Ref" | grep "Err"
20 '
21
22 test_expect_success "args expecting stdin dont crash when not given" '
23 - curl "$API_ADDR/api/v0/bootstrap/add" > result
23 + curl "$API_ADDR/api/v0/bootstrap/add" > result
24 '
25
26 test_expect_success "no panic traces on daemon" '
27 - test_must_fail grep "nil pointer dereference" daemon_err
27 + test_must_fail grep "nil pointer dereference" daemon_err
28 '
29
30 test_expect_success "metrics work" '
31 - curl "$API_ADDR/debug/metrics/prometheus" > pro_data &&
32 - grep "ipfs_bs_cache_arc_hits_total" < pro_data ||
33 - test_fsh cat pro_data
31 + curl "$API_ADDR/debug/metrics/prometheus" > pro_data &&
32 + grep "ipfs_bs_cache_arc_hits_total" < pro_data ||
33 + test_fsh cat pro_data
34 '
35
36 test_expect_success "pin add api looks right - #3753" '
37 - HASH=$(echo "foo" | ipfs add -q) &&
38 - curl "http://$API_ADDR/api/v0/pin/add/$HASH" > pinadd_out &&
39 - echo "{\"Pins\":[\"QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6\"]}" > pinadd_exp &&
40 - test_cmp pinadd_out pinadd_exp
37 + HASH=$(echo "foo" | ipfs add -q) &&
38 + curl "http://$API_ADDR/api/v0/pin/add/$HASH" > pinadd_out &&
39 + echo "{\"Pins\":[\"QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6\"]}" > pinadd_exp &&
40 + test_cmp pinadd_out pinadd_exp
41 '
42
43 test_expect_success "pin add api looks right - #3753" '
44 - curl "http://$API_ADDR/api/v0/pin/rm/$HASH" > pinrm_out &&
45 - echo "{\"Pins\":[\"QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6\"]}" > pinrm_exp &&
46 - test_cmp pinrm_out pinrm_exp
44 + curl "http://$API_ADDR/api/v0/pin/rm/$HASH" > pinrm_out &&
45 + echo "{\"Pins\":[\"QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6\"]}" > pinrm_exp &&
46 + test_cmp pinrm_out pinrm_exp
47 '
48
49 test_expect_success "no daemon crash on improper file argument - #4003" '
50 - FNC=$(echo $API_ADDR | awk -F: '\''{ printf "%s %s", $1, $2 }'\'') &&
51 - 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"
50 + FNC=$(echo $API_ADDR | awk -F: '\''{ printf "%s %s", $1, $2 }'\'') &&
51 + 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"
52 '
53
54 test_kill_ipfs_daemon
55
56 test_expect_success "ipfs daemon --offline --mount fails - #2995" '
57 - test_expect_code 1 ipfs daemon --offline --mount 2>daemon_err &&
58 - grep "mount is not currently supported in offline mode" daemon_err ||
59 - test_fsh cat daemon_err
57 + test_expect_code 1 ipfs daemon --offline --mount 2>daemon_err &&
58 + grep "mount is not currently supported in offline mode" daemon_err ||
59 + test_fsh cat daemon_err
60 '
61
62 test_done
test/sharness/x0601-pin-fail-test.sh
+8 -8
@@ -13,22 +13,22 @@ test_init_ipfs
13 test_launch_ipfs_daemon
14
15 test_expect_success "pre-test setup" '
16 - printf "" > pins &&
17 - ipfs pin ls --type=recursive -q > rec_pins_before
16 + printf "" > pins &&
17 + ipfs pin ls --type=recursive -q > rec_pins_before
18 '
19
20
21 for i in `seq 9000`
22 do
23 - test_expect_success "ipfs add (and pin) a file" '
24 - echo $i | ipfs add -q >> pins
25 - '
23 + test_expect_success "ipfs add (and pin) a file" '
24 + echo $i | ipfs add -q >> pins
25 + '
26 done
27
28 test_expect_success "get pinset afterwards" '
29 - ipfs pin ls --type=recursive -q | sort > rec_pins_after &&
30 - cat pins rec_pins_before | sort | uniq > exp_pins_after &&
31 - test_cmp rec_pins_after exp_pins_after
29 + ipfs pin ls --type=recursive -q | sort > rec_pins_after &&
30 + cat pins rec_pins_before | sort | uniq > exp_pins_after &&
31 + test_cmp rec_pins_after exp_pins_after
32 '
33
34 test_kill_ipfs_daemon