File tree 1 file changed +47
-0
lines changed 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ #
3
+ # Copyright (c) 2016 Jeromy Johnson
4
+ # MIT Licensed; see the LICENSE file in this repository.
5
+ #
6
+
7
+ test_description=" Test ipfs repo fsck"
8
+
9
+ . lib/test-lib.sh
10
+
11
+ test_init_ipfs
12
+
13
+ check_random_corruption () {
14
+ to_break=$( find " $IPFS_PATH /blocks" -type f | sort -R | head -n 1)
15
+
16
+ test_expect_success " back up file and overwrite it" '
17
+ cp "$to_break" backup_file &&
18
+ echo "this is super broken" > "$to_break"
19
+ '
20
+
21
+ test_expect_success " repo verify detects failure" '
22
+ test_expect_code 1 ipfs repo verify
23
+ '
24
+
25
+ test_expect_success " replace the object" '
26
+ cp backup_file "$to_break"
27
+ '
28
+
29
+ test_expect_success " ipfs repo verify passes just fine now" '
30
+ ipfs repo verify
31
+ '
32
+ }
33
+
34
+ test_expect_success " create some files" '
35
+ random-files -depth=3 -dirs=4 -files=10 foobar > /dev/null
36
+ '
37
+
38
+ test_expect_success " add them all" '
39
+ ipfs add -r -q foobar > /dev/null
40
+ '
41
+
42
+ for i in ` seq 20`
43
+ do
44
+ check_random_corruption
45
+ done
46
+
47
+ test_done
You can’t perform that action at this time.
0 commit comments