diff options
author | rl1987 <rl1987@sdf.lonestar.org> | 2015-10-08 21:27:17 +0300 |
---|---|---|
committer | rl1987 <rl1987@sdf.lonestar.org> | 2015-10-24 14:30:50 +0300 |
commit | 2fc841aacbfdb0e824ab3bed9e06db8d9c793747 (patch) | |
tree | fdf73b162e2c6b559d9e38765a30d3bb87a281e9 /src/test/test_dns.c | |
parent | 595bd9295c438ed0b889287845ef75da30abd2aa (diff) | |
download | tor-2fc841aacbfdb0e824ab3bed9e06db8d9c793747.tar.gz tor-2fc841aacbfdb0e824ab3bed9e06db8d9c793747.zip |
Making it slightly cleaner.
Diffstat (limited to 'src/test/test_dns.c')
-rw-r--r-- | src/test/test_dns.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/test/test_dns.c b/src/test/test_dns.c index 04c84af207..f1b11a88e8 100644 --- a/src/test/test_dns.c +++ b/src/test/test_dns.c @@ -321,6 +321,22 @@ NS(test_main)(void *arg) #undef NS_SUBMODULE +/** Create an <b>edge_connection_t</b> instance that is considered a + * valid exit connection by asserts in dns_resolve_impl. + */ +static edge_connection_t * +create_valid_exitconn(void) +{ + edge_connection_t *exitconn = tor_malloc_zero(sizeof(edge_connection_t)); + TO_CONN(exitconn)->type = CONN_TYPE_EXIT; + TO_CONN(exitconn)->magic = EDGE_CONNECTION_MAGIC; + TO_CONN(exitconn)->purpose = EXIT_PURPOSE_RESOLVE; + TO_CONN(exitconn)->state = EXIT_CONN_STATE_RESOLVING; + exitconn->base_.s = TOR_INVALID_SOCKET; + + return exitconn; +} + #define NS_SUBMODULE ASPECT(resolve_impl, addr_is_ip_no_need_to_resolve) /* @@ -342,12 +358,7 @@ NS(test_main)(void *arg) or_circuit_t *on_circ = tor_malloc_zero(sizeof(or_circuit_t)); - edge_connection_t *exitconn = tor_malloc_zero(sizeof(edge_connection_t)); - TO_CONN(exitconn)->type = CONN_TYPE_EXIT; - TO_CONN(exitconn)->magic = EDGE_CONNECTION_MAGIC; - TO_CONN(exitconn)->purpose = EXIT_PURPOSE_RESOLVE; - TO_CONN(exitconn)->state = EXIT_CONN_STATE_RESOLVING; - exitconn->base_.s = TOR_INVALID_SOCKET; + edge_connection_t *exitconn = create_valid_exitconn(); TO_CONN(exitconn)->address = tor_strdup("8.8.8.8"); @@ -357,8 +368,7 @@ NS(test_main)(void *arg) resolved_addr = &(exitconn->base_.addr); tt_int_op(retval,==,1); - tt_assert(tor_addr_compare(resolved_addr, - (const tor_addr_t *)&addr_to_compare, CMP_EXACT) == 0); + tt_assert(tor_addr_eq(resolved_addr, (const tor_addr_t *)&addr_to_compare)); tt_int_op(exitconn->address_ttl,==,DEFAULT_DNS_TTL); done: |