test_router.c 943 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* Copyright (c) 2007-2013, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file test_router.c
  5. * \brief Unit tests for router related functions.
  6. **/
  7. #include "or.h"
  8. #include "nodelist.h"
  9. #include "router.h"
  10. #include "test.h"
  11. /** Tese the case when node_get_by_id() returns NULL, node_describe_by_id
  12. * should return the base 16 encoding of the id.
  13. */
  14. static void
  15. test_node_describe_by_id_null_node(void *arg)
  16. {
  17. const char ID[] = "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
  18. "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA";
  19. (void) arg;
  20. /* make sure node_get_by_id returns NULL */
  21. test_assert(!node_get_by_id(ID));
  22. test_streq(node_describe_by_id(ID),
  23. "$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
  24. done:
  25. return;
  26. }
  27. struct testcase_t router_tests[] = {
  28. { "node_get_by_id_null_node", test_node_describe_by_id_null_node, TT_FORK,
  29. NULL, NULL },
  30. END_OF_TESTCASES
  31. };