@cryptotaxi247 / kubo / commits / d0dd22b7d

sharness/t0120-bootstrap: test the bootstrap cmd

and do it both online + offline

Juan Batiz-Benet committed Feb 1, 2015 at 06:07 UTC d0dd22b7d435416b84c70c3c563344266f6d39f1
1 file changed +131
test/sharness/t0120-bootstrap.sh new
+131
@@ -0,0 +1,131 @@
1 +#!/bin/sh
2 +#
3 +# Copyright (c) 2014 Jeromy Johnson
4 +# MIT Licensed; see the LICENSE file in this repository.
5 +#
6 +
7 +# changing the bootstrap peers will require changing it in two places :)
8 +BP1="/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
9 +BP2="/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx"
10 +BP3="/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z"
11 +BP4="/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLpPVmHKQ4XTPdz8tjDFgdeRFkpV8JgYq8JVJ69RrZm"
12 +BP5="/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64"
13 +BP6="/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu"
14 +BP7="/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm"
15 +BP8="/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd"
16 +BP9="/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3"
17 +
18 +test_description="Test ipfs repo operations"
19 +
20 +. lib/test-lib.sh
21 +
22 +test_init_ipfs
23 +
24 +# we use a function so that we can run it both offline + online
25 +test_bootstrap_list_cmd() {
26 + printf "" >list_expected
27 + for BP in "$@"
28 + do
29 + echo "$BP" >>list_expected
30 + done
31 +
32 + test_expect_success "'ipfs bootstrap' succeeds" '
33 + ipfs bootstrap >list_actual
34 + '
35 +
36 + test_expect_success "'ipfs bootstrap' output looks good" '
37 + test_cmp list_actual list_expected
38 + '
39 +
40 + test_expect_success "'ipfs bootstrap list' succeeds" '
41 + ipfs bootstrap list >list2_actual
42 + '
43 +
44 + test_expect_success "'ipfs bootstrap list' output looks good" '
45 + test_cmp list2_actual list_expected
46 + '
47 +}
48 +
49 +# we use a function so that we can run it both offline + online
50 +test_bootstrap_cmd() {
51 +
52 + # remove all peers just in case.
53 + # if this fails, the first listing may not be empty
54 + ipfs bootstrap rm --all
55 +
56 + test_bootstrap_list_cmd
57 +
58 + test_expect_success "'ipfs bootstrap add' succeeds" '
59 + ipfs bootstrap add "$BP1" "$BP2" "$BP3" >add_actual
60 + '
61 +
62 + test_expect_success "'ipfs bootstrap add' output looks good" '
63 + echo $BP1 >add_expected
64 + echo $BP2 >>add_expected
65 + echo $BP3 >>add_expected
66 + test_cmp add_actual add_expected
67 + '
68 +
69 + test_bootstrap_list_cmd $BP1 $BP2 $BP3
70 +
71 + test_expect_success "'ipfs bootstrap rm' succeeds" '
72 + ipfs bootstrap rm "$BP1" "$BP3" >rm_actual
73 + '
74 +
75 + test_expect_success "'ipfs bootstrap rm' output looks good" '
76 + echo $BP1 >rm_expected
77 + echo $BP3 >>rm_expected
78 + test_cmp rm_actual rm_expected
79 + '
80 +
81 + test_bootstrap_list_cmd $BP2
82 +
83 + test_expect_success "'ipfs bootstrap add --default' succeeds" '
84 + ipfs bootstrap add --default >add2_actual
85 + '
86 +
87 + test_expect_success "'ipfs bootstrap add --default' output has default BP" '
88 + echo $BP1 >add2_expected
89 + echo $BP2 >>add2_expected
90 + echo $BP3 >>add2_expected
91 + echo $BP4 >>add2_expected
92 + echo $BP5 >>add2_expected
93 + echo $BP6 >>add2_expected
94 + echo $BP7 >>add2_expected
95 + echo $BP8 >>add2_expected
96 + echo $BP9 >>add2_expected
97 + test_cmp add2_actual add2_expected
98 + '
99 +
100 + test_bootstrap_list_cmd $BP1 $BP2 $BP3 $BP4 $BP5 $BP6 $BP7 $BP8 $BP9
101 +
102 + test_expect_success "'ipfs bootstrap rm --all' succeeds" '
103 + ipfs bootstrap rm --all >rm2_actual
104 + '
105 +
106 + test_expect_success "'ipfs bootstrap rm' output looks good" '
107 + echo $BP1 >rm2_expected
108 + echo $BP2 >>rm2_expected
109 + echo $BP3 >>rm2_expected
110 + echo $BP4 >>rm2_expected
111 + echo $BP5 >>rm2_expected
112 + echo $BP6 >>rm2_expected
113 + echo $BP7 >>rm2_expected
114 + echo $BP8 >>rm2_expected
115 + echo $BP9 >>rm2_expected
116 + test_cmp rm2_actual rm2_expected
117 + '
118 +
119 + test_bootstrap_list_cmd
120 +}
121 +
122 +# should work offline
123 +test_bootstrap_cmd
124 +
125 +# should work online
126 +test_launch_ipfs_daemon
127 +test_bootstrap_cmd
128 +test_kill_ipfs_daemon
129 +
130 +
131 +test_done