"""Tests for protocol helpers.""" from s5p.proto import Socks5AddrType, encode_address class TestEncodeAddress: """Test SOCKS5 address encoding.""" def test_ipv4(self): atyp, data = encode_address("127.0.0.1") assert atyp == Socks5AddrType.IPV4 assert data == b"\x7f\x00\x00\x01" def test_ipv6(self): atyp, data = encode_address("::1") assert atyp == Socks5AddrType.IPV6 assert len(data) == 16 def test_domain(self): atyp, data = encode_address("example.com") assert atyp == Socks5AddrType.DOMAIN assert data == bytes([11]) + b"example.com"