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