From 314a6b42c59c7d9ea240b758ccffd796963efd0f Mon Sep 17 00:00:00 2001 From: George Kadianakis Date: Thu, 1 Jul 2021 17:42:34 +0300 Subject: Introduce vanguards-lite subsystem and some of its entry points Co-authored-by: Mike Perry --- src/test/test_entrynodes.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/test/test_entrynodes.c') diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c index c94b5d6a23..785ce296d3 100644 --- a/src/test/test_entrynodes.c +++ b/src/test/test_entrynodes.c @@ -92,6 +92,12 @@ bfn_mock_node_get_by_id(const char *id) return NULL; } +static int +mock_router_have_minimum_dir_info(void) +{ + return 1; +} + /* Helper function to free a test node. */ static void test_node_free(node_t *n) @@ -3087,6 +3093,23 @@ test_entry_guard_vanguard_path_selection(void *arg) circuit_free_(circ); } +static void +test_entry_guard_layer2_guards(void *arg) +{ + (void) arg; + MOCK(router_have_minimum_dir_info, mock_router_have_minimum_dir_info); + + /* Create the guardset */ + maintain_layer2_guards(); + + routerset_t *l2_guards = get_layer2_guards(); + tt_assert(l2_guards); + tt_int_op(routerset_len(l2_guards), OP_EQ, 4); + + done: + UNMOCK(router_have_minimum_dir_info); +} + static const struct testcase_setup_t big_fake_network = { big_fake_network_setup, big_fake_network_cleanup }; @@ -3152,6 +3175,8 @@ struct testcase_t entrynodes_tests[] = { BFN_TEST(manage_primary), BFN_TEST(correct_cascading_order), + BFN_TEST(layer2_guards), + EN_TEST_FORK(guard_preferred), BFN_TEST(select_for_circuit_no_confirmed), -- cgit v1.2.3-54-g00ecf