| 41 | |
| 42 | |
| 43 | class TTunnelLayer(tunnel.TunnelLayer): |
| 44 | def start_handshake(self) -> layer.CommandGenerator[None]: |
| 45 | yield SendData(self.tunnel_connection, b"handshake-hello") |
| 46 | |
| 47 | def receive_handshake_data( |
| 48 | self, data: bytes |
| 49 | ) -> layer.CommandGenerator[tuple[bool, str | None]]: |
| 50 | yield SendData(self.tunnel_connection, data) |
| 51 | if data == b"handshake-success": |
| 52 | return True, None |
| 53 | else: |
| 54 | return False, "handshake error" |
| 55 | |
| 56 | def send_data(self, data: bytes) -> layer.CommandGenerator[None]: |
| 57 | yield SendData(self.tunnel_connection, b"tunneled-" + data) |
| 58 | |
| 59 | def receive_data(self, data: bytes) -> layer.CommandGenerator[None]: |
| 60 | yield from self.event_to_child( |
| 61 | DataReceived(self.conn, data.replace(b"tunneled-", b"")) |
| 62 | ) |
| 63 | |
| 64 | |
| 65 | @pytest.mark.parametrize("success", ["success", "fail"]) |
no outgoing calls
searching dependent graphs…