summaryrefslogtreecommitdiff
path: root/src/test/test_entrynodes.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2014-09-15 15:50:38 +0300
committerGeorge Kadianakis <desnacked@riseup.net>2014-09-15 16:07:48 +0300
commit532ab7e13cac4c9ba1cdb1e6e008b0e5cb2afff4 (patch)
tree3b33eafe54f3f37822bce795ade7db5221ddad2c /src/test/test_entrynodes.c
parent6c512d2f634c5688ca6ce5d4bfbe1ee2d263f212 (diff)
downloadtor-532ab7e13cac4c9ba1cdb1e6e008b0e5cb2afff4.tar.gz
tor-532ab7e13cac4c9ba1cdb1e6e008b0e5cb2afff4.zip
Move some useful unittest functions to a testhelper.c file.
This commit only moves code.
Diffstat (limited to 'src/test/test_entrynodes.c')
-rw-r--r--src/test/test_entrynodes.c55
1 files changed, 0 insertions, 55 deletions
diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c
index fab82c3446..0f7fcb0054 100644
--- a/src/test/test_entrynodes.c
+++ b/src/test/test_entrynodes.c
@@ -37,61 +37,6 @@ get_or_state_replacement(void)
return dummy_state;
}
-/* NOP replacement for router_descriptor_is_older_than() */
-static int
-router_descriptor_is_older_than_replacement(const routerinfo_t *router,
- int seconds)
-{
- (void) router;
- (void) seconds;
- return 0;
-}
-
-/* Number of descriptors contained in test_descriptors.txt. */
-#define NUMBER_OF_DESCRIPTORS 8
-
-/** Parse a file containing router descriptors and load them to our
- routerlist. This function is used to setup an artificial network
- so that we can conduct entry guard tests. */
-static void
-setup_fake_routerlist(void)
-{
- int retval;
- routerlist_t *our_routerlist = NULL;
- smartlist_t *our_nodelist = NULL;
-
- /* Read the file that contains our test descriptors. */
-
- /* We need to mock this function otherwise the descriptors will not
- accepted as they are too old. */
- MOCK(router_descriptor_is_older_than,
- router_descriptor_is_older_than_replacement);
-
- /* Load all the test descriptors to the routerlist. */
- retval = router_load_routers_from_string(TEST_DESCRIPTORS,
- NULL, SAVED_IN_JOURNAL,
- NULL, 0, NULL);
- tt_int_op(retval, ==, NUMBER_OF_DESCRIPTORS);
-
- /* Sanity checking of routerlist and nodelist. */
- our_routerlist = router_get_routerlist();
- tt_int_op(smartlist_len(our_routerlist->routers), ==, NUMBER_OF_DESCRIPTORS);
- routerlist_assert_ok(our_routerlist);
-
- our_nodelist = nodelist_get_list();
- tt_int_op(smartlist_len(our_nodelist), ==, NUMBER_OF_DESCRIPTORS);
-
- /* Mark all routers as non-guards but up and running! */
- SMARTLIST_FOREACH_BEGIN(our_nodelist, node_t *, node) {
- node->is_running = 1;
- node->is_valid = 1;
- node->is_possible_guard = 0;
- } SMARTLIST_FOREACH_END(node);
-
- done:
- UNMOCK(router_descriptor_is_older_than);
-}
-
/* Unittest cleanup function: Cleanup the fake network. */
static int
fake_network_cleanup(const struct testcase_t *testcase, void *ptr)