Rewrite the test suite for better compat and stability
[tinc] / test / legacy-protocol.test
1 #!/bin/sh
2
3 # shellcheck source=testlib.sh
4 . "${0%/*}/testlib.sh"
5
6 echo [STEP] Initialize two nodes
7
8 tinc foo <<EOF
9 init foo
10 set DeviceType dummy
11 set Port 30060
12 set Address localhost
13 add Subnet 10.98.98.1
14 set PingTimeout 2
15 EOF
16
17 tinc bar <<EOF
18 init bar
19 set DeviceType dummy
20 set Port 0
21 add Subnet 10.98.98.2
22 set PingTimeout 2
23 set MaxTimeout 2
24 EOF
25
26 echo [STEP] Exchange host config files
27
28 tinc foo export | tinc bar exchange | tinc foo import
29 tinc bar add ConnectTo foo
30
31 echo [STEP] Foo 1.1, bar 1.0
32
33 tinc bar set ExperimentalProtocol no
34 tinc foo del bar.Ed25519PublicKey
35 tinc bar del foo.Ed25519PublicKey
36
37 create_script foo hosts/bar-up
38 create_script bar hosts/foo-up
39
40 start_tinc foo
41 start_tinc bar
42
43 wait_script foo hosts/bar-up
44 wait_script bar hosts/foo-up
45
46 require_nodes foo 2
47 require_nodes bar 2
48
49 tinc bar stop
50 tinc foo stop
51
52 test -z "$(tinc foo get bar.Ed25519PublicKey)"
53 test -z "$(tinc bar get foo.Ed25519PublicKey)"
54
55 echo [STEP] Foo 1.1, bar upgrades to 1.1
56
57 tinc bar del ExperimentalProtocol
58
59 start_tinc foo
60 start_tinc bar
61
62 wait_script foo hosts/bar-up
63 wait_script bar hosts/foo-up
64
65 require_nodes foo 2
66 require_nodes bar 2
67
68 tinc bar stop
69 tinc foo stop
70
71 test -n "$(tinc foo get bar.Ed25519PublicKey)"
72 test -n "$(tinc bar get foo.Ed25519PublicKey)"
73
74 echo [STEP] Bar downgrades, must no longer be allowed to connect
75
76 tinc bar set ExperimentalProtocol no
77
78 create_script foo subnet-up
79 start_tinc foo
80 wait_script foo subnet-up
81
82 create_script bar subnet-up
83 start_tinc bar
84 wait_script bar subnet-up
85
86 # There is no reliable way to wait for 'not connecting'.
87 sleep 10
88
89 require_nodes foo 1
90 require_nodes bar 1