test_router.c 913 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. (void) arg;
  18. #define ID "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
  19. /* make sure node_get_by_id returns NULL */
  20. test_assert(!node_get_by_id(ID));
  21. test_streq(node_describe_by_id(ID),
  22. "$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
  23. done:
  24. return;
  25. }
  26. struct testcase_t router_tests[] = {
  27. { "node_get_by_id_null_node", test_node_describe_by_id_null_node, TT_FORK,
  28. NULL, NULL },
  29. END_OF_TESTCASES
  30. };