|
@@ -161,8 +161,93 @@ test_clist_maps(void *arg)
|
|
UNMOCK(circuitmux_detach_circuit);
|
|
UNMOCK(circuitmux_detach_circuit);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void
|
|
|
|
+test_rend_token_maps(void *arg)
|
|
|
|
+{
|
|
|
|
+ or_circuit_t *c1, *c2, *c3, *c4;
|
|
|
|
+ const uint8_t tok1[REND_TOKEN_LEN] = "The cat can't tell y";
|
|
|
|
+ const uint8_t tok2[REND_TOKEN_LEN] = "ou its name, and it ";
|
|
|
|
+ const uint8_t tok3[REND_TOKEN_LEN] = "doesn't really care.";
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ (void)arg;
|
|
|
|
+ (void)tok1;
|
|
|
|
+ c1 = or_circuit_new(0, NULL);
|
|
|
|
+ c2 = or_circuit_new(0, NULL);
|
|
|
|
+ c3 = or_circuit_new(0, NULL);
|
|
|
|
+ c4 = or_circuit_new(0, NULL);
|
|
|
|
+
|
|
|
|
+ tt_int_op(strlen((char*)tok1), ==, REND_TOKEN_LEN);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ tt_ptr_op(NULL, ==, circuit_get_rendezvous(tok1));
|
|
|
|
+ tt_ptr_op(NULL, ==, circuit_get_intro_point(tok1));
|
|
|
|
+
|
|
|
|
+ circuit_set_rendezvous_cookie(c1, tok1);
|
|
|
|
+ circuit_set_intro_point_digest(c2, tok2);
|
|
|
|
+
|
|
|
|
+ tt_ptr_op(NULL, ==, circuit_get_rendezvous(tok3));
|
|
|
|
+ tt_ptr_op(NULL, ==, circuit_get_intro_point(tok3));
|
|
|
|
+ tt_ptr_op(NULL, ==, circuit_get_rendezvous(tok2));
|
|
|
|
+ tt_ptr_op(NULL, ==, circuit_get_intro_point(tok1));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ tt_ptr_op(NULL, ==, circuit_get_rendezvous(tok1));
|
|
|
|
+ tt_ptr_op(NULL, ==, circuit_get_intro_point(tok2));
|
|
|
|
+
|
|
|
|
+ c1->base_.purpose = CIRCUIT_PURPOSE_REND_POINT_WAITING;
|
|
|
|
+ c2->base_.purpose = CIRCUIT_PURPOSE_INTRO_POINT;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ tt_ptr_op(c1, ==, circuit_get_rendezvous(tok1));
|
|
|
|
+ tt_ptr_op(c2, ==, circuit_get_intro_point(tok2));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ c3->base_.purpose = CIRCUIT_PURPOSE_REND_POINT_WAITING;
|
|
|
|
+ circuit_set_rendezvous_cookie(c3, tok2);
|
|
|
|
+ tt_ptr_op(c2, ==, circuit_get_intro_point(tok2));
|
|
|
|
+ tt_ptr_op(c3, ==, circuit_get_rendezvous(tok2));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ circuit_mark_for_close(TO_CIRCUIT(c1), END_CIRC_REASON_FINISHED);
|
|
|
|
+ tt_ptr_op(NULL, ==, circuit_get_rendezvous(tok1));
|
|
|
|
+ circuit_free(TO_CIRCUIT(c1));
|
|
|
|
+ c1 = NULL;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ circuit_free(TO_CIRCUIT(c2));
|
|
|
|
+ c2 = NULL;
|
|
|
|
+ tt_ptr_op(NULL, ==, circuit_get_intro_point(tok2));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ tt_ptr_op(c3, ==, circuit_get_rendezvous(tok2));
|
|
|
|
+
|
|
|
|
+ c3->base_.purpose = CIRCUIT_PURPOSE_INTRO_POINT;
|
|
|
|
+ circuit_set_intro_point_digest(c3, tok3);
|
|
|
|
+
|
|
|
|
+ tt_ptr_op(NULL, ==, circuit_get_rendezvous(tok2));
|
|
|
|
+ tt_ptr_op(c3, ==, circuit_get_intro_point(tok3));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ c4->base_.purpose = CIRCUIT_PURPOSE_INTRO_POINT;
|
|
|
|
+ circuit_set_intro_point_digest(c4, tok3);
|
|
|
|
+
|
|
|
|
+ tt_ptr_op(c4, ==, circuit_get_intro_point(tok3));
|
|
|
|
+
|
|
|
|
+ tt_ptr_op(c3->rendinfo, ==, NULL);
|
|
|
|
+ tt_ptr_op(c4->rendinfo, !=, NULL);
|
|
|
|
+ test_mem_op(c4->rendinfo, ==, tok3, REND_TOKEN_LEN);
|
|
|
|
+
|
|
|
|
+ done:
|
|
|
|
+ circuit_free(TO_CIRCUIT(c1));
|
|
|
|
+ circuit_free(TO_CIRCUIT(c2));
|
|
|
|
+ circuit_free(TO_CIRCUIT(c3));
|
|
|
|
+ circuit_free(TO_CIRCUIT(c4));
|
|
|
|
+}
|
|
|
|
+
|
|
struct testcase_t circuitlist_tests[] = {
|
|
struct testcase_t circuitlist_tests[] = {
|
|
{ "maps", test_clist_maps, TT_FORK, NULL, NULL },
|
|
{ "maps", test_clist_maps, TT_FORK, NULL, NULL },
|
|
|
|
+ { "rend_token_maps", test_rend_token_maps, TT_FORK, NULL, NULL },
|
|
END_OF_TESTCASES
|
|
END_OF_TESTCASES
|
|
};
|
|
};
|
|
|
|
|