diff options
author | David Goulet <dgoulet@torproject.org> | 2020-02-11 10:15:04 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2020-02-11 10:15:04 -0500 |
commit | 33414e5494b56f3f677d022bfb4bb1ed99191032 (patch) | |
tree | 32619c30742fa06de03ad49dfede27077b9833f5 /src/test/test_address_set.c | |
parent | 6d9113d2f65b6e3142efdaa91a5b4761cd197be8 (diff) | |
download | tor-33414e5494b56f3f677d022bfb4bb1ed99191032.tar.gz tor-33414e5494b56f3f677d022bfb4bb1ed99191032.zip |
test: Add unit test for connection_dir_is_global_write_low()
Part of #33029
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test/test_address_set.c')
-rw-r--r-- | src/test/test_address_set.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/test/test_address_set.c b/src/test/test_address_set.c index fb8408b3c3..81dc6dff52 100644 --- a/src/test/test_address_set.c +++ b/src/test/test_address_set.c @@ -4,6 +4,7 @@ #include "core/or/or.h" #include "lib/crypt_ops/crypto_rand.h" #include "core/or/address_set.h" +#include "feature/nodelist/dirlist.h" #include "feature/nodelist/microdesc.h" #include "feature/nodelist/networkstatus.h" #include "feature/nodelist/nodelist.h" @@ -31,6 +32,12 @@ mock_networkstatus_get_latest_consensus_by_flavor(consensus_flavor_t f) return dummy_ns; } +static void +mock_dirlist_add_trusted_addresses(void) +{ + return; +} + /* Number of address a single node_t can have. Default to the production * value. This is to control the size of the bloom filter. */ static int addr_per_node = 2; @@ -98,6 +105,8 @@ test_nodelist(void *arg) mock_networkstatus_get_latest_consensus_by_flavor); MOCK(get_estimated_address_per_node, mock_get_estimated_address_per_node); + MOCK(dirlist_add_trusted_addresses, + mock_dirlist_add_trusted_addresses); dummy_ns = tor_malloc_zero(sizeof(*dummy_ns)); dummy_ns->flavor = FLAV_MICRODESC; @@ -113,7 +122,9 @@ test_nodelist(void *arg) * (the_nodelist->node_addrs) so we will fail the contain test rarely. */ addr_per_node = 1024; - /* No node no nothing. The lookups should be empty. */ + /* No node no nothing. The lookups should be empty. We've mocked the + * dirlist_add_trusted_addresses in order for _no_ authorities to be added + * to the filter else it makes this test to trigger many false positive. */ nodelist_set_consensus(dummy_ns); /* The address set should be empty. */ @@ -167,6 +178,7 @@ test_nodelist(void *arg) UNMOCK(networkstatus_get_latest_consensus); UNMOCK(networkstatus_get_latest_consensus_by_flavor); UNMOCK(get_estimated_address_per_node); + UNMOCK(dirlist_add_trusted_addresses); } struct testcase_t address_set_tests[] = { |