aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_router.c
blob: 5e816564d9004d9e58f6eaea6cf1a7e96818fee1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Copyright (c) 2007-2013, The Tor Project, Inc. */
/* See LICENSE for licensing information */

/**
 * \file test_router.c
 * \brief Unit tests for router related functions.
 **/

#include "or.h"
#include "nodelist.h"
#include "router.h"
#include "test.h"

/** Tese the case when node_get_by_id() returns NULL, node_describe_by_id
 * should return the base 16 encoding of the id.
 */
static void
test_node_describe_by_id_null_node(void *arg)
{
  const char ID[] = "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
                    "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA";
  (void) arg;

  /* make sure node_get_by_id returns NULL */
  test_assert(!node_get_by_id(ID));
  test_streq(node_describe_by_id(ID),
              "$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
 done:
  return;
}

struct testcase_t router_tests[] = {
  { "node_get_by_id_null_node", test_node_describe_by_id_null_node, TT_FORK,
    NULL, NULL },
  END_OF_TESTCASES
};