/work/auto_tests/invalid_tcp_proxy_test.c
Line | Count | Source |
1 | | // Test to make sure that when UDP is disabled, and we set an invalid proxy, |
2 | | // i.e. one that doesn't run a proxy server, then we don't get any connection. |
3 | | |
4 | | #include <stdio.h> |
5 | | |
6 | | #include "../testing/misc_tools.h" |
7 | | #include "auto_test_support.h" |
8 | | #include "check_compat.h" |
9 | | |
10 | | // Try to bootstrap for 20 seconds. |
11 | 202 | #define NUM_ITERATIONS (unsigned)(20.0 / (ITERATION_INTERVAL / 1000.0)) |
12 | | |
13 | | int main(void) |
14 | 2 | { |
15 | 2 | setvbuf(stdout, nullptr, _IONBF, 0); |
16 | | |
17 | 2 | struct Tox_Options *opts = tox_options_new(nullptr); |
18 | 2 | tox_options_set_udp_enabled(opts, false); |
19 | 2 | tox_options_set_proxy_type(opts, TOX_PROXY_TYPE_SOCKS5); |
20 | 2 | tox_options_set_proxy_host(opts, "127.0.0.1"); |
21 | 2 | tox_options_set_proxy_port(opts, 51724); |
22 | 2 | Tox *tox = tox_new_log(opts, nullptr, nullptr); |
23 | 2 | tox_options_free(opts); |
24 | | |
25 | 2 | bootstrap_tox_live_network(tox, true); |
26 | | |
27 | 2 | printf("Waiting for connection...\n"); |
28 | | |
29 | 202 | for (uint16_t i = 0; i < NUM_ITERATIONS; i++) { |
30 | 200 | tox_iterate(tox, nullptr); |
31 | 200 | c_sleep(ITERATION_INTERVAL); |
32 | | // None of the iterations should have a connection. |
33 | 200 | const Tox_Connection status = tox_self_get_connection_status(tox); |
34 | 200 | ck_assert_msg(status == TOX_CONNECTION_NONE, |
35 | 200 | "unexpectedly got a connection (%d)", status); |
36 | 200 | } |
37 | | |
38 | 2 | tox_kill(tox); |
39 | 2 | return 0; |
40 | 2 | } |