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
15 def init(ctx: Test, *options: str) -> T.Tuple[Tinc, Tinc]:
16 """Initialize new test nodes."""
17 custom = os.linesep.join(options)
18 log.info('init two nodes with options "%s"', custom)
20 foo, bar = ctx.node(), ctx.node()
44 foo.add_script(Script.SUBNET_UP)
45 bar.add_script(Script.SUBNET_UP)
50 log.info("exchange host configs")
51 cmd.exchange(foo, bar)
56 def splice(foo: Tinc, bar: Tinc, protocol: str) -> subp.Popen:
57 """Start splice between nodes."""
68 log.info("splice with args %s", args)
69 return subp.Popen(args)
72 def test_splice(ctx: Test, protocol: str, *options: str) -> None:
73 """Splice connection and check that it fails."""
74 log.info("no splicing allowed (%s)", protocol)
75 foo, bar = init(ctx, *options)
77 log.info("waiting for subnets to come up")
78 foo[Script.SUBNET_UP].wait()
79 bar[Script.SUBNET_UP].wait()
81 splice_proc = splice(foo, bar, protocol)
89 with Test("sptps") as context:
90 test_splice(context, "17.7")
92 with Test("legacy") as context:
93 test_splice(context, "17.0", "set ExperimentalProtocol no")