aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2014-08-20 17:07:19 +0300
committerNick Mathewson <nickm@torproject.org>2014-08-20 10:25:27 -0400
commitd28670c94fb6482cfbd5117b001f076dbb9b9f41 (patch)
tree14627adbdbe3d8a0adf3d3b6be6ebb426f5b1853 /src/test
parent764cebb4d9a3f7b16d4735b9ef8a656bc921e217 (diff)
downloadtor-d28670c94fb6482cfbd5117b001f076dbb9b9f41.tar.gz
tor-d28670c94fb6482cfbd5117b001f076dbb9b9f41.zip
Fix entrynodes test fails because of outdated test vectors.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_entrynodes.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c
index ede93fb43a..83ceea7ce6 100644
--- a/src/test/test_entrynodes.c
+++ b/src/test/test_entrynodes.c
@@ -325,6 +325,19 @@ state_lines_free(smartlist_t *entry_guard_lines)
smartlist_free(entry_guard_lines);
}
+/* Return a statically allocated string representing yesterday's date
+ * in ISO format. We use it so that state file items are not found to
+ * be outdated. */
+static const char *
+get_yesterday_date_str(void)
+{
+ static char buf[ISO_TIME_LEN+1];
+
+ time_t yesterday = time(NULL) - 24*60*60;
+ format_iso_time(buf, yesterday);
+ return buf;
+}
+
/* Tests entry_guards_parse_state(). It creates a fake Tor state with
a saved entry guard and makes sure that Tor can parse it and
creates the right entry node out of it.
@@ -342,7 +355,7 @@ test_entry_guards_parse_state_simple(void *arg)
const char *nickname = "hagbard";
const char *fpr = "B29D536DD1752D542E1FBB3C9CE4449D51298212";
const char *tor_version = "0.2.5.3-alpha-dev";
- const char *added_at = "2014-05-22 02:40:47";
+ const char *added_at = get_yesterday_date_str();
const char *unlisted_since = "2014-06-08 16:16:50";
(void) arg;
@@ -457,7 +470,7 @@ test_entry_guards_parse_state_pathbias(void *arg)
smartlist_add_asprintf(state_line, "EntryGuardAddedBy");
smartlist_add_asprintf(state_line,
"B29D536DD1752D542E1FBB3C9CE4449D51298212 0.2.5.3-alpha-dev "
- "2014-05-22 02:40:47");
+ "%s", get_yesterday_date_str());
smartlist_add(entry_state_lines, state_line);
state_line = smartlist_new();