sharness: use tabs for indent
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Sep 6, 2017 at 20:50 UTC
83f001bd968cd9abbfd2e951b8a5fda59ad4bf34
38 files changed
+1209
-1209
test/sharness/t0010-basic-commands.sh
+6
-6
@@ -17,7 +17,7 @@ test_expect_success "ipfs version succeeds" '
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" '
@@ -26,10 +26,10 @@ test_expect_success "ipfs version output looks good" '
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
@@ -79,7 +79,7 @@ test_expect_failure "All ipfs root commands are mentioned in base helptext" '
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 ||
82
+ grep " $cmd" help.txt > /dev/null ||
83
{ echo missing $cmd from helptext; echo 1 > fail; }
84
done
85
test/sharness/t0020-init.sh
+5
-5
@@ -40,14 +40,14 @@ test_expect_success "cleanup dir with bad perms" '
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
test/sharness/t0021-config.sh
+132
-132
@@ -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
@@ -42,115 +42,115 @@ test_config_cmd_set() {
42
# set it as astring instead of proper json. We leverage the
43
# unmarshalling that has to happen.
44
CONFIG_SET_JSON_TEST='{
45
- "MDNS": {
46
- "Enabled": true,
47
- "Interval": 10
48
- }
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'" '
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
- '
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
+1
-1
@@ -30,7 +30,7 @@ test_expect_success "ipfs config succeeds" '
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" '
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
+13
-13
@@ -18,12 +18,12 @@ fi
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.
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
@@ -35,22 +35,22 @@ test_expect_success "'ipfs mount' output looks good" '
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" '
@@ -58,8 +58,8 @@ test_expect_success "mount directories cannot be removed while active" '
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" '
@@ -67,7 +67,7 @@ test_expect_success "mount directories can be removed after shutdown" '
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
+13
-13
@@ -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
+240
-240
@@ -18,112 +18,112 @@ test_add_cat_file() {
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
- '
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
- '
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
- '
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 ||
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
- '
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() {
@@ -142,85 +142,85 @@ test_add_cat_raw() {
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
@@ -250,7 +250,7 @@ test_expect_success "ipfs cat succeeds with stdin opened (issue #1141)" '
250
'
251
252
test_expect_success "ipfs cat output looks good" '
253
- cat mountdir/hello.txt >expected &&
253
+ cat mountdir/hello.txt >expected &&
254
test_cmp expected actual
255
'
256
@@ -320,69 +320,69 @@ test_expect_success "ipfs cat with built input output looks good" '
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
- '
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
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
- '
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
- '
383
+ test_expect_success "cleanup" '
384
+ rm -r mountdir/planets
385
+ '
386
}
387
388
PLANETS="QmWSgS32xQEcXMeqd3YPJLrNBLSdsfYCep2U7CFkyrjXwY"
@@ -422,21 +422,21 @@ test_expect_success "'ipfs add -rn' succeeds" '
422
test_expect_success "'ipfs add -rn' output looks good" '
423
MOONS="QmVKvomp91nMih5j6hYBA8KjbiaYvEetU2Q7KvtZkLe9nQ" &&
424
EUROPA="Qmbjg7zWdqdMaK2BucPncJQDxiALExph5k3NkQv5RHpccu" &&
425
- JUPITER="QmS5mZddhFPLWFX3w6FzAy9QxyYkaxvUpsWCtZ3r7jub9J" &&
426
- SATURN="QmaMagZT4rTE7Nonw8KGSK4oe1bh533yhZrCo1HihSG8FK" &&
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 &&
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"
@@ -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
+1
-1
@@ -55,7 +55,7 @@ test_add_skip() {
55
added QmT4uMRDCN7EMpFeqwvKkboszbqeW1kWVGrBxBuCGqZcQc .vimrc
56
EOF
57
ipfs add mountdir/dotfiles/.vimrc >actual
58
- cat actual
58
+ cat actual
59
test_cmp expected actual
60
'
61
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/t0050-block.sh
+42
-42
@@ -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,45 +128,45 @@ 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" '
test/sharness/t0051-object.sh
+14
-14
@@ -61,7 +61,7 @@ test_object_cmd() {
61
'
62
63
test_expect_success "'ipfs object put file.json' succeeds" '
64
- ipfs object put ../t0051-object-data/testPut.json > actual_putOut
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" '
@@ -71,7 +71,7 @@ test_object_cmd() {
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
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" '
@@ -307,21 +307,21 @@ test_object_cmd() {
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/t0060-daemon.sh
+27
-27
@@ -14,48 +14,48 @@ 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
@@ -86,9 +86,9 @@ test_expect_success "nc is available" '
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 ||
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
@@ -106,11 +106,11 @@ test_expect_success "output looks good" '
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)" '
@@ -121,9 +121,9 @@ test_expect_success "'ipfs daemon' should be able to run with a pipe attached to
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
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/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
+24
-24
@@ -49,14 +49,14 @@ test_expect_success "'ipfs pin rm' output looks good" '
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" '
@@ -136,7 +136,7 @@ test_expect_success "pin something directly" '
136
DIRECTPIN=`ipfs add -q awesome` &&
137
echo "unpinned $DIRECTPIN" >expected9 &&
138
ipfs pin rm -r "$DIRECTPIN" >actual9 &&
139
- test_cmp expected9 actual9 &&
139
+ test_cmp expected9 actual9 &&
140
141
echo "pinned $DIRECTPIN directly" >expected10 &&
142
ipfs pin add -r=false "$DIRECTPIN" >actual10 &&
@@ -220,34 +220,34 @@ test_expect_success "'ipfs refs --unique --recursive (bigger)'" '
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" '
@@ -255,7 +255,7 @@ test_expect_success "repo version came out correct" '
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
test/sharness/t0081-repo-pinning.sh
+33
-33
@@ -17,13 +17,13 @@ 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
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
24
+ test "$expect" = "false" && return
25
+ test_fsh cat actual
26
+ return
27
fi
28
}
29
@@ -41,8 +41,8 @@ test_pin() {
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
44
+ test_pin_flag "$object" "indirect" $i || return 1
45
+ test_pin_flag "$object" "direct" $d || return 1
46
return 0
47
}
48
@@ -108,10 +108,10 @@ test_expect_success "objects are there" '
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
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
@@ -152,16 +152,16 @@ test_expect_success "'ipfs repo gc' succeeds" '
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 &&
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 &&
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
@@ -178,27 +178,27 @@ test_expect_success "none are pinned any more" '
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" &&
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 &&
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 &&
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 &&
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 &&
@@ -220,12 +220,12 @@ test_expect_success "'ipfs repo gc' succeeds" '
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 &&
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 &&
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
'
@@ -275,9 +275,9 @@ test_expect_success "test add nopin dir" '
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
+58
-58
@@ -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,9 +64,9 @@ 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" '
@@ -75,45 +75,45 @@ test_expect_success "'ipfs repo fsck' output looks good with no daemon" '
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/t0090-get.sh
+11
-11
@@ -11,20 +11,20 @@ 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="$@"
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
- '
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" '
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" '
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" &&
@@ -78,11 +78,11 @@ test_get_cmd() {
78
test_cmp "$HASH2" data
79
'
80
81
- test_ipfs_get_flag ".tar" "-xf" -a
81
+ test_ipfs_get_flag ".tar" "-xf" -a
82
83
- test_ipfs_get_flag ".tar.gz" "-zxf" -a -C
83
+ test_ipfs_get_flag ".tar.gz" "-zxf" -a -C
84
85
- test_ipfs_get_flag ".tar.gz" "-zxf" -a -C -l 9
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 &&
test/sharness/t0100-name.sh
+3
-3
@@ -55,9 +55,9 @@ test_expect_success "resolve output looks good" '
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
test/sharness/t0110-gateway.sh
+33
-33
@@ -22,65 +22,65 @@ 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) ||
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" '
@@ -124,35 +124,35 @@ test_expect_success "HEAD 'index.html' has no content" '
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
+108
-108
@@ -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" '
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
- '
139
+ '
140
141
- test_expect_success "output looks good" '
141
+ test_expect_success "output looks good" '
142
test_cmp add_stdin_actual bpeers
143
- '
143
+ '
144
145
- test_bootstrap_list_cmd $BP1 $BP2 $BP3 $BP4
145
+ test_bootstrap_list_cmd $BP1 $BP2 $BP3 $BP4
146
147
- test_expect_success "'ipfs bootstrap rm' accepts args from stdin" '
147
+ test_expect_success "'ipfs bootstrap rm' accepts args from stdin" '
148
cat bpeers | ipfs bootstrap rm > rm_stdin_actual
149
- '
149
+ '
150
151
- test_expect_success "output looks good" '
151
+ test_expect_success "output looks good" '
152
test_cmp rm_stdin_actual bpeers
153
- '
153
+ '
154
155
- test_bootstrap_list_cmd
155
+ test_bootstrap_list_cmd
156
}
157
158
# should work offline
test/sharness/t0121-bootstrap-iptb.sh
+3
-3
@@ -22,15 +22,15 @@ test_expect_success "setup iptb nodes" '
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() {
test/sharness/t0140-swarm.sh
+7
-7
@@ -51,7 +51,7 @@ 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
@@ -67,32 +67,32 @@ 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 &&
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
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 &&
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
95
+ grep -v "/ip4/1.2.3.4/tcp/1234" actual
96
'
97
98
test_kill_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/t0170-dht.sh
+17
-17
@@ -7,27 +7,27 @@ 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 ] ||
29
+ ipfsi 1 dht put planet pluto | sort >putted &&
30
+ [ -s putted ] ||
31
test_fsh cat putted
32
'
33
@@ -45,9 +45,9 @@ test_expect_success 'findprovs' '
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 ||
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
@@ -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 ] ||
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
+4
-4
@@ -7,14 +7,14 @@ 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
@@ -58,7 +58,7 @@ test_expect_success "wait until echo > wait executed" '
58
'
59
60
test_expect_success 'stop iptb' '
61
- iptb stop
61
+ iptb stop
62
'
63
64
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/t0230-channel-streaming-http-content-type.sh
+2
-2
@@ -16,7 +16,7 @@ test_ls_cmd() {
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
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" '
@@ -39,7 +39,7 @@ test_ls_cmd() {
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
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" '
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/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/t0600-issues-and-regressions-online.sh
+2
-2
@@ -47,8 +47,8 @@ test_expect_success "pin add api looks right - #3753" '
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