aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_hs_common.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-05-02 10:16:23 -0400
committerNick Mathewson <nickm@torproject.org>2018-05-02 10:17:46 -0400
commite386d61c9be44e82694d523d48591056984bb319 (patch)
tree4f4a050f7bdd7f4a0235dc21bd0c324a7352221d /src/test/test_hs_common.c
parent8625f36de1085cb24e532adb0bb76d3d2b6b5808 (diff)
downloadtor-e386d61c9be44e82694d523d48591056984bb319.tar.gz
tor-e386d61c9be44e82694d523d48591056984bb319.zip
Make hs_get_responsible_hsdirs() deterministic.
This test was using the current time to pick the time period number, and a randomly generated hs key. Therefore, it sometimes picked an index that would wrap around the example dht, and sometimes would not. The fix here is just to fix the time period and the public key. Fixes bug 25997; bugfix on 0.3.2.1-alpha.
Diffstat (limited to 'src/test/test_hs_common.c')
-rw-r--r--src/test/test_hs_common.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c
index dcca5713eb..94d3d52e98 100644
--- a/src/test/test_hs_common.c
+++ b/src/test/test_hs_common.c
@@ -360,11 +360,8 @@ mock_networkstatus_get_live_consensus(time_t now)
static void
test_responsible_hsdirs(void *arg)
{
- time_t now = approx_time();
smartlist_t *responsible_dirs = smartlist_new();
networkstatus_t *ns = NULL;
- int retval;
-
(void) arg;
hs_init();
@@ -386,12 +383,12 @@ test_responsible_hsdirs(void *arg)
helper_add_hsdir_to_networkstatus(ns, 3, "spyro", 0);
}
- ed25519_keypair_t kp;
- retval = ed25519_keypair_generate(&kp, 0);
- tt_int_op(retval, OP_EQ , 0);
+ /* Use a fixed time period and pub key so we always take the same path */
+ ed25519_public_key_t pubkey;
+ uint64_t time_period_num = 17653; // 2 May, 2018, 14:00.
+ memset(&pubkey, 42, sizeof(pubkey));
- uint64_t time_period_num = hs_get_time_period_num(now);
- hs_get_responsible_hsdirs(&kp.pubkey, time_period_num,
+ hs_get_responsible_hsdirs(&pubkey, time_period_num,
0, 0, responsible_dirs);
/* Make sure that we only found 2 responsible HSDirs.