aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/config/config.c28
-rw-r--r--src/core/or/policies.c8
-rw-r--r--src/feature/dirauth/dirvote.c8
-rw-r--r--src/feature/dircache/directory.c3
-rw-r--r--src/feature/hs_common/shared_random_client.c21
-rw-r--r--src/feature/nodelist/nodelist.c147
-rw-r--r--src/lib/log/log.c9
-rw-r--r--src/test/include.am2
-rw-r--r--src/test/test.c10
-rw-r--r--src/test/test_options.c12
-rw-r--r--src/test/test_shared_random.c34
-rw-r--r--src/test/test_util.c2
12 files changed, 175 insertions, 109 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c
index 1b1889779d..105c408614 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -3359,7 +3359,6 @@ STATIC int
options_validate(or_options_t *old_options, or_options_t *options,
or_options_t *default_options, int from_setconf, char **msg)
{
- int i;
config_line_t *cl;
const char *uname = get_uname();
int n_ports=0;
@@ -3680,30 +3679,6 @@ options_validate(or_options_t *old_options, or_options_t *options,
}
}
- /* Terminate Reachable*Addresses with reject *
- */
- for (i=0; i<3; i++) {
- config_line_t **linep =
- (i==0) ? &options->ReachableAddresses :
- (i==1) ? &options->ReachableORAddresses :
- &options->ReachableDirAddresses;
- if (!*linep)
- continue;
- /* We need to end with a reject *:*, not an implicit accept *:* */
- for (;;) {
- linep = &((*linep)->next);
- if (!*linep) {
- *linep = tor_malloc_zero(sizeof(config_line_t));
- (*linep)->key = tor_strdup(
- (i==0) ? "ReachableAddresses" :
- (i==1) ? "ReachableORAddresses" :
- "ReachableDirAddresses");
- (*linep)->value = tor_strdup("reject *:*");
- break;
- }
- }
- }
-
if ((options->ReachableAddresses ||
options->ReachableORAddresses ||
options->ReachableDirAddresses ||
@@ -4714,8 +4689,7 @@ have_enough_mem_for_dircache(const or_options_t *options, size_t total_mem,
} else {
if (total_mem >= DIRCACHE_MIN_MEM_BYTES) {
*msg = tor_strdup("DirCache is disabled and we are configured as a "
- "relay. This may disqualify us from becoming a guard in the "
- "future.");
+ "relay. We will not become a Guard.");
}
}
return *msg == NULL ? 0 : -1;
diff --git a/src/core/or/policies.c b/src/core/or/policies.c
index e01415f95e..7f5d5dd10f 100644
--- a/src/core/or/policies.c
+++ b/src/core/or/policies.c
@@ -317,6 +317,14 @@ parse_reachable_addresses(void)
}
}
+ /* Prepend a reject *.* to reachable_(or|dir)_addr_policy */
+ if (!ret && (options->ReachableDirAddresses ||
+ options->ReachableORAddresses ||
+ options->ReachableAddresses)) {
+ append_exit_policy_string(&reachable_or_addr_policy, "reject *:*");
+ append_exit_policy_string(&reachable_dir_addr_policy, "reject *:*");
+ }
+
return ret;
}
diff --git a/src/feature/dirauth/dirvote.c b/src/feature/dirauth/dirvote.c
index 6477f34baf..a97f3c47d8 100644
--- a/src/feature/dirauth/dirvote.c
+++ b/src/feature/dirauth/dirvote.c
@@ -4566,16 +4566,16 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
/* These are hardwired, to avoid disaster. */
v3_out->recommended_relay_protocols =
tor_strdup("Cons=1-2 Desc=1-2 DirCache=1 HSDir=1 HSIntro=3 HSRend=1 "
- "Link=4 LinkAuth=1 Microdesc=1-2 Relay=2");
+ "Link=4 Microdesc=1-2 Relay=2");
v3_out->recommended_client_protocols =
tor_strdup("Cons=1-2 Desc=1-2 DirCache=1 HSDir=1 HSIntro=3 HSRend=1 "
- "Link=4 LinkAuth=1 Microdesc=1-2 Relay=2");
+ "Link=4 Microdesc=1-2 Relay=2");
v3_out->required_client_protocols =
tor_strdup("Cons=1-2 Desc=1-2 DirCache=1 HSDir=1 HSIntro=3 HSRend=1 "
- "Link=4 LinkAuth=1 Microdesc=1-2 Relay=2");
+ "Link=4 Microdesc=1-2 Relay=2");
v3_out->required_relay_protocols =
tor_strdup("Cons=1 Desc=1 DirCache=1 HSDir=1 HSIntro=3 HSRend=1 "
- "Link=3-4 LinkAuth=1 Microdesc=1 Relay=1-2");
+ "Link=3-4 Microdesc=1 Relay=1-2");
/* We are not allowed to vote to require anything we don't have. */
tor_assert(protover_all_supported(v3_out->required_relay_protocols, NULL));
diff --git a/src/feature/dircache/directory.c b/src/feature/dircache/directory.c
index a723176185..888a7c1939 100644
--- a/src/feature/dircache/directory.c
+++ b/src/feature/dircache/directory.c
@@ -5210,6 +5210,9 @@ connection_dir_finished_flushing(dir_connection_t *conn)
tor_assert(conn);
tor_assert(conn->base_.type == CONN_TYPE_DIR);
+ if (conn->base_.marked_for_close)
+ return 0;
+
/* Note that we have finished writing the directory response. For direct
* connections this means we're done; for tunneled connections it's only
* an intermediate step. */
diff --git a/src/feature/hs_common/shared_random_client.c b/src/feature/hs_common/shared_random_client.c
index ff98a719db..a13404a329 100644
--- a/src/feature/hs_common/shared_random_client.c
+++ b/src/feature/hs_common/shared_random_client.c
@@ -51,9 +51,13 @@ get_voting_interval(void)
return interval;
}
-/* Given the time <b>now</b>, return the start time of the current round of
+/* Given the current consensus, return the start time of the current round of
* the SR protocol. For example, if it's 23:47:08, the current round thus
- * started at 23:47:00 for a voting interval of 10 seconds. */
+ * started at 23:47:00 for a voting interval of 10 seconds.
+ *
+ * This function uses the consensus voting schedule to derive its results,
+ * instead of the actual consensus we are currently using, so it should be used
+ * for voting purposes. */
time_t
get_start_time_of_current_round(void)
{
@@ -231,8 +235,17 @@ sr_state_get_start_time_of_current_protocol_run(void)
{
int total_rounds = SHARED_RANDOM_N_ROUNDS * SHARED_RANDOM_N_PHASES;
int voting_interval = get_voting_interval();
- /* Find the time the current round started. */
- time_t beginning_of_curr_round = get_start_time_of_current_round();
+ time_t beginning_of_curr_round;
+
+ /* This function is not used for voting purposes, so if we have a live
+ consensus, use its valid-after as the beginning of the current round,
+ otherwise resort to the voting schedule which should always exist. */
+ networkstatus_t *ns = networkstatus_get_live_consensus(approx_time());
+ if (ns) {
+ beginning_of_curr_round = ns->valid_after;
+ } else {
+ beginning_of_curr_round = get_start_time_of_current_round();
+ }
/* Get current SR protocol round */
int curr_round_slot;
diff --git a/src/feature/nodelist/nodelist.c b/src/feature/nodelist/nodelist.c
index 75a08fe752..d6bc474483 100644
--- a/src/feature/nodelist/nodelist.c
+++ b/src/feature/nodelist/nodelist.c
@@ -84,10 +84,17 @@ static void node_free_(node_t *node);
/** count_usable_descriptors counts descriptors with these flag(s)
*/
typedef enum {
- /* All descriptors regardless of flags */
- USABLE_DESCRIPTOR_ALL = 0,
- /* Only descriptors with the Exit flag */
- USABLE_DESCRIPTOR_EXIT_ONLY = 1
+ /* All descriptors regardless of flags or exit policies */
+ USABLE_DESCRIPTOR_ALL = 0U,
+ /* Only count descriptors with an exit policy that allows at least one port
+ */
+ USABLE_DESCRIPTOR_EXIT_POLICY = 1U << 0,
+ /* Only count descriptors for relays that have the exit flag in the
+ * consensus */
+ USABLE_DESCRIPTOR_EXIT_FLAG = 1U << 1,
+ /* Only count descriptors for relays that have the policy and the flag */
+ USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG = (USABLE_DESCRIPTOR_EXIT_POLICY |
+ USABLE_DESCRIPTOR_EXIT_FLAG)
} usable_descriptor_t;
static void count_usable_descriptors(int *num_present,
int *num_usable,
@@ -2135,8 +2142,11 @@ get_dir_info_status_string(void)
* *<b>num_present</b>).
*
* If <b>in_set</b> is non-NULL, only consider those routers in <b>in_set</b>.
- * If <b>exit_only</b> is USABLE_DESCRIPTOR_EXIT_ONLY, only consider nodes
- * with the Exit flag.
+ * If <b>exit_only</b> & USABLE_DESCRIPTOR_EXIT_POLICY, only consider nodes
+ * present if they have an exit policy that accepts at least one port.
+ * If <b>exit_only</b> & USABLE_DESCRIPTOR_EXIT_FLAG, only consider nodes
+ * usable if they have the exit flag in the consensus.
+ *
* If *<b>descs_out</b> is present, add a node_t for each usable descriptor
* to it.
*/
@@ -2157,7 +2167,7 @@ count_usable_descriptors(int *num_present, int *num_usable,
if (!node)
continue; /* This would be a bug: every entry in the consensus is
* supposed to have a node. */
- if (exit_only == USABLE_DESCRIPTOR_EXIT_ONLY && ! rs->is_exit)
+ if ((exit_only & USABLE_DESCRIPTOR_EXIT_FLAG) && ! rs->is_exit)
continue;
if (in_set && ! routerset_contains_routerstatus(in_set, rs, -1))
continue;
@@ -2170,7 +2180,14 @@ count_usable_descriptors(int *num_present, int *num_usable,
else
present = NULL != router_get_by_descriptor_digest(digest);
if (present) {
- /* we have the descriptor listed in the consensus. */
+ /* Do the policy check last, because it requires a descriptor,
+ * and is potentially expensive */
+ if ((exit_only & USABLE_DESCRIPTOR_EXIT_POLICY) &&
+ node_exit_policy_rejects_all(node)) {
+ continue;
+ }
+ /* we have the descriptor listed in the consensus, and it
+ * satisfies our exit constraints (if any) */
++*num_present;
}
if (descs_out)
@@ -2179,10 +2196,17 @@ count_usable_descriptors(int *num_present, int *num_usable,
}
SMARTLIST_FOREACH_END(rs);
- log_debug(LD_DIR, "%d usable, %d present (%s%s).",
+ log_debug(LD_DIR, "%d usable, %d present (%s%s%s%s%s).",
*num_usable, *num_present,
md ? "microdesc" : "desc",
- exit_only == USABLE_DESCRIPTOR_EXIT_ONLY ? " exits" : "s");
+ (exit_only & USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG) ?
+ " exit" : "s",
+ (exit_only & USABLE_DESCRIPTOR_EXIT_POLICY) ?
+ " policies" : "" ,
+ (exit_only == USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG) ?
+ " and" : "" ,
+ (exit_only & USABLE_DESCRIPTOR_EXIT_FLAG) ?
+ " flags" : "" );
}
/** Return an estimate of which fraction of usable paths through the Tor
@@ -2217,9 +2241,20 @@ compute_frac_paths_available(const networkstatus_t *consensus,
count_usable_descriptors(num_present_out, num_usable_out,
mid, consensus, now, NULL,
USABLE_DESCRIPTOR_ALL);
+ log_debug(LD_NET,
+ "%s: %d present, %d usable",
+ "mid",
+ np,
+ nu);
+
if (options->EntryNodes) {
count_usable_descriptors(&np, &nu, guards, consensus, now,
options->EntryNodes, USABLE_DESCRIPTOR_ALL);
+ log_debug(LD_NET,
+ "%s: %d present, %d usable",
+ "guard",
+ np,
+ nu);
} else {
SMARTLIST_FOREACH(mid, const node_t *, node, {
if (authdir) {
@@ -2230,42 +2265,45 @@ compute_frac_paths_available(const networkstatus_t *consensus,
smartlist_add(guards, (node_t*)node);
}
});
+ log_debug(LD_NET,
+ "%s: %d possible",
+ "guard",
+ smartlist_len(guards));
}
- /* All nodes with exit flag
- * If we're in a network with TestingDirAuthVoteExit set,
- * this can cause false positives on have_consensus_path,
- * incorrectly setting it to CONSENSUS_PATH_EXIT. This is
- * an unavoidable feature of forcing authorities to declare
- * certain nodes as exits.
- */
+ /* All nodes with exit policy and flag */
count_usable_descriptors(&np, &nu, exits, consensus, now,
- NULL, USABLE_DESCRIPTOR_EXIT_ONLY);
+ NULL, USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG);
log_debug(LD_NET,
"%s: %d present, %d usable",
"exits",
np,
nu);
- /* We need at least 1 exit present in the consensus to consider
+ /* We need at least 1 exit (flag and policy) in the consensus to consider
* building exit paths */
/* Update our understanding of whether the consensus has exits */
consensus_path_type_t old_have_consensus_path = have_consensus_path;
- have_consensus_path = ((nu > 0) ?
+ have_consensus_path = ((np > 0) ?
CONSENSUS_PATH_EXIT :
CONSENSUS_PATH_INTERNAL);
- if (have_consensus_path == CONSENSUS_PATH_INTERNAL
- && old_have_consensus_path != have_consensus_path) {
- log_notice(LD_NET,
- "The current consensus has no exit nodes. "
- "Tor can only build internal paths, "
- "such as paths to hidden services.");
-
- /* However, exit nodes can reachability self-test using this consensus,
- * join the network, and appear in a later consensus. This will allow
- * the network to build exit paths, such as paths for world wide web
- * browsing (as distinct from hidden service web browsing). */
+ if (old_have_consensus_path != have_consensus_path) {
+ if (have_consensus_path == CONSENSUS_PATH_INTERNAL) {
+ log_notice(LD_NET,
+ "The current consensus has no exit nodes. "
+ "Tor can only build internal paths, "
+ "such as paths to onion services.");
+
+ /* However, exit nodes can reachability self-test using this consensus,
+ * join the network, and appear in a later consensus. This will allow
+ * the network to build exit paths, such as paths for world wide web
+ * browsing (as distinct from hidden service web browsing). */
+ } else if (old_have_consensus_path == CONSENSUS_PATH_INTERNAL) {
+ log_notice(LD_NET,
+ "The current consensus contains exit nodes. "
+ "Tor can build exit and internal paths.");
+ }
}
f_guard = frac_nodes_with_descriptors(guards, WEIGHT_FOR_GUARD, 1);
@@ -2292,44 +2330,29 @@ compute_frac_paths_available(const networkstatus_t *consensus,
smartlist_t *myexits= smartlist_new();
smartlist_t *myexits_unflagged = smartlist_new();
- /* All nodes with exit flag in ExitNodes option */
+ /* All nodes with exit policy and flag in ExitNodes option */
count_usable_descriptors(&np, &nu, myexits, consensus, now,
- options->ExitNodes, USABLE_DESCRIPTOR_EXIT_ONLY);
+ options->ExitNodes,
+ USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG);
log_debug(LD_NET,
"%s: %d present, %d usable",
"myexits",
np,
nu);
- /* Now compute the nodes in the ExitNodes option where which we don't know
- * what their exit policy is, or we know it permits something. */
+ /* Now compute the nodes in the ExitNodes option where we know their exit
+ * policy permits something. */
count_usable_descriptors(&np, &nu, myexits_unflagged,
consensus, now,
- options->ExitNodes, USABLE_DESCRIPTOR_ALL);
+ options->ExitNodes,
+ USABLE_DESCRIPTOR_EXIT_POLICY);
log_debug(LD_NET,
"%s: %d present, %d usable",
"myexits_unflagged (initial)",
np,
nu);
- SMARTLIST_FOREACH_BEGIN(myexits_unflagged, const node_t *, node) {
- if (node_has_preferred_descriptor(node, 0) &&
- node_exit_policy_rejects_all(node)) {
- SMARTLIST_DEL_CURRENT(myexits_unflagged, node);
- /* this node is not actually an exit */
- np--;
- /* this node is unusable as an exit */
- nu--;
- }
- } SMARTLIST_FOREACH_END(node);
-
- log_debug(LD_NET,
- "%s: %d present, %d usable",
- "myexits_unflagged (final)",
- np,
- nu);
-
- f_myexit= frac_nodes_with_descriptors(myexits, WEIGHT_FOR_EXIT, 0);
+ f_myexit= frac_nodes_with_descriptors(myexits,WEIGHT_FOR_EXIT, 0);
f_myexit_unflagged=
frac_nodes_with_descriptors(myexits_unflagged,
WEIGHT_FOR_EXIT, 0);
@@ -2359,9 +2382,14 @@ compute_frac_paths_available(const networkstatus_t *consensus,
f_exit = f_myexit;
}
- /* if the consensus has no exits, treat the exit fraction as 100% */
+ /* if the consensus has no exits, we can only build onion service paths,
+ * which are G - M - M. So use the middle fraction for the exit fraction. */
if (router_have_consensus_path() != CONSENSUS_PATH_EXIT) {
- f_exit = 1.0;
+ /* If there are no exits in the consensus, then f_exit is always 0, so
+ * it is safe to replace f_exit with f_mid. */
+ if (!BUG(f_exit > 0.0)) {
+ f_exit = f_mid;
+ }
}
f_path = f_guard * f_mid * f_exit;
@@ -2370,14 +2398,14 @@ compute_frac_paths_available(const networkstatus_t *consensus,
tor_asprintf(status_out,
"%d%% of guards bw, "
"%d%% of midpoint bw, and "
- "%d%% of exit bw%s = "
+ "%d%% of %s = "
"%d%% of path bw",
(int)(f_guard*100),
(int)(f_mid*100),
(int)(f_exit*100),
(router_have_consensus_path() == CONSENSUS_PATH_EXIT ?
- "" :
- " (no exits in consensus)"),
+ "exit bw" :
+ "end bw (no exits in consensus, using mid)"),
(int)(f_path*100));
return f_path;
@@ -2518,4 +2546,3 @@ update_router_have_minimum_dir_info(void)
have_min_dir_info = res;
need_to_update_have_min_dir_info = 0;
}
-
diff --git a/src/lib/log/log.c b/src/lib/log/log.c
index e2514a341b..d60ce6308a 100644
--- a/src/lib/log/log.c
+++ b/src/lib/log/log.c
@@ -101,7 +101,7 @@ sev_to_string(int severity)
case LOG_NOTICE: return "notice";
case LOG_WARN: return "warn";
case LOG_ERR: return "err";
- default: /* Call assert, not tor_assert, since tor_assert
+ default: /* Call raw_assert, not tor_assert, since tor_assert
* calls log on failure. */
raw_assert_unreached(); return "UNKNOWN"; // LCOV_EXCL_LINE
}
@@ -122,7 +122,8 @@ should_log_function_name(log_domain_mask_t domain, int severity)
/* We care about places where bugs occur. */
return (domain & (LD_BUG|LD_NOFUNCNAME)) == LD_BUG;
default:
- /* Call assert, not tor_assert, since tor_assert calls log on failure. */
+ /* Call raw_assert, not tor_assert, since tor_assert calls
+ * log on failure. */
raw_assert(0); return 0; // LCOV_EXCL_LINE
}
}
@@ -579,7 +580,7 @@ logv,(int severity, log_domain_mask_t domain, const char *funcname,
char *end_of_prefix=NULL;
int callbacks_deferred = 0;
- /* Call assert, not raw_assert, since raw_assert calls log on failure. */
+ /* Call raw_assert, not tor_assert, since tor_assert calls log on failure. */
raw_assert(format);
/* check that severity is sane. Overrunning the masks array leads to
* interesting and hard to diagnose effects */
@@ -694,7 +695,7 @@ tor_log_update_sigsafe_err_fds(void)
if (!found_real_stderr &&
int_array_contains(fds, n_fds, STDOUT_FILENO)) {
/* Don't use a virtual stderr when we're also logging to stdout. */
- raw_assert(n_fds >= 2); /* Don't raw_assert inside log fns */
+ raw_assert(n_fds >= 2); /* Don't tor_assert inside log fns */
fds[0] = fds[--n_fds];
}
diff --git a/src/test/include.am b/src/test/include.am
index 81b089b8f7..9367b0cb82 100644
--- a/src/test/include.am
+++ b/src/test/include.am
@@ -51,7 +51,7 @@ TEST_CHUTNEY_FLAVORS = basic-min bridges-min hs-v2-min hs-v3-min \
TEST_CHUTNEY_FLAVORS_IPV6 = bridges+ipv6-min ipv6-exit-min hs-v23-ipv6-md \
single-onion-ipv6-md
# only run if we can find a stable (or simply another) version of tor
-TEST_CHUTNEY_FLAVORS_MIXED = mixed+hs-v23
+TEST_CHUTNEY_FLAVORS_MIXED = mixed+hs-v2
### This is a lovely feature, but it requires automake >= 1.12, and Tor
### doesn't require that yet.
diff --git a/src/test/test.c b/src/test/test.c
index 745aa987aa..f96a0b33ed 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -26,6 +26,8 @@
#include <dirent.h>
#endif /* defined(_WIN32) */
+#include <math.h>
+
/* These macros pull in declarations for some functions and structures that
* are typically file-private. */
#define ROUTER_PRIVATE
@@ -34,14 +36,6 @@
#define MAIN_PRIVATE
#define STATEFILE_PRIVATE
-/*
- * Linux doesn't provide lround in math.h by default, but mac os does...
- * It's best just to leave math.h out of the picture entirely.
- */
-//#include <math.h>
-long int lround(double x);
-double fabs(double x);
-
#include "core/or/or.h"
#include "lib/err/backtrace.h"
#include "lib/container/buffers.h"
diff --git a/src/test/test_options.c b/src/test/test_options.c
index 801b5895ff..71d2193d1f 100644
--- a/src/test/test_options.c
+++ b/src/test/test_options.c
@@ -1656,6 +1656,18 @@ test_options_validate__reachable_addresses(void *ignored)
tt_str_op(tdata->opt->ReachableAddresses->value, OP_EQ, "*:82");
tor_free(msg);
+ free_options_test_data(tdata);
+ mock_clean_saved_logs();
+ tdata = get_options_test_data("FascistFirewall 1\n"
+ "ReachableAddresses *:82\n"
+ "MaxClientCircuitsPending 1\n"
+ "ConnLimit 1\n");
+
+ ret = options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg);
+ tt_int_op(ret, OP_EQ, -1);
+ tt_ptr_op(tdata->opt->ReachableAddresses->next, OP_EQ, NULL);
+ tor_free(msg);
+
#define SERVERS_REACHABLE_MSG "Servers must be able to freely connect to" \
" the rest of the Internet, so they must not set Reachable*Addresses or" \
" FascistFirewall or FirewallPorts or ClientUseIPv4 0."
diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c
index d2defdf680..72e4522da1 100644
--- a/src/test/test_shared_random.c
+++ b/src/test/test_shared_random.c
@@ -290,6 +290,40 @@ test_get_start_time_of_current_run(void *arg)
tt_str_op("2015-04-20 00:00:00", OP_EQ, tbuf);
}
+ {
+ /* We want the local time to be past midnight, but the current consensus to
+ * have valid-after 23:00 (e.g. this can happen if we fetch a new consensus
+ * at 00:08 before dircaches have a chance to get the midnight consensus).
+ *
+ * Basically, we want to cause a desynch between ns->valid_after (23:00)
+ * and the voting_schedule.interval_starts (01:00), to make sure that
+ * sr_state_get_start_time_of_current_protocol_run() handles it gracefully:
+ * It should actually follow the local consensus time and not the voting
+ * schedule (which is designed for authority voting purposes). */
+ retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:00 UTC",
+ &mock_consensus.fresh_until);
+ tt_int_op(retval, OP_EQ, 0);
+
+ retval = parse_rfc1123_time("Mon, 19 Apr 2015 23:00:00 UTC",
+ &mock_consensus.valid_after);
+
+ retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:08:00 UTC",
+ &current_time);
+ tt_int_op(retval, OP_EQ, 0);
+ update_approx_time(current_time);
+ voting_schedule_recalculate_timing(get_options(), current_time);
+
+ run_start_time = sr_state_get_start_time_of_current_protocol_run();
+
+ /* Compare it with the correct result */
+ format_iso_time(tbuf, run_start_time);
+ tt_str_op("2015-04-19 00:00:00", OP_EQ, tbuf);
+ /* Check that voting_schedule.interval_starts is at 01:00 (see above) */
+ time_t interval_starts = voting_schedule_get_next_valid_after_time();
+ format_iso_time(tbuf, interval_starts);
+ tt_str_op("2015-04-20 01:00:00", OP_EQ, tbuf);
+ }
+
/* Next test is testing it without a consensus to use the testing voting
* interval . */
UNMOCK(networkstatus_get_live_consensus);
diff --git a/src/test/test_util.c b/src/test/test_util.c
index b395110cdf..6cbd504e34 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -6299,7 +6299,7 @@ test_util_log_mallinfo(void *arg)
tt_assert(next2);
if (mem2 == 0) {
/* This is a fake mallinfo that doesn't actually fill in its outputs. */
- tt_int_op(mem1, OP_EQ, 0);
+ tt_u64_op(mem1, OP_EQ, 0);
} else {
tt_u64_op(mem1, OP_LT, mem2);
}