summaryrefslogtreecommitdiff
path: root/auto_tests/invalid_proxy_test.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-06-23 11:40:20 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-06-23 12:34:33 +0000
commita48e0c4d1892eebf356108504c0b7fe6c0175b5e (patch)
treed901ec9b5def9f900d67a5ec449d22bd78ce29b4 /auto_tests/invalid_proxy_test.c
parent36e20e7e94760b48bee4894cced30814d72c1938 (diff)
Add tests for what happens when passing an invalid proxy host.
Related: https://github.com/qTox/qTox/issues/5174
Diffstat (limited to 'auto_tests/invalid_proxy_test.c')
-rw-r--r--auto_tests/invalid_proxy_test.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/auto_tests/invalid_proxy_test.c b/auto_tests/invalid_proxy_test.c
new file mode 100644
index 00000000..518ae55f
--- /dev/null
+++ b/auto_tests/invalid_proxy_test.c
@@ -0,0 +1,46 @@
1// Test that if UDP is enabled, and an invalid proxy is provided, then we get a
2// UDP connection only.
3#ifndef _XOPEN_SOURCE
4#define _XOPEN_SOURCE 600
5#endif
6
7#include "helpers.h"
8
9static uint8_t const key[] = {
10 0x15, 0xE9, 0xC3, 0x09, 0xCF, 0xCB, 0x79, 0xFD,
11 0xDF, 0x0E, 0xBA, 0x05, 0x7D, 0xAB, 0xB4, 0x9F,
12 0xE1, 0x5F, 0x38, 0x03, 0xB1, 0xBF, 0xF0, 0x65,
13 0x36, 0xAE, 0x2E, 0x5B, 0xA5, 0xE4, 0x69, 0x0E,
14};
15
16int main(void)
17{
18 setvbuf(stdout, nullptr, _IONBF, 0);
19
20 struct Tox_Options *opts = tox_options_new(nullptr);
21 tox_options_set_udp_enabled(opts, true);
22 tox_options_set_proxy_type(opts, TOX_PROXY_TYPE_SOCKS5);
23 tox_options_set_proxy_host(opts, "localhost");
24 tox_options_set_proxy_port(opts, 51724);
25 Tox *tox = tox_new_log(opts, nullptr, nullptr);
26 tox_options_free(opts);
27
28 tox_add_tcp_relay(tox, "tox.ngc.zone", 33445, key, nullptr);
29 tox_bootstrap(tox, "tox.ngc.zone", 33445, key, nullptr);
30
31 printf("Waiting for connection");
32
33 while (tox_self_get_connection_status(tox) == TOX_CONNECTION_NONE) {
34 printf(".");
35 fflush(stdout);
36
37 tox_iterate(tox, nullptr);
38 c_sleep(ITERATION_INTERVAL);
39 }
40
41 assert(tox_self_get_connection_status(tox) == TOX_CONNECTION_UDP);
42 printf("Connection (UDP): %d\n", tox_self_get_connection_status(tox));
43
44 tox_kill(tox);
45 return 0;
46}