summaryrefslogtreecommitdiff
path: root/src/test/test_router.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test_router.c')
-rw-r--r--src/test/test_router.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/src/test/test_router.c b/src/test/test_router.c
index cf0c2b3dd1..ddd043b941 100644
--- a/src/test/test_router.c
+++ b/src/test/test_router.c
@@ -24,7 +24,7 @@
#include "feature/nodelist/routerlist.h"
#include "feature/nodelist/routerstatus_st.h"
#include "feature/relay/router.h"
-#include "feature/stats/rephist.h"
+#include "feature/stats/bwhist.h"
#include "lib/crypt_ops/crypto_curve25519.h"
#include "lib/crypt_ops/crypto_ed25519.h"
#include "lib/encoding/confline.h"
@@ -61,8 +61,8 @@ rtr_tests_router_get_my_routerinfo(void)
mock_routerinfo = tor_malloc_zero(sizeof(routerinfo_t));
mock_routerinfo->nickname = tor_strdup("ConlonNancarrow");
- mock_routerinfo->addr = 123456789;
- mock_routerinfo->or_port = 443;
+ tor_addr_from_ipv4h(&mock_routerinfo->ipv4_addr, 123456789);
+ mock_routerinfo->ipv4_orport = 443;
mock_routerinfo->platform = tor_strdup("unittest");
mock_routerinfo->cache_info.published_on = now;
mock_routerinfo->identity_pkey = crypto_pk_dup_key(ident_key);
@@ -226,13 +226,13 @@ test_router_check_descriptor_bandwidth_changed(void *arg)
/* When uptime is less than 24h and bandwidthcapacity does not change
* Uptime: 10800, last_changed: x, Previous bw: 10000, Current bw: 20001 */
- MOCK(rep_hist_bandwidth_assess, mock_rep_hist_bandwidth_assess);
+ MOCK(bwhist_bandwidth_assess, mock_rep_hist_bandwidth_assess);
setup_full_capture_of_logs(LOG_INFO);
check_descriptor_bandwidth_changed(time(NULL) + 6*60*60 + 1);
expect_log_msg_containing(
"Measured bandwidth has changed; rebuilding descriptor.");
UNMOCK(get_uptime);
- UNMOCK(rep_hist_bandwidth_assess);
+ UNMOCK(bwhist_bandwidth_assess);
teardown_capture_of_logs();
/* When uptime is more than 24h */
@@ -507,13 +507,12 @@ test_router_get_advertised_or_port(void *arg)
listener_connection_t *listener = NULL;
tor_addr_port_t ipv6;
- // Test one failing case of router_get_advertised_ipv6_or_ap().
- router_get_advertised_ipv6_or_ap(opts, &ipv6);
+ // Test one failing case of routerconf_find_ipv6_or_ap().
+ routerconf_find_ipv6_or_ap(opts, &ipv6);
tt_str_op(fmt_addrport(&ipv6.addr, ipv6.port), OP_EQ, "[::]:0");
- // And one failing case of router_get_advertised_or_port().
- tt_int_op(0, OP_EQ, router_get_advertised_or_port_by_af(opts, AF_INET));
- tt_int_op(0, OP_EQ, router_get_advertised_or_port(opts));
+ // And one failing case of routerconf_find_or_port().
+ tt_int_op(0, OP_EQ, routerconf_find_or_port(opts, AF_INET));
// Set up a couple of configured ports.
config_line_append(&opts->ORPort_lines, "ORPort", "[1234::5678]:auto");
@@ -522,13 +521,12 @@ test_router_get_advertised_or_port(void *arg)
tt_assert(r == 0);
// There are no listeners, so the "auto" case will turn up no results.
- tt_int_op(0, OP_EQ, router_get_advertised_or_port_by_af(opts, AF_INET6));
- router_get_advertised_ipv6_or_ap(opts, &ipv6);
+ tt_int_op(0, OP_EQ, routerconf_find_or_port(opts, AF_INET6));
+ routerconf_find_ipv6_or_ap(opts, &ipv6);
tt_str_op(fmt_addrport(&ipv6.addr, ipv6.port), OP_EQ, "[::]:0");
// This will return the matching value from the configured port.
- tt_int_op(9999, OP_EQ, router_get_advertised_or_port_by_af(opts, AF_INET));
- tt_int_op(9999, OP_EQ, router_get_advertised_or_port(opts));
+ tt_int_op(9999, OP_EQ, routerconf_find_or_port(opts, AF_INET));
// Now set up a dummy listener.
MOCK(get_connection_array, mock_get_connection_array);
@@ -538,16 +536,15 @@ test_router_get_advertised_or_port(void *arg)
smartlist_add(fake_connection_array, TO_CONN(listener));
// We should get a port this time.
- tt_int_op(54321, OP_EQ, router_get_advertised_or_port_by_af(opts, AF_INET6));
+ tt_int_op(54321, OP_EQ, routerconf_find_or_port(opts, AF_INET6));
- // Test one succeeding case of router_get_advertised_ipv6_or_ap().
- router_get_advertised_ipv6_or_ap(opts, &ipv6);
+ // Test one succeeding case of routerconf_find_ipv6_or_ap().
+ routerconf_find_ipv6_or_ap(opts, &ipv6);
tt_str_op(fmt_addrport(&ipv6.addr, ipv6.port), OP_EQ,
"[1234::5678]:54321");
// This will return the matching value from the configured port.
- tt_int_op(9999, OP_EQ, router_get_advertised_or_port_by_af(opts, AF_INET));
- tt_int_op(9999, OP_EQ, router_get_advertised_or_port(opts));
+ tt_int_op(9999, OP_EQ, routerconf_find_or_port(opts, AF_INET));
done:
or_options_free(opts);
@@ -573,28 +570,26 @@ test_router_get_advertised_or_port_localhost(void *arg)
tt_assert(r == 0);
// We should refuse to advertise them, since we have default dirauths.
- router_get_advertised_ipv6_or_ap(opts, &ipv6);
+ routerconf_find_ipv6_or_ap(opts, &ipv6);
tt_str_op(fmt_addrport(&ipv6.addr, ipv6.port), OP_EQ, "[::]:0");
// But the lower-level function should still report the correct value
- tt_int_op(9999, OP_EQ, router_get_advertised_or_port_by_af(opts, AF_INET6));
+ tt_int_op(9999, OP_EQ, routerconf_find_or_port(opts, AF_INET6));
// The IPv4 checks are done in resolve_my_address(), which doesn't use
// ORPorts so we can't test them here. (See #33681.) Both these lower-level
// functions should still report the correct value.
- tt_int_op(8888, OP_EQ, router_get_advertised_or_port_by_af(opts, AF_INET));
- tt_int_op(8888, OP_EQ, router_get_advertised_or_port(opts));
+ tt_int_op(8888, OP_EQ, routerconf_find_or_port(opts, AF_INET));
// Now try with a fake authority set up.
config_line_append(&opts->DirAuthorities, "DirAuthority",
"127.0.0.1:1066 "
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
- tt_int_op(9999, OP_EQ, router_get_advertised_or_port_by_af(opts, AF_INET6));
- router_get_advertised_ipv6_or_ap(opts, &ipv6);
+ tt_int_op(9999, OP_EQ, routerconf_find_or_port(opts, AF_INET6));
+ routerconf_find_ipv6_or_ap(opts, &ipv6);
tt_str_op(fmt_addrport(&ipv6.addr, ipv6.port), OP_EQ, "[::1]:9999");
- tt_int_op(8888, OP_EQ, router_get_advertised_or_port_by_af(opts, AF_INET));
- tt_int_op(8888, OP_EQ, router_get_advertised_or_port(opts));
+ tt_int_op(8888, OP_EQ, routerconf_find_or_port(opts, AF_INET));
done:
or_options_free(opts);