Enhance tests.
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
Kevin Atkinson committed
Jun 26, 2018 at 15:44 UTC
b3457f240cc1d4d9e0e9399303ae7cfbd6905727
1 file changed
+62
-9
test/sharness/t0272-urlstore.sh
+62
-9
@@ -16,12 +16,14 @@ test_expect_success "enable urlstore" '
16
17
test_expect_success "create some random files" '
18
random 2222 7 > file1 &&
19
- random 50000000 7 > file2
19
+ random 500000 7 > file2 &&
20
+ random 50000000 7 > file3
21
'
22
23
test_expect_success "add files using trickle dag format without raw leaves" '
24
HASH1a=$(ipfs add -q --trickle --raw-leaves=false file1) &&
24
- HASH2a=$(ipfs add -q --trickle --raw-leaves=false file2)
25
+ HASH2a=$(ipfs add -q --trickle --raw-leaves=false file2) &&
26
+ HASH3a=$(ipfs add -q --trickle --raw-leaves=false file3)
27
'
28
test_launch_ipfs_daemon --offline
29
@@ -29,17 +31,20 @@ test_expect_success "make sure files can be retrived via the gateway" '
31
curl http://127.0.0.1:$GWAY_PORT/ipfs/$HASH1a -o file1.actual &&
32
test_cmp file1 file1.actual &&
33
curl http://127.0.0.1:$GWAY_PORT/ipfs/$HASH2a -o file2.actual &&
32
- test_cmp file2 file2.actual
34
+ test_cmp file2 file2.actual &&
35
+ curl http://127.0.0.1:$GWAY_PORT/ipfs/$HASH3a -o file3.actual &&
36
+ test_cmp file3 file3.actual
37
'
38
39
test_expect_success "add files using gateway address via url store" '
40
HASH1=$(ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH1a) &&
37
- HASH2=$(ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH2a)
41
+ HASH2=$(ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH2a) &&
42
+ ipfs pin add $HASH1 $HASH2
43
'
44
45
test_expect_success "make sure hashes are different" '
41
- echo $HASH1a $HASH1
42
- echo $HASH2a $HASH2
46
+ echo $HASH1a $HASH1 ## FIXME
47
+ echo $HASH2a $HASH2 ## FIXME
48
'
49
50
test_expect_success "get files via urlstore" '
@@ -49,9 +54,31 @@ test_expect_success "get files via urlstore" '
54
test_cmp file2 file2.actual
55
'
56
57
+cat <<EOF | sort > ls_expect
58
+zb2rhX1q5oFFzEkPNsTe1Y8osUdFqSQGjUWRZsqC9fbY6WVSk 262144 http://127.0.0.1:$GWAY_PORT/ipfs/QmUow2T4P69nEsqTQDZCt8yg9CPS8GFmpuDAr5YtsPhTdM 0
59
+zb2rhYbKFn1UWGHXaAitcdVTkDGTykX8RFpGWzRFuLpoe9VE4 237856 http://127.0.0.1:$GWAY_PORT/ipfs/QmUow2T4P69nEsqTQDZCt8yg9CPS8GFmpuDAr5YtsPhTdM 262144
60
+zb2rhjddJ5DNzBrFu8G6CP1ApY25BukwCeskXHzN1H18CiVVZ 2222 http://127.0.0.1:$GWAY_PORT/ipfs/QmcHm3BL2cXuQ6rJdKQgPrmT9suqGkfy2KzH3MkXPEBXU6 0
61
+EOF
62
+
63
+test_expect_success "ipfs filestore ls works with urls" '
64
+ ipfs filestore ls | sort > ls_actual &&
65
+ test_cmp ls_expect ls_actual
66
+'
67
+
68
+cat <<EOF | sort > verify_expect
69
+ok zb2rhX1q5oFFzEkPNsTe1Y8osUdFqSQGjUWRZsqC9fbY6WVSk 262144 http://127.0.0.1:$GWAY_PORT/ipfs/QmUow2T4P69nEsqTQDZCt8yg9CPS8GFmpuDAr5YtsPhTdM 0
70
+ok zb2rhYbKFn1UWGHXaAitcdVTkDGTykX8RFpGWzRFuLpoe9VE4 237856 http://127.0.0.1:$GWAY_PORT/ipfs/QmUow2T4P69nEsqTQDZCt8yg9CPS8GFmpuDAr5YtsPhTdM 262144
71
+ok zb2rhjddJ5DNzBrFu8G6CP1ApY25BukwCeskXHzN1H18CiVVZ 2222 http://127.0.0.1:$GWAY_PORT/ipfs/QmcHm3BL2cXuQ6rJdKQgPrmT9suqGkfy2KzH3MkXPEBXU6 0
72
+EOF
73
+
74
+test_expect_success "ipfs filestore verify works with urls" '
75
+ ipfs filestore verify | sort > verify_actual &&
76
+ test_cmp verify_expect verify_actual
77
+'
78
+
79
test_expect_success "remove original hashes from local gateway" '
80
ipfs pin rm $HASH1a $HASH2a &&
54
- ipfs repo gc
81
+ ipfs repo gc > /dev/null
82
'
83
84
test_expect_success "gatway no longer has files" '
@@ -59,11 +86,37 @@ test_expect_success "gatway no longer has files" '
86
test_must_fail curl -f http://127.0.0.1:$GWAY_PORT/ipfs/$HASH2a -o file2.actual
87
'
88
62
-test_expect_success "files can not be retrieved via the urlstore" '
63
- test_must_fail ipfs get $HASH1
89
+cat <<EOF | sort > verify_expect_2
90
+error zb2rhX1q5oFFzEkPNsTe1Y8osUdFqSQGjUWRZsqC9fbY6WVSk 262144 http://127.0.0.1:$GWAY_PORT/ipfs/QmUow2T4P69nEsqTQDZCt8yg9CPS8GFmpuDAr5YtsPhTdM 0
91
+error zb2rhYbKFn1UWGHXaAitcdVTkDGTykX8RFpGWzRFuLpoe9VE4 237856 http://127.0.0.1:$GWAY_PORT/ipfs/QmUow2T4P69nEsqTQDZCt8yg9CPS8GFmpuDAr5YtsPhTdM 262144
92
+error zb2rhjddJ5DNzBrFu8G6CP1ApY25BukwCeskXHzN1H18CiVVZ 2222 http://127.0.0.1:$GWAY_PORT/ipfs/QmcHm3BL2cXuQ6rJdKQgPrmT9suqGkfy2KzH3MkXPEBXU6 0
93
+EOF
94
+
95
+test_expect_success "ipfs filestore verify is correct" '
96
+ ipfs filestore verify | sort > verify_actual_2 &&
97
+ test_cmp verify_expect_2 verify_actual_2
98
+'
99
+
100
+test_expect_failure "files can not be retrieved via the urlstore" '
101
+ test_must_fail ipfs get $HASH1 &&
102
test_must_fail ipfs get $HASH2
103
'
104
105
+test_expect_success "add large file using gateway address via url store" '
106
+ HASH3=$(ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH3a)
107
+'
108
+
109
+test_expect_success "get large file via urlstore" '
110
+ ipfs get $HASH3 -o file3.actual &&
111
+ test_cmp file3 file3.actual
112
+'
113
+
114
test_kill_ipfs_daemon
115
116
+test_expect_success "files can not be retrieved via the urlstore" '
117
+ test_must_fail ipfs get $HASH1 &&
118
+ test_must_fail ipfs get $HASH2 &&
119
+ test_must_fail ipfs get $HASH3
120
+'
121
+
122
test_done