3 """Test splicing connection between tinc peers."""
6 import subprocess as subp
9 from testlib import check, cmd, path
10 from testlib.log import log
11 from testlib.proc import Tinc, Script
12 from testlib.test import Test
13 from testlib.feature import SANDBOX_LEVEL
16 def init(ctx: Test, *options: str) -> T.Tuple[Tinc, Tinc]:
17 """Initialize new test nodes."""
18 custom = os.linesep.join(options)
19 log.info('init two nodes with options "%s"', custom)
21 foo, bar = ctx.node(), ctx.node()
30 set Sandbox {SANDBOX_LEVEL}
42 set Sandbox {SANDBOX_LEVEL}
47 foo.add_script(Script.SUBNET_UP)
48 bar.add_script(Script.SUBNET_UP)
53 log.info("exchange host configs")
54 cmd.exchange(foo, bar)
59 def splice(foo: Tinc, bar: Tinc, protocol: str) -> subp.Popen:
60 """Start splice between nodes."""
71 log.info("splice with args %s", args)
72 return subp.Popen(args)
75 def test_splice(ctx: Test, protocol: str, *options: str) -> None:
76 """Splice connection and check that it fails."""
77 log.info("no splicing allowed (%s)", protocol)
78 foo, bar = init(ctx, *options)
80 log.info("waiting for subnets to come up")
81 foo[Script.SUBNET_UP].wait()
82 bar[Script.SUBNET_UP].wait()
84 splice_proc = splice(foo, bar, protocol)
92 with Test("sptps") as context:
93 test_splice(context, "17.7")
95 with Test("legacy") as context:
96 test_splice(context, "17.0", "set ExperimentalProtocol no")