mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
Add routerset_contains_router() test
This commit is contained in:
parent
6209939e86
commit
c3c7ef5125
@ -1417,12 +1417,62 @@ test_rset_contains_router(void *arg)
|
||||
ri.nickname = (char *)nickname;
|
||||
|
||||
r = routerset_contains_router(set, &ri, country);
|
||||
|
||||
tt_int_op(r, OP_EQ, 4);
|
||||
|
||||
done:
|
||||
routerset_free(set);
|
||||
}
|
||||
|
||||
static void
|
||||
test_rset_contains_router_ipv4(void *arg)
|
||||
{
|
||||
routerset_t *set;
|
||||
routerinfo_t ri;
|
||||
country_t country = 1;
|
||||
int r;
|
||||
const char *s;
|
||||
(void) arg;
|
||||
|
||||
/* IPv4 address test. */
|
||||
memset(&ri, 0, sizeof(ri));
|
||||
set = routerset_new();
|
||||
s = "10.0.0.1";
|
||||
r = routerset_parse(set, s, "");
|
||||
ri.addr = htonl(0x0a000001); /* 10.0.0.1 */
|
||||
ri.or_port = 1234;
|
||||
|
||||
r = routerset_contains_router(set, &ri, country);
|
||||
tt_int_op(r, OP_EQ, 3);
|
||||
|
||||
done:
|
||||
routerset_free(set);
|
||||
}
|
||||
|
||||
static void
|
||||
test_rset_contains_router_ipv6(void *arg)
|
||||
{
|
||||
routerset_t *set;
|
||||
routerinfo_t ri;
|
||||
country_t country = 1;
|
||||
int r;
|
||||
const char *s;
|
||||
(void) arg;
|
||||
|
||||
/* IPv6 address test. */
|
||||
memset(&ri, 0, sizeof(ri));
|
||||
set = routerset_new();
|
||||
s = "2600::1";
|
||||
r = routerset_parse(set, s, "");
|
||||
tor_addr_parse(&ri.ipv6_addr, "2600::1");
|
||||
ri.ipv6_orport = 12345;
|
||||
|
||||
r = routerset_contains_router(set, &ri, country);
|
||||
tt_int_op(r, OP_EQ, 3);
|
||||
|
||||
done:
|
||||
routerset_free(set);
|
||||
}
|
||||
|
||||
/*
|
||||
* Functional test for routerset_contains_routerstatus.
|
||||
*/
|
||||
@ -2144,6 +2194,10 @@ struct testcase_t routerset_tests[] = {
|
||||
{ "contains_extendinfo", test_rset_contains_extendinfo,
|
||||
TT_FORK, NULL, NULL },
|
||||
{ "contains_router", test_rset_contains_router, TT_FORK, NULL, NULL },
|
||||
{ "contains_router_ipv4", test_rset_contains_router_ipv4,
|
||||
TT_FORK, NULL, NULL },
|
||||
{ "contains_router_ipv6", test_rset_contains_router_ipv6,
|
||||
TT_FORK, NULL, NULL },
|
||||
{ "contains_routerstatus", test_rset_contains_routerstatus,
|
||||
TT_FORK, NULL, NULL },
|
||||
{ "contains_none", test_rset_contains_none, TT_FORK, NULL, NULL },
|
||||
|
Loading…
Reference in New Issue
Block a user