"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/test/test_address_set.c" between
tor-0.4.6.5.tar.gz and tor-0.4.6.6.tar.gz

About: Tor is an anonymous Internet communication system - a network of virtual tunnels that allows people and groups to improve their privacy and security on the Internet.

test_address_set.c  (tor-0.4.6.5):test_address_set.c  (tor-0.4.6.6)
skipping to change at line 20 skipping to change at line 20
#include "feature/nodelist/nodelist.h" #include "feature/nodelist/nodelist.h"
#include "feature/nodelist/routerlist.h" #include "feature/nodelist/routerlist.h"
#include "feature/nodelist/torcert.h" #include "feature/nodelist/torcert.h"
#include "feature/nodelist/microdesc_st.h" #include "feature/nodelist/microdesc_st.h"
#include "feature/nodelist/networkstatus_st.h" #include "feature/nodelist/networkstatus_st.h"
#include "feature/nodelist/routerinfo_st.h" #include "feature/nodelist/routerinfo_st.h"
#include "feature/nodelist/routerstatus_st.h" #include "feature/nodelist/routerstatus_st.h"
#include "test/test.h" #include "test/test.h"
#include "test/rng_test_helpers.h"
static networkstatus_t *dummy_ns = NULL; static networkstatus_t *dummy_ns = NULL;
static networkstatus_t * static networkstatus_t *
mock_networkstatus_get_latest_consensus(void) mock_networkstatus_get_latest_consensus(void)
{ {
return dummy_ns; return dummy_ns;
} }
static networkstatus_t * static networkstatus_t *
mock_networkstatus_get_latest_consensus_by_flavor(consensus_flavor_t f) mock_networkstatus_get_latest_consensus_by_flavor(consensus_flavor_t f)
skipping to change at line 65 skipping to change at line 66
(void) arg; (void) arg;
/* Setup an IPv4 and IPv6 addresses. */ /* Setup an IPv4 and IPv6 addresses. */
tor_addr_t addr_v6; tor_addr_t addr_v6;
tor_addr_parse(&addr_v6, "1:2:3:4::"); tor_addr_parse(&addr_v6, "1:2:3:4::");
tor_addr_t addr_v4; tor_addr_t addr_v4;
tor_addr_parse(&addr_v4, "42.42.42.42"); tor_addr_parse(&addr_v4, "42.42.42.42");
uint32_t ipv4h = tor_addr_to_ipv4h(&addr_v4); uint32_t ipv4h = tor_addr_to_ipv4h(&addr_v4);
/* Use our deterministic RNG since the address set uses a bloom filter
* internally. */
testing_enable_deterministic_rng();
/* Make it very big so the chance of failing the contain test will be /* Make it very big so the chance of failing the contain test will be
* extremely rare. */ * extremely rare. */
set = address_set_new(1024); set = address_set_new(1024);
tt_assert(set); tt_assert(set);
/* Add and lookup IPv6. */ /* Add and lookup IPv6. */
address_set_add(set, &addr_v6); address_set_add(set, &addr_v6);
ret = address_set_probably_contains(set, &addr_v6); ret = address_set_probably_contains(set, &addr_v6);
tt_int_op(ret, OP_EQ, 1); tt_int_op(ret, OP_EQ, 1);
skipping to change at line 92 skipping to change at line 97
memset(&dummy_addr, 'A', sizeof(dummy_addr)); memset(&dummy_addr, 'A', sizeof(dummy_addr));
dummy_addr.family = AF_INET; dummy_addr.family = AF_INET;
ret = address_set_probably_contains(set, &dummy_addr); ret = address_set_probably_contains(set, &dummy_addr);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
dummy_addr.family = AF_INET6; dummy_addr.family = AF_INET6;
ret = address_set_probably_contains(set, &dummy_addr); ret = address_set_probably_contains(set, &dummy_addr);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
done: done:
address_set_free(set); address_set_free(set);
testing_disable_deterministic_rng();
} }
static void static void
test_nodelist(void *arg) test_nodelist(void *arg)
{ {
int ret; int ret;
routerstatus_t *rs = NULL; microdesc_t *md = NULL; routerinfo_t *ri = NULL; routerstatus_t *rs = NULL; microdesc_t *md = NULL; routerinfo_t *ri = NULL;
(void) arg; (void) arg;
MOCK(networkstatus_get_latest_consensus, MOCK(networkstatus_get_latest_consensus,
mock_networkstatus_get_latest_consensus); mock_networkstatus_get_latest_consensus);
MOCK(networkstatus_get_latest_consensus_by_flavor, MOCK(networkstatus_get_latest_consensus_by_flavor,
mock_networkstatus_get_latest_consensus_by_flavor); mock_networkstatus_get_latest_consensus_by_flavor);
MOCK(get_estimated_address_per_node, MOCK(get_estimated_address_per_node,
mock_get_estimated_address_per_node); mock_get_estimated_address_per_node);
MOCK(dirlist_add_trusted_dir_addresses, MOCK(dirlist_add_trusted_dir_addresses,
mock_dirlist_add_trusted_dir_addresses); mock_dirlist_add_trusted_dir_addresses);
/* Use our deterministic RNG since the address set, used for
* nodelist_probably_contains_address() uses a bloom filter internally. */
testing_enable_deterministic_rng();
dummy_ns = tor_malloc_zero(sizeof(*dummy_ns)); dummy_ns = tor_malloc_zero(sizeof(*dummy_ns));
dummy_ns->flavor = FLAV_MICRODESC; dummy_ns->flavor = FLAV_MICRODESC;
dummy_ns->routerstatus_list = smartlist_new(); dummy_ns->routerstatus_list = smartlist_new();
tor_addr_t addr_v4, addr_v6, dummy_addr; tor_addr_t addr_v4, addr_v6, dummy_addr;
tor_addr_parse(&addr_v4, "42.42.42.42"); tor_addr_parse(&addr_v4, "42.42.42.42");
tor_addr_parse(&addr_v6, "1:2:3:4::"); tor_addr_parse(&addr_v6, "1:2:3:4::");
memset(&dummy_addr, 'A', sizeof(dummy_addr)); memset(&dummy_addr, 'A', sizeof(dummy_addr));
/* This will make the nodelist bloom filter very large /* This will make the nodelist bloom filter very large
skipping to change at line 182 skipping to change at line 193
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
done: done:
routerstatus_free(rs); routerinfo_free(ri); microdesc_free(md); routerstatus_free(rs); routerinfo_free(ri); microdesc_free(md);
smartlist_clear(dummy_ns->routerstatus_list); smartlist_clear(dummy_ns->routerstatus_list);
networkstatus_vote_free(dummy_ns); networkstatus_vote_free(dummy_ns);
UNMOCK(networkstatus_get_latest_consensus); UNMOCK(networkstatus_get_latest_consensus);
UNMOCK(networkstatus_get_latest_consensus_by_flavor); UNMOCK(networkstatus_get_latest_consensus_by_flavor);
UNMOCK(get_estimated_address_per_node); UNMOCK(get_estimated_address_per_node);
UNMOCK(dirlist_add_trusted_dir_addresses); UNMOCK(dirlist_add_trusted_dir_addresses);
testing_disable_deterministic_rng();
} }
/** Test that the no-reentry exit filter works as intended */ /** Test that the no-reentry exit filter works as intended */
static void static void
test_exit_no_reentry(void *arg) test_exit_no_reentry(void *arg)
{ {
routerstatus_t *rs = NULL; microdesc_t *md = NULL; routerinfo_t *ri = NULL; routerstatus_t *rs = NULL; microdesc_t *md = NULL; routerinfo_t *ri = NULL;
(void) arg; (void) arg;
MOCK(networkstatus_get_latest_consensus, MOCK(networkstatus_get_latest_consensus,
 End of changes. 5 change blocks. 
0 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)