Line data Source code
1 : /* Copyright (c) 2007-2021, The Tor Project, Inc. */
2 : /* See LICENSE for licensing information */
3 :
4 : #include "orconfig.h"
5 : #include "core/or/or.h"
6 : #include "trunnel/netinfo.h"
7 : #include "test/test.h"
8 :
9 : static void
10 1 : test_netinfo_unsupported_addr(void *arg)
11 : {
12 1 : 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)
23 : };
24 :
25 1 : (void)arg;
26 :
27 1 : netinfo_cell_t *parsed_cell = NULL;
28 :
29 1 : ssize_t parsed = netinfo_cell_parse(&parsed_cell, wire_data,
30 : sizeof(wire_data));
31 :
32 1 : tt_assert(parsed == sizeof(wire_data));
33 :
34 1 : netinfo_addr_t *addr = netinfo_cell_get_my_addrs(parsed_cell, 0);
35 1 : tt_assert(addr);
36 :
37 1 : tt_int_op(3, OP_EQ, netinfo_addr_get_addr_type(addr));
38 1 : tt_int_op(5, OP_EQ, netinfo_addr_get_len(addr));
39 :
40 1 : done:
41 1 : netinfo_cell_free(parsed_cell);
42 1 : }
43 :
44 : struct testcase_t netinfo_tests[] = {
45 : { "unsupported_addr", test_netinfo_unsupported_addr, 0, NULL, NULL },
46 : END_OF_TESTCASES
47 : };
48 :
|