This repository has been archived by the owner on Apr 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
t0130-multinode.sh
executable file
·112 lines (84 loc) · 2.09 KB
/
t0130-multinode.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
#
# Copyright (c) 2015 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#
test_description="Test multiple ipfs nodes"
. lib/test-lib.sh
check_file_fetch() {
node=$1
fhash=$2
fname=$3
test_expect_success "can fetch file" '
ipfsi $node cat $fhash > fetch_out
'
test_expect_success "file looks good" '
test_cmp $fname fetch_out
'
}
check_dir_fetch() {
node=$1
ref=$2
test_expect_success "node can fetch all refs for dir" '
ipfsi $node refs -r $ref > /dev/null
'
}
run_single_file_test() {
test_expect_success "add a file on node1" '
random 1000000 > filea &&
FILEA_HASH=$(ipfsi 1 add -q filea)
'
check_file_fetch 4 $FILEA_HASH filea
check_file_fetch 3 $FILEA_HASH filea
check_file_fetch 2 $FILEA_HASH filea
check_file_fetch 1 $FILEA_HASH filea
check_file_fetch 0 $FILEA_HASH filea
}
run_random_dir_test() {
test_expect_success "create a bunch of random files" '
random-files -depth=4 -dirs=5 -files=8 foobar > /dev/null
'
test_expect_success "add those on node 2" '
DIR_HASH=$(ipfsi 2 add -r -q foobar | tail -n1)
'
check_dir_fetch 0 $DIR_HASH
check_dir_fetch 1 $DIR_HASH
check_dir_fetch 2 $DIR_HASH
check_dir_fetch 3 $DIR_HASH
check_dir_fetch 4 $DIR_HASH
}
run_basic_test() {
startup_cluster 5
run_single_file_test
test_expect_success "shut down nodes" '
iptb stop
'
}
run_advanced_test() {
startup_cluster 5 "$@"
run_single_file_test
run_random_dir_test
test_expect_success "shut down nodes" '
iptb stop ||
test_fsh tail -n +1 .iptb/*/daemon.std*
'
}
test_expect_success "set up /tcp testbed" '
iptb init -n 5 -p 0 -f --bootstrap=none
'
# test multiplex muxer
export LIBP2P_MUX_PREFS="/mplex/6.7.0"
run_advanced_test
unset LIBP2P_MUX_PREFS
# test default configuration
run_advanced_test
test_expect_success "set up /ws testbed" '
iptb init -n 5 -ws -p 0 -f --bootstrap=none
'
# test multiplex muxer
export LIBP2P_MUX_PREFS="/mplex/6.7.0"
run_advanced_test "--enable-mplex-experiment"
unset LIBP2P_MUX_PREFS
# test default configuration
run_advanced_test
test_done