Add test cases for urlstore.
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
Kevin Atkinson committed
Jun 26, 2018 at 00:35 UTC
90972095a9ca0ea2f6ab6580b28bc5ac635596a2
1 file changed
+69
test/sharness/t0272-urlstore.sh
new
+69
@@ -0,0 +1,69 @@
1
+#!/usr/bin/env bash
2
+#
3
+# Copyright (c) 2017 Jeromy Johnson
4
+# MIT Licensed; see the LICENSE file in this repository.
5
+#
6
+
7
+test_description="Test out the urlstore functionality"
8
+
9
+. lib/test-lib.sh
10
+
11
+test_init_ipfs
12
+
13
+test_expect_success "enable urlstore" '
14
+ ipfs config --json Experimental.UrlstoreEnabled true
15
+'
16
+
17
+test_expect_success "create some random files" '
18
+ random 2222 7 > file1 &&
19
+ random 50000000 7 > file2
20
+'
21
+
22
+test_expect_success "add files using trickle dag format without raw leaves" '
23
+ HASH1a=$(ipfs add -q --trickle --raw-leaves=false file1) &&
24
+ HASH2a=$(ipfs add -q --trickle --raw-leaves=false file2)
25
+'
26
+test_launch_ipfs_daemon --offline
27
+
28
+test_expect_success "make sure files can be retrived via the gateway" '
29
+ curl http://127.0.0.1:$GWAY_PORT/ipfs/$HASH1a -o file1.actual &&
30
+ test_cmp file1 file1.actual &&
31
+ curl http://127.0.0.1:$GWAY_PORT/ipfs/$HASH2a -o file2.actual &&
32
+ test_cmp file2 file2.actual
33
+'
34
+
35
+test_expect_success "add files using gateway address via url store" '
36
+ 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)
38
+'
39
+
40
+test_expect_success "make sure hashes are different" '
41
+ echo $HASH1a $HASH1
42
+ echo $HASH2a $HASH2
43
+'
44
+
45
+test_expect_success "get files via urlstore" '
46
+ ipfs get $HASH1 -o file1.actual &&
47
+ test_cmp file1 file1.actual &&
48
+ ipfs get $HASH2 -o file2.actual &&
49
+ test_cmp file2 file2.actual
50
+'
51
+
52
+test_expect_success "remove original hashes from local gateway" '
53
+ ipfs pin rm $HASH1a $HASH2a &&
54
+ ipfs repo gc
55
+'
56
+
57
+test_expect_success "gatway no longer has files" '
58
+ test_must_fail curl -f http://127.0.0.1:$GWAY_PORT/ipfs/$HASH1a -o file1.actual
59
+ test_must_fail curl -f http://127.0.0.1:$GWAY_PORT/ipfs/$HASH2a -o file2.actual
60
+'
61
+
62
+test_expect_success "files can not be retrieved via the urlstore" '
63
+ test_must_fail ipfs get $HASH1
64
+ test_must_fail ipfs get $HASH2
65
+'
66
+
67
+test_kill_ipfs_daemon
68
+
69
+test_done