Merge branch 'maint-0.4.5' into maint-0.4.6
[tor.git] / src / test / test_netinfo.c
blob03a7a8a90559370bff1b3c1256eb0bb07203abc4
1 /* Copyright (c) 2007-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
4 #include "orconfig.h"
5 #include "core/or/or.h"
6 #include "trunnel/netinfo.h"
7 #include "test/test.h"
9 static void
10 test_netinfo_unsupported_addr(void *arg)
12 const uint8_t wire_data[] =
13 { // TIME
14 0x00, 0x00, 0x00, 0x01,
15 // OTHERADDR
16 0x04, // ATYPE
17 0x04, // ALEN
18 0x08, 0x08, 0x08, 0x08, // AVAL
19 0x01, // NMYADDR
20 0x03, // ATYPE (unsupported)
21 0x05, // ALEN
22 'a', 'd', 'r', 'r', '!' // AVAL (unsupported)
25 (void)arg;
27 netinfo_cell_t *parsed_cell = NULL;
29 ssize_t parsed = netinfo_cell_parse(&parsed_cell, wire_data,
30 sizeof(wire_data));
32 tt_assert(parsed == sizeof(wire_data));
34 netinfo_addr_t *addr = netinfo_cell_get_my_addrs(parsed_cell, 0);
35 tt_assert(addr);
37 tt_int_op(3, OP_EQ, netinfo_addr_get_addr_type(addr));
38 tt_int_op(5, OP_EQ, netinfo_addr_get_len(addr));
40 done:
41 netinfo_cell_free(parsed_cell);
44 struct testcase_t netinfo_tests[] = {
45 { "unsupported_addr", test_netinfo_unsupported_addr, 0, NULL, NULL },
46 END_OF_TESTCASES