test/sharness: circuit relay test
License: MIT Signed-off-by: vyzo <vyzo@hackzen.org>
vyzo committed
Jul 28, 2017 at 12:10 UTC
1f40c5210d572f32ffa2e04cc5356ee3175a7569
1 file changed
+70
test/sharness/t0182-circuit-relay.sh
new
+70
@@ -0,0 +1,70 @@
1
+#!/bin/sh
2
+
3
+test_description="Test circuit relay"
4
+
5
+. lib/test-lib.sh
6
+
7
+# start iptb + wait for peering
8
+NUM_NODES=3
9
+test_expect_success 'init iptb' '
10
+ iptb init -n $NUM_NODES --bootstrap=none --port=0
11
+'
12
+
13
+# Network toplogy: A <-> Relay <-> B
14
+test_expect_success 'start up nodes for configuration' '
15
+ iptb start --args --routing=none
16
+'
17
+
18
+test_expect_success 'configure EnableRelayHop in relay node' '
19
+ ipfsi 1 config --json Swarm.EnableRelayHop true
20
+'
21
+
22
+test_expect_success 'restart nodes' '
23
+ iptb stop &&
24
+ iptb start --args --routing=none
25
+'
26
+
27
+test_expect_success 'connect A <-> Relay' '
28
+ iptb connect 0 1
29
+'
30
+
31
+test_expect_success 'connect B <-> Relay' '
32
+ iptb connect 2 1
33
+'
34
+
35
+test_expect_success 'wait until relay is ready to do work' '
36
+ sleep 1
37
+'
38
+
39
+test_expect_success 'peer ids' '
40
+ PEERID_0=$(iptb get id 0) &&
41
+ PEERID_1=$(iptb get id 1) &&
42
+ PEERID_2=$(iptb get id 2)
43
+'
44
+
45
+test_expect_success 'connect A <-Relay-> B' '
46
+ ipfsi 0 swarm connect /p2p-circuit/ipfs/$PEERID_2 > peers_out
47
+'
48
+
49
+test_expect_success 'output looks good' '
50
+ echo "connect $PEERID_2 success" > peers_exp &&
51
+ test_cmp peers_exp peers_out
52
+'
53
+
54
+test_expect_success 'peers for A look good' '
55
+ ipfsi 0 swarm peers | grep p2p-circuit > peers_out &&
56
+ echo "/ipfs/$PEERID_1/p2p-circuit/ipfs/$PEERID_2" > peers_exp &&
57
+ test_cmp peers_exp peers_out
58
+'
59
+
60
+test_expect_success 'peers for B look good' '
61
+ ipfsi 2 swarm peers | grep p2p-circuit > peers_out &&
62
+ echo "/ipfs/$PEERID_1/p2p-circuit/ipfs/$PEERID_0" > peers_exp &&
63
+ test_cmp peers_exp peers_out
64
+'
65
+
66
+test_expect_success 'stop iptb' '
67
+ iptb stop
68
+'
69
+
70
+test_done