test_relaycell.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. /* Copyright (c) 2014-2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /* Unit tests for handling different kinds of relay cell */
  4. #define RELAY_PRIVATE
  5. #define CIRCUITLIST_PRIVATE
  6. #include "or.h"
  7. #include "main.h"
  8. #include "config.h"
  9. #include "connection.h"
  10. #include "crypto.h"
  11. #include "circuitbuild.h"
  12. #include "circuitlist.h"
  13. #include "connection_edge.h"
  14. #include "relay.h"
  15. #include "test.h"
  16. static int srm_ncalls;
  17. static entry_connection_t *srm_conn;
  18. static int srm_atype;
  19. static size_t srm_alen;
  20. static int srm_answer_is_set;
  21. static uint8_t srm_answer[512];
  22. static int srm_ttl;
  23. static time_t srm_expires;
  24. void connection_free_minimal(connection_t*);
  25. int connected_cell_format_payload(uint8_t *payload_out,
  26. const tor_addr_t *addr,
  27. uint32_t ttl);
  28. /* Mock replacement for connection_ap_hannshake_socks_resolved() */
  29. static void
  30. socks_resolved_mock(entry_connection_t *conn,
  31. int answer_type,
  32. size_t answer_len,
  33. const uint8_t *answer,
  34. int ttl,
  35. time_t expires)
  36. {
  37. srm_ncalls++;
  38. srm_conn = conn;
  39. srm_atype = answer_type;
  40. srm_alen = answer_len;
  41. if (answer) {
  42. memset(srm_answer, 0, sizeof(srm_answer));
  43. memcpy(srm_answer, answer, answer_len < 512 ? answer_len : 512);
  44. srm_answer_is_set = 1;
  45. } else {
  46. srm_answer_is_set = 0;
  47. }
  48. srm_ttl = ttl;
  49. srm_expires = expires;
  50. }
  51. static int mum_ncalls;
  52. static entry_connection_t *mum_conn;
  53. static int mum_endreason;
  54. /* Mock replacement for connection_mark_unattached_ap_() */
  55. static void
  56. mark_unattached_mock(entry_connection_t *conn, int endreason,
  57. int line, const char *file)
  58. {
  59. ++mum_ncalls;
  60. mum_conn = conn;
  61. mum_endreason = endreason;
  62. (void) line;
  63. (void) file;
  64. }
  65. /* Helper: Return a newly allocated and initialized origin circuit with
  66. * purpose and flags. A default HS identifier is set to an ed25519
  67. * authentication key for introduction point. */
  68. static origin_circuit_t *
  69. helper_create_origin_circuit(int purpose, int flags)
  70. {
  71. origin_circuit_t *circ = NULL;
  72. circ = origin_circuit_init(purpose, flags);
  73. tor_assert(circ);
  74. circ->cpath = tor_malloc_zero(sizeof(crypt_path_t));
  75. circ->cpath->magic = CRYPT_PATH_MAGIC;
  76. circ->cpath->state = CPATH_STATE_OPEN;
  77. circ->cpath->package_window = circuit_initial_package_window();
  78. circ->cpath->deliver_window = CIRCWINDOW_START;
  79. circ->cpath->prev = circ->cpath;
  80. /* Create a default HS identifier. */
  81. circ->hs_ident = tor_malloc_zero(sizeof(hs_ident_circuit_t));
  82. return circ;
  83. }
  84. static void
  85. mock_connection_mark_unattached_ap_(entry_connection_t *conn, int endreason,
  86. int line, const char *file)
  87. {
  88. (void) line;
  89. (void) file;
  90. conn->edge_.end_reason = endreason;
  91. }
  92. static void
  93. mock_mark_for_close(connection_t *conn,
  94. int line, const char *file)
  95. {
  96. (void)line;
  97. (void)file;
  98. conn->marked_for_close = 1;
  99. return;
  100. }
  101. static void
  102. mock_start_reading(connection_t *conn)
  103. {
  104. (void)conn;
  105. return;
  106. }
  107. static void
  108. test_circbw_relay(void *arg)
  109. {
  110. cell_t cell;
  111. relay_header_t rh;
  112. tor_addr_t addr;
  113. edge_connection_t *edgeconn;
  114. entry_connection_t *entryconn;
  115. origin_circuit_t *circ;
  116. int delivered = 0;
  117. int overhead = 0;
  118. (void)arg;
  119. #define PACK_CELL(id, cmd, body_s) do { \
  120. memset(&cell, 0, sizeof(cell)); \
  121. memset(&rh, 0, sizeof(rh)); \
  122. memcpy(cell.payload+RELAY_HEADER_SIZE, (body_s), sizeof((body_s))-1); \
  123. rh.length = sizeof((body_s))-1; \
  124. rh.command = (cmd); \
  125. rh.stream_id = (id); \
  126. relay_header_pack((uint8_t*)&cell.payload, &rh); \
  127. } while (0)
  128. #define ASSERT_COUNTED_BW() do { \
  129. tt_int_op(circ->n_delivered_read_circ_bw, OP_EQ, delivered+rh.length); \
  130. tt_int_op(circ->n_overhead_read_circ_bw, OP_EQ, \
  131. overhead+RELAY_PAYLOAD_SIZE-rh.length); \
  132. delivered = circ->n_delivered_read_circ_bw; \
  133. overhead = circ->n_overhead_read_circ_bw; \
  134. } while (0)
  135. #define ASSERT_UNCOUNTED_BW() do { \
  136. tt_int_op(circ->n_delivered_read_circ_bw, OP_EQ, delivered); \
  137. tt_int_op(circ->n_overhead_read_circ_bw, OP_EQ, overhead); \
  138. } while (0)
  139. MOCK(connection_mark_unattached_ap_, mock_connection_mark_unattached_ap_);
  140. MOCK(connection_start_reading, mock_start_reading);
  141. MOCK(connection_mark_for_close_internal_, mock_mark_for_close);
  142. entryconn = entry_connection_new(CONN_TYPE_AP, AF_INET);
  143. edgeconn = ENTRY_TO_EDGE_CONN(entryconn);
  144. edgeconn->base_.state = AP_CONN_STATE_CONNECT_WAIT;
  145. edgeconn->deliver_window = 1000;
  146. circ = helper_create_origin_circuit(CIRCUIT_PURPOSE_C_GENERAL, 0);
  147. edgeconn->cpath_layer = circ->cpath;
  148. circ->cpath->state = CPATH_STATE_AWAITING_KEYS;
  149. circ->cpath->deliver_window = 1000;
  150. /* Stream id 0: Not counted */
  151. PACK_CELL(0, RELAY_COMMAND_END, "Data1234");
  152. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
  153. circ->cpath);
  154. ASSERT_UNCOUNTED_BW();
  155. /* Stream id 1: Counted */
  156. PACK_CELL(1, RELAY_COMMAND_END, "Data1234");
  157. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
  158. circ->cpath);
  159. ASSERT_COUNTED_BW();
  160. /* Properly formatted connect cell: counted */
  161. PACK_CELL(1, RELAY_COMMAND_CONNECTED, "Data1234");
  162. tor_addr_parse(&addr, "30.40.50.60");
  163. rh.length = connected_cell_format_payload(cell.payload+RELAY_HEADER_SIZE,
  164. &addr, 1024);
  165. relay_header_pack((uint8_t*)&cell.payload, &rh); \
  166. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
  167. circ->cpath);
  168. ASSERT_COUNTED_BW();
  169. /* Properly formatted resolved cell in correct state: counted */
  170. edgeconn->base_.state = AP_CONN_STATE_RESOLVE_WAIT;
  171. entryconn->socks_request->command = SOCKS_COMMAND_RESOLVE;
  172. edgeconn->on_circuit = TO_CIRCUIT(circ);
  173. PACK_CELL(1, RELAY_COMMAND_RESOLVED,
  174. "\x04\x04\x12\x00\x00\x01\x00\x00\x02\x00");
  175. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
  176. circ->cpath);
  177. ASSERT_COUNTED_BW();
  178. edgeconn->base_.state = AP_CONN_STATE_OPEN;
  179. entryconn->socks_request->has_finished = 1;
  180. /* Connected cell after open: not counted */
  181. PACK_CELL(1, RELAY_COMMAND_CONNECTED, "Data1234");
  182. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
  183. circ->cpath);
  184. ASSERT_UNCOUNTED_BW();
  185. /* Resolved cell after open: not counted */
  186. PACK_CELL(1, RELAY_COMMAND_RESOLVED, "Data1234");
  187. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
  188. circ->cpath);
  189. ASSERT_UNCOUNTED_BW();
  190. /* Drop cell: not counted */
  191. PACK_CELL(1, RELAY_COMMAND_DROP, "Data1234");
  192. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
  193. circ->cpath);
  194. ASSERT_UNCOUNTED_BW();
  195. /* Data cell on stream 0: not counted */
  196. PACK_CELL(0, RELAY_COMMAND_DATA, "Data1234");
  197. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
  198. circ->cpath);
  199. ASSERT_UNCOUNTED_BW();
  200. /* Data cell on open connection: counted */
  201. ENTRY_TO_CONN(entryconn)->marked_for_close = 0;
  202. PACK_CELL(1, RELAY_COMMAND_DATA, "Data1234");
  203. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
  204. circ->cpath);
  205. ASSERT_COUNTED_BW();
  206. /* Sendme on stream: not counted */
  207. ENTRY_TO_CONN(entryconn)->outbuf_flushlen = 0;
  208. PACK_CELL(1, RELAY_COMMAND_SENDME, "Data1234");
  209. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
  210. circ->cpath);
  211. ASSERT_UNCOUNTED_BW();
  212. /* Sendme on circuit with full window: not counted */
  213. PACK_CELL(0, RELAY_COMMAND_SENDME, "Data1234");
  214. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
  215. circ->cpath);
  216. ASSERT_UNCOUNTED_BW();
  217. /* Sendme on circuit with non-full window: counted */
  218. PACK_CELL(0, RELAY_COMMAND_SENDME, "Data1234");
  219. circ->cpath->package_window = 900;
  220. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
  221. circ->cpath);
  222. ASSERT_COUNTED_BW();
  223. /* End cell on non-closed connection: counted */
  224. PACK_CELL(1, RELAY_COMMAND_END, "Data1234");
  225. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
  226. circ->cpath);
  227. ASSERT_COUNTED_BW();
  228. /* End cell on connection that already got one: not counted */
  229. PACK_CELL(1, RELAY_COMMAND_END, "Data1234");
  230. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
  231. circ->cpath);
  232. ASSERT_UNCOUNTED_BW();
  233. /* Invalid extended cell: not counted */
  234. PACK_CELL(1, RELAY_COMMAND_EXTENDED2, "Data1234");
  235. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
  236. circ->cpath);
  237. ASSERT_UNCOUNTED_BW();
  238. /* Invalid extended cell: not counted */
  239. PACK_CELL(1, RELAY_COMMAND_EXTENDED, "Data1234");
  240. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
  241. circ->cpath);
  242. ASSERT_UNCOUNTED_BW();
  243. /* Invalid HS cell: not counted */
  244. PACK_CELL(1, RELAY_COMMAND_ESTABLISH_INTRO, "Data1234");
  245. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
  246. circ->cpath);
  247. ASSERT_UNCOUNTED_BW();
  248. /* "Valid" HS cell in expected state: counted */
  249. TO_CIRCUIT(circ)->purpose = CIRCUIT_PURPOSE_C_ESTABLISH_REND;
  250. PACK_CELL(1, RELAY_COMMAND_RENDEZVOUS_ESTABLISHED, "Data1234");
  251. connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
  252. circ->cpath);
  253. ASSERT_COUNTED_BW();
  254. done:
  255. UNMOCK(connection_start_reading);
  256. UNMOCK(connection_mark_unattached_ap_);
  257. UNMOCK(connection_mark_for_close_internal_);
  258. circuit_free_(TO_CIRCUIT(circ));
  259. connection_free_minimal(ENTRY_TO_CONN(entryconn));
  260. }
  261. /* Tests for connection_edge_process_resolved_cell().
  262. The point of ..process_resolved_cell() is to handle an incoming cell
  263. on an entry connection, and call connection_mark_unattached_ap() and/or
  264. connection_ap_handshake_socks_resolved().
  265. */
  266. static void
  267. test_relaycell_resolved(void *arg)
  268. {
  269. entry_connection_t *entryconn;
  270. edge_connection_t *edgeconn;
  271. cell_t cell;
  272. relay_header_t rh;
  273. int r;
  274. or_options_t *options = get_options_mutable();
  275. #define SET_CELL(s) do { \
  276. memset(&cell, 0, sizeof(cell)); \
  277. memset(&rh, 0, sizeof(rh)); \
  278. memcpy(cell.payload + RELAY_HEADER_SIZE, (s), sizeof((s))-1); \
  279. rh.length = sizeof((s))-1; \
  280. rh.command = RELAY_COMMAND_RESOLVED; \
  281. } while (0)
  282. #define MOCK_RESET() do { \
  283. srm_ncalls = mum_ncalls = 0; \
  284. } while (0)
  285. #define ASSERT_MARK_CALLED(reason) do { \
  286. tt_int_op(mum_ncalls, OP_EQ, 1); \
  287. tt_ptr_op(mum_conn, OP_EQ, entryconn); \
  288. tt_int_op(mum_endreason, OP_EQ, (reason)); \
  289. } while (0)
  290. #define ASSERT_RESOLVED_CALLED(atype, answer, ttl, expires) do { \
  291. tt_int_op(srm_ncalls, OP_EQ, 1); \
  292. tt_ptr_op(srm_conn, OP_EQ, entryconn); \
  293. tt_int_op(srm_atype, OP_EQ, (atype)); \
  294. if ((answer) != NULL) { \
  295. tt_int_op(srm_alen, OP_EQ, sizeof(answer)-1); \
  296. tt_int_op(srm_alen, OP_LT, 512); \
  297. tt_int_op(srm_answer_is_set, OP_EQ, 1); \
  298. tt_mem_op(srm_answer, OP_EQ, answer, sizeof(answer)-1); \
  299. } else { \
  300. tt_int_op(srm_answer_is_set, OP_EQ, 0); \
  301. } \
  302. tt_int_op(srm_ttl, OP_EQ, ttl); \
  303. tt_i64_op(srm_expires, OP_EQ, expires); \
  304. } while (0)
  305. (void)arg;
  306. MOCK(connection_mark_unattached_ap_, mark_unattached_mock);
  307. MOCK(connection_ap_handshake_socks_resolved, socks_resolved_mock);
  308. options->ClientDNSRejectInternalAddresses = 0;
  309. SET_CELL(/* IPv4: 127.0.1.2, ttl 256 */
  310. "\x04\x04\x7f\x00\x01\x02\x00\x00\x01\x00"
  311. /* IPv4: 18.0.0.1, ttl 512 */
  312. "\x04\x04\x12\x00\x00\x01\x00\x00\x02\x00"
  313. /* IPv6: 2003::3, ttl 1024 */
  314. "\x06\x10"
  315. "\x20\x02\x00\x00\x00\x00\x00\x00"
  316. "\x00\x00\x00\x00\x00\x00\x00\x03"
  317. "\x00\x00\x04\x00");
  318. entryconn = entry_connection_new(CONN_TYPE_AP, AF_INET);
  319. edgeconn = ENTRY_TO_EDGE_CONN(entryconn);
  320. /* Try with connection in non-RESOLVE_WAIT state: cell gets ignored */
  321. MOCK_RESET();
  322. r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
  323. tt_int_op(r, OP_EQ, 0);
  324. tt_int_op(srm_ncalls, OP_EQ, 0);
  325. tt_int_op(mum_ncalls, OP_EQ, 0);
  326. /* Now put it in the right state. */
  327. ENTRY_TO_CONN(entryconn)->state = AP_CONN_STATE_RESOLVE_WAIT;
  328. entryconn->socks_request->command = SOCKS_COMMAND_RESOLVE;
  329. entryconn->entry_cfg.ipv4_traffic = 1;
  330. entryconn->entry_cfg.ipv6_traffic = 1;
  331. entryconn->entry_cfg.prefer_ipv6 = 0;
  332. /* We prefer ipv4, so we should get the first ipv4 answer */
  333. MOCK_RESET();
  334. r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
  335. tt_int_op(r, OP_EQ, 0);
  336. ASSERT_MARK_CALLED(END_STREAM_REASON_DONE|
  337. END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
  338. ASSERT_RESOLVED_CALLED(RESOLVED_TYPE_IPV4, "\x7f\x00\x01\x02", 256, -1);
  339. /* But we may be discarding private answers. */
  340. MOCK_RESET();
  341. options->ClientDNSRejectInternalAddresses = 1;
  342. r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
  343. tt_int_op(r, OP_EQ, 0);
  344. ASSERT_MARK_CALLED(END_STREAM_REASON_DONE|
  345. END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
  346. ASSERT_RESOLVED_CALLED(RESOLVED_TYPE_IPV4, "\x12\x00\x00\x01", 512, -1);
  347. /* now prefer ipv6, and get the first ipv6 answer */
  348. entryconn->entry_cfg.prefer_ipv6 = 1;
  349. MOCK_RESET();
  350. r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
  351. tt_int_op(r, OP_EQ, 0);
  352. ASSERT_MARK_CALLED(END_STREAM_REASON_DONE|
  353. END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
  354. ASSERT_RESOLVED_CALLED(RESOLVED_TYPE_IPV6,
  355. "\x20\x02\x00\x00\x00\x00\x00\x00"
  356. "\x00\x00\x00\x00\x00\x00\x00\x03",
  357. 1024, -1);
  358. /* With a cell that only has IPv4, we report IPv4 even if we prefer IPv6 */
  359. MOCK_RESET();
  360. SET_CELL("\x04\x04\x12\x00\x00\x01\x00\x00\x02\x00");
  361. r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
  362. tt_int_op(r, OP_EQ, 0);
  363. ASSERT_MARK_CALLED(END_STREAM_REASON_DONE|
  364. END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
  365. ASSERT_RESOLVED_CALLED(RESOLVED_TYPE_IPV4, "\x12\x00\x00\x01", 512, -1);
  366. /* But if we don't allow IPv4, we report nothing if the cell contains only
  367. * ipv4 */
  368. MOCK_RESET();
  369. entryconn->entry_cfg.ipv4_traffic = 0;
  370. r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
  371. tt_int_op(r, OP_EQ, 0);
  372. ASSERT_MARK_CALLED(END_STREAM_REASON_DONE|
  373. END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
  374. ASSERT_RESOLVED_CALLED(RESOLVED_TYPE_ERROR, NULL, -1, -1);
  375. /* If we wanted hostnames, we report nothing, since we only had IPs. */
  376. MOCK_RESET();
  377. entryconn->entry_cfg.ipv4_traffic = 1;
  378. entryconn->socks_request->command = SOCKS_COMMAND_RESOLVE_PTR;
  379. r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
  380. tt_int_op(r, OP_EQ, 0);
  381. ASSERT_MARK_CALLED(END_STREAM_REASON_DONE|
  382. END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
  383. ASSERT_RESOLVED_CALLED(RESOLVED_TYPE_ERROR, NULL, -1, -1);
  384. /* A hostname cell is fine though. */
  385. MOCK_RESET();
  386. SET_CELL("\x00\x0fwww.example.com\x00\x01\x00\x00");
  387. r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
  388. tt_int_op(r, OP_EQ, 0);
  389. ASSERT_MARK_CALLED(END_STREAM_REASON_DONE|
  390. END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
  391. ASSERT_RESOLVED_CALLED(RESOLVED_TYPE_HOSTNAME, "www.example.com", 65536, -1);
  392. /* error on malformed cell */
  393. MOCK_RESET();
  394. entryconn->socks_request->command = SOCKS_COMMAND_RESOLVE;
  395. SET_CELL("\x04\x04\x01\x02\x03\x04"); /* no ttl */
  396. r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
  397. tt_int_op(r, OP_EQ, 0);
  398. ASSERT_MARK_CALLED(END_STREAM_REASON_TORPROTOCOL);
  399. tt_int_op(srm_ncalls, OP_EQ, 0);
  400. /* error on all addresses private */
  401. MOCK_RESET();
  402. SET_CELL(/* IPv4: 127.0.1.2, ttl 256 */
  403. "\x04\x04\x7f\x00\x01\x02\x00\x00\x01\x00"
  404. /* IPv4: 192.168.1.1, ttl 256 */
  405. "\x04\x04\xc0\xa8\x01\x01\x00\x00\x01\x00");
  406. r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
  407. tt_int_op(r, OP_EQ, 0);
  408. ASSERT_MARK_CALLED(END_STREAM_REASON_TORPROTOCOL);
  409. ASSERT_RESOLVED_CALLED(RESOLVED_TYPE_ERROR_TRANSIENT, NULL, 0, TIME_MAX);
  410. /* Legit error code */
  411. MOCK_RESET();
  412. SET_CELL("\xf0\x15" "quiet and meaningless" "\x00\x00\x0f\xff");
  413. r = connection_edge_process_resolved_cell(edgeconn, &cell, &rh);
  414. tt_int_op(r, OP_EQ, 0);
  415. ASSERT_MARK_CALLED(END_STREAM_REASON_DONE|
  416. END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
  417. ASSERT_RESOLVED_CALLED(RESOLVED_TYPE_ERROR_TRANSIENT, NULL, -1, -1);
  418. done:
  419. UNMOCK(connection_mark_unattached_ap_);
  420. UNMOCK(connection_ap_handshake_socks_resolved);
  421. }
  422. struct testcase_t relaycell_tests[] = {
  423. { "resolved", test_relaycell_resolved, TT_FORK, NULL, NULL },
  424. { "circbw", test_circbw_relay, TT_FORK, NULL, NULL },
  425. END_OF_TESTCASES
  426. };