Skip the legacy protocol test if that protocol is disabled.
[tinc] / test / legacy-protocol.test
1 #!/bin/sh
2
3 # Skip this test if the legacy protocol is disabled
4 if grep -q "define DISABLE_LEGACY 1" "${0%/*}/../config.h"; then
5         exit 77
6 fi
7
8 . "${0%/*}/testlib.sh"
9
10 # Initialize two nodes
11
12 $tinc $c1 <<EOF
13 init foo
14 set DeviceType dummy
15 set Port 32753
16 set Address localhost
17 set PingTimeout 1
18 EOF
19
20 $tinc $c2 <<EOF
21 init bar
22 set DeviceType dummy
23 set Port 0
24 set PingTimeout 1
25 set MaxTimeout 1
26 EOF
27
28 # Exchange host config files
29
30 $tinc $c1 export | $tinc $c2 exchange | $tinc $c1 import
31 $tinc $c2 add ConnectTo foo
32
33 # Foo 1.1, bar 1.0
34
35 $tinc $c2 set ExperimentalProtocol no
36 $tinc $c1 del bar.Ed25519PublicKey
37 $tinc $c2 del foo.Ed25519PublicKey
38
39 $tinc $c1 start $r1
40 $tinc $c2 start $r2
41
42 sleep 1
43
44 test `$tinc $c1 dump reachable nodes | wc -l` = 2
45 test `$tinc $c2 dump reachable nodes | wc -l` = 2
46
47 $tinc $c2 stop
48 $tinc $c1 stop
49
50 test -z "`$tinc $c1 get bar.Ed25519PublicKey`"
51 test -z "`$tinc $c2 get foo.Ed25519PublicKey`"
52
53 # Foo 1.1, bar upgrades to 1.1
54
55 $tinc $c2 del ExperimentalProtocol
56
57 $tinc $c1 start $r1
58 $tinc $c2 start $r2
59
60 sleep 5
61
62 test `$tinc $c1 dump reachable nodes | wc -l` = 2
63 test `$tinc $c2 dump reachable nodes | wc -l` = 2
64
65 $tinc $c2 stop
66 $tinc $c1 stop
67
68 test -n "`$tinc $c1 get bar.Ed25519PublicKey`"
69 test -n "`$tinc $c2 get foo.Ed25519PublicKey`"
70
71 # Bar downgrades, must no longer be allowed to connect
72
73 $tinc $c2 set ExperimentalProtocol no
74
75 $tinc $c1 start $r1
76 $tinc $c2 start $r2
77
78 sleep 1
79
80 test `$tinc $c1 dump reachable nodes | wc -l` = 1
81 test `$tinc $c2 dump reachable nodes | wc -l` = 1
82
83 $tinc $c2 stop
84 $tinc $c1 stop