This repository includes a test suite to verify the functionality of the MTProxy server. The tests run in Docker or directly on the host and check:
- HTTP Stats: Verifies the stats endpoint (port 8888) is accessible.
- Prometheus Metrics: Verifies the
/metricsendpoint returns valid Prometheus exposition format. - MTProto Port: Verifies the MTProto port accepts TCP connections.
- Docker and Docker Compose (for containerized testing)
make(for running the test command)- Python 3.9+ (for local script execution without Docker)
Simply run:
make testThis will:
- Build the MTProxy Docker image.
- Build the test runner Docker image.
- Start the proxy and test runner.
- Execute the connectivity checks.
A random secret will be generated automatically if MTPROXY_SECRET is not set.
If you want to run the tests against a local instance:
- Install Python dependencies:
pip install -r tests/requirements.txt
- Set environment variables:
export MTPROXY_HOST=localhost # or IP of your proxy export MTPROXY_PORT=443 # or your proxy port
- Run the script:
python3 tests/test_proxy.py
If tests are failing, you can manually verify connectivity to Telegram servers:
# Check connectivity to Telegram DC 2 (Europe)
nc -zv 149.154.167.50 443
# Expected output: Connection to 149.154.167.50 443 port [tcp/https] succeeded!If this fails, your network (ISP, firewall, or hosting provider) is blocking connections to Telegram.
The fuzz/ directory contains libFuzzer harnesses for protocol parsers, compiled with AddressSanitizer and UndefinedBehaviorSanitizer.
| Harness | Parser | What it tests |
|---|---|---|
fuzz_tls_server_hello |
tls_check_server_hello() |
Extension parsing, length validation, record counting |
fuzz_tls_client_hello |
tls_parse_sni() + tls_parse_client_hello_ciphers() |
SNI extraction, cipher suite GREASE skipping |
fuzz_http_request |
http_parse_data() |
HTTP state machine, header limits, Content-Length overflow |
Requires Clang (for -fsanitize=fuzzer):
# Build fuzz targets
make fuzz CC=clang
# Run all targets for 60 seconds each (default)
make fuzz-run
# Custom duration
make fuzz-run FUZZ_DURATION=300Seed corpus files are in fuzz/corpus/. The fuzzers also run automatically in CI on every push and PR.
- Timeout: If tests time out, check your network connection. MTProto proxies may be blocked by some ISPs.
- Port already in use: The tests use ports 18443 and 18888 by default. Make sure these are available.