aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport-testing.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-07-02 14:56:30 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-07-02 14:56:30 +0000
commitad3870165e0c80ac5ec04d5ac78251eeba13e403 (patch)
treedc96d36a90b7b776f6e32322dee68ccba18a2a3d /src/transport/transport-testing.c
parent6d9ebef7d96adad01308c135f27748ec3f6b7774 (diff)
downloadgnunet-ad3870165e0c80ac5ec04d5ac78251eeba13e403.tar.gz
gnunet-ad3870165e0c80ac5ec04d5ac78251eeba13e403.zip
porting transport testing to new testing lib (mantis 2453)
Diffstat (limited to 'src/transport/transport-testing.c')
-rw-r--r--src/transport/transport-testing.c294
1 files changed, 103 insertions, 191 deletions
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index b3c3a9399..87ce70423 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -27,31 +27,6 @@
27 27
28#include "transport-testing.h" 28#include "transport-testing.h"
29 29
30#define HOSTKEYFILESIZE 914
31
32static const char *
33get_host_key (struct GNUNET_TRANSPORT_TESTING_handle *tth)
34{
35 if (tth->hostkey_data == NULL)
36 {
37 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
38 "No precomputed hostkeys available\n");
39 return NULL;
40 }
41 if (tth->hostkeys_total > tth->hostkeys_last)
42 {
43 tth->hostkeys_last++;
44 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
45 "Used hostkey %u of %u available hostkeys\n",
46 tth->hostkeys_last, tth->hostkeys_total);
47 return &tth->hostkey_data[(tth->hostkeys_last - 1) * HOSTKEYFILESIZE];
48 }
49 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
50 "No hostkey available (%u of %u already used)\n",
51 tth->hostkeys_last, tth->hostkeys_total);
52 return NULL;
53}
54
55 30
56static struct PeerContext * 31static struct PeerContext *
57find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, 32find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth,
@@ -190,20 +165,21 @@ static void
190get_hello (void *cb_cls, const struct GNUNET_MessageHeader *message) 165get_hello (void *cb_cls, const struct GNUNET_MessageHeader *message)
191{ 166{
192 struct PeerContext *p = cb_cls; 167 struct PeerContext *p = cb_cls;
168 struct GNUNET_PeerIdentity hello_id;
193 169
194 GNUNET_assert (message != NULL); 170 GNUNET_assert (message != NULL);
195 GNUNET_assert (GNUNET_OK == 171 GNUNET_assert (GNUNET_OK ==
196 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) 172 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
197 message, &p->id)); 173 message, &hello_id));
174 GNUNET_assert (0 == memcmp (&hello_id, &p->id, sizeof (hello_id)));
198 GNUNET_free_non_null (p->hello); 175 GNUNET_free_non_null (p->hello);
199 p->hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (message); 176 p->hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (message);
200 177
201 if (p->start_cb != NULL) 178 if (NULL != p->start_cb)
202 { 179 {
203 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 180 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
204 "Peer %u (`%s') successfully started\n", p->no, 181 "Peer %u (`%s') successfully started\n", p->no,
205 GNUNET_i2s (&p->id)); 182 GNUNET_i2s (&p->id));
206
207 p->start_cb (p, p->cb_cls); 183 p->start_cb (p, p->cb_cls);
208 p->start_cb = NULL; 184 p->start_cb = NULL;
209 } 185 }
@@ -247,7 +223,7 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
247 * Start a peer with the given configuration 223 * Start a peer with the given configuration
248 * @param tth the testing handle 224 * @param tth the testing handle
249 * @param cfgname configuration file 225 * @param cfgname configuration file
250 * @param peer_id the peer_id 226 * @param peer_id a unique number to identify the peer
251 * @param rec receive callback 227 * @param rec receive callback
252 * @param nc connect callback 228 * @param nc connect callback
253 * @param nd disconnect callback 229 * @param nd disconnect callback
@@ -256,18 +232,20 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
256 * @return the peer context 232 * @return the peer context
257 */ 233 */
258struct PeerContext * 234struct PeerContext *
259GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle 235GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
260 *tth, const char *cfgname, int peer_id, 236 const char *cfgname, int peer_id,
261 GNUNET_TRANSPORT_ReceiveCallback rec, 237 GNUNET_TRANSPORT_ReceiveCallback rec,
262 GNUNET_TRANSPORT_NotifyConnect nc, 238 GNUNET_TRANSPORT_NotifyConnect nc,
263 GNUNET_TRANSPORT_NotifyDisconnect nd, 239 GNUNET_TRANSPORT_NotifyDisconnect nd,
264 GNUNET_TRANSPORT_TESTING_start_cb start_cb, 240 GNUNET_TRANSPORT_TESTING_start_cb start_cb,
265 void *cb_cls) 241 void *cb_cls)
266{ 242{
267 const char *hostkey = NULL; 243 char *emsg = NULL;
268 struct GNUNET_DISK_FileHandle *fn; 244 struct GNUNET_PeerIdentity *dummy;
245
246 GNUNET_assert (NULL != tth);
247 GNUNET_assert (NULL != tth->tl_system);
269 248
270 GNUNET_assert (tth != NULL);
271 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) 249 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO)
272 { 250 {
273 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 251 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
@@ -276,47 +254,60 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
276 } 254 }
277 255
278 struct PeerContext *p = GNUNET_malloc (sizeof (struct PeerContext)); 256 struct PeerContext *p = GNUNET_malloc (sizeof (struct PeerContext));
257 GNUNET_CONTAINER_DLL_insert (tth->p_head, tth->p_tail, p);
279 258
259 /* Create configuration and call testing lib to modify it */
280 p->cfg = GNUNET_CONFIGURATION_create (); 260 p->cfg = GNUNET_CONFIGURATION_create ();
281 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 261 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
282 262
283 if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) 263 if (GNUNET_SYSERR == GNUNET_TESTING_configuration_create (tth->tl_system, p->cfg))
284 GNUNET_assert (GNUNET_OK == 264 {
285 GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", 265 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
286 "SERVICEHOME", 266 "Testing library failed to create unique configuration based on `%s'\n",
287 &p->servicehome)); 267 cfgname);
268 GNUNET_free (p);
269 return NULL;
270 }
288 271
289 if (NULL != p->servicehome) 272 p->no = peer_id;
290 GNUNET_DISK_directory_remove (p->servicehome); 273 /* Configure peer with configuration */
274 p->peer = GNUNET_TESTING_peer_configure (tth->tl_system, p->cfg, p->no, NULL, &emsg);
275 if (NULL == p->peer)
276 {
277 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
278 "Testing library failed to create unique configuration based on `%s': `%s'\n",
279 cfgname, emsg);
280 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
281 return NULL;
282 }
291 283
292 hostkey = get_host_key (tth); 284 if (GNUNET_OK != GNUNET_TESTING_peer_start (p->peer))
293 if (hostkey != NULL)
294 { 285 {
286 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
287 "Testing library failed to create unique configuration based on `%s'\n",
288 cfgname);
289 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
290 return NULL;
291 }
295 292
296 GNUNET_asprintf (&p->hostkeyfile, "%s/.hostkey", p->servicehome); 293 memset(&dummy, '\0', sizeof (dummy));
297 GNUNET_assert (GNUNET_OK == 294 GNUNET_TESTING_peer_get_identity (p->peer, &p->id);
298 GNUNET_DISK_directory_create_for_file (p->hostkeyfile)); 295 if (0 == memcmp (&dummy, &p->id, sizeof (dummy)))
299 fn = GNUNET_DISK_file_open (p->hostkeyfile, 296 {
300 GNUNET_DISK_OPEN_READWRITE | 297 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
301 GNUNET_DISK_OPEN_CREATE, 298 "Testing library failed to obtain peer identity for peer %u\n",
302 GNUNET_DISK_PERM_USER_READ | 299 p->no);
303 GNUNET_DISK_PERM_USER_WRITE); 300 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
304 GNUNET_assert (fn != NULL); 301 return NULL;
305 GNUNET_assert (HOSTKEYFILESIZE == 302 }
306 GNUNET_DISK_file_write (fn, hostkey, HOSTKEYFILESIZE)); 303 else
307 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fn)); 304 {
308 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 305 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
309 "Wrote hostkey to file: `%s' \n", p->hostkeyfile); 306 "Peer %u configured with identity `%s'\n",
307 p->no,
308 GNUNET_i2s (&p->id));
310 } 309 }
311 310
312 p->arm_proc =
313 GNUNET_OS_start_process (GNUNET_YES,
314 NULL, NULL, "gnunet-service-arm",
315 "gnunet-service-arm", "-c", cfgname,
316 "-L", "ERROR",
317 NULL);
318
319 p->no = peer_id;
320 p->tth = tth; 311 p->tth = tth;
321 p->nc = nc; 312 p->nc = nc;
322 p->nd = nd; 313 p->nd = nd;
@@ -327,15 +318,21 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
327 else 318 else
328 p->cb_cls = p; 319 p->cb_cls = p;
329 320
330 p->th = 321 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p,
331 GNUNET_TRANSPORT_connect (p->cfg, NULL, p, &notify_receive, 322 &notify_receive,
332 &notify_connect, &notify_disconnect); 323 &notify_connect, &notify_disconnect);
333 GNUNET_assert (p->th != NULL); 324 if (NULL == p->th)
325 {
326 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
327 "Failed to connect to transport service for peer `%s': `%s'\n",
328 cfgname, emsg);
329 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
330 return NULL;
331 }
334 332
335 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); 333 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p);
336 GNUNET_assert (p->ghh != NULL); 334 GNUNET_assert (p->ghh != NULL);
337 335
338 GNUNET_CONTAINER_DLL_insert (tth->p_head, tth->p_tail, p);
339 return p; 336 return p;
340} 337}
341 338
@@ -355,93 +352,55 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle
355 GNUNET_TRANSPORT_TESTING_start_cb 352 GNUNET_TRANSPORT_TESTING_start_cb
356 restart_cb, void *cb_cls) 353 restart_cb, void *cb_cls)
357{ 354{
358 struct GNUNET_DISK_FileHandle *fn;
359
360 GNUNET_assert (tth != NULL); 355 GNUNET_assert (tth != NULL);
361 GNUNET_assert (p != NULL); 356 GNUNET_assert (p != NULL);
362 GNUNET_assert (p->hostkeyfile != NULL); 357 GNUNET_assert (NULL != p->peer);
363 GNUNET_assert (p->servicehome != NULL); 358
359 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
360 "Restarting peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id));
364 361
365 /* shutdown */ 362 /* shutdown */
366 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 363 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
367 "Stopping peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id)); 364 "Stopping peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id));
368 if (p->ghh != NULL) 365 if (NULL != p->ghh)
369 GNUNET_TRANSPORT_get_hello_cancel (p->ghh); 366 GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
370 p->ghh = NULL; 367 p->ghh = NULL;
371 368
372 if (p->th != NULL) 369 if (NULL != p->th)
373 GNUNET_TRANSPORT_disconnect (p->th); 370 GNUNET_TRANSPORT_disconnect (p->th);
374 371
375 if (NULL != p->arm_proc) 372 if (GNUNET_SYSERR == GNUNET_TESTING_peer_stop(p->peer))
376 { 373 {
377 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) 374 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
378 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 375 "Failed to stop peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id));
379 GNUNET_OS_process_wait (p->arm_proc); 376 return GNUNET_SYSERR;
380 GNUNET_OS_process_destroy (p->arm_proc);
381 p->arm_proc = NULL;
382 } 377 }
383 if (p->hello != NULL)
384 GNUNET_free (p->hello);
385 p->hello = NULL;
386
387 if (p->cfg != NULL)
388 GNUNET_CONFIGURATION_destroy (p->cfg);
389 p->cfg = NULL;
390
391 378
392 /* start */ 379 sleep (5);
393 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
394 "Restarting peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id));
395 sleep (5); // YUCK!
396 380
397 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) 381 /* restart */
382 if (GNUNET_SYSERR == GNUNET_TESTING_peer_start(p->peer))
398 { 383 {
399 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 384 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
400 "File not found: `%s' \n", cfgname); 385 "Failed to restart peer %u (`%s')\n",
401 goto fail; 386 p->no, GNUNET_i2s (&p->id));
387 return GNUNET_SYSERR;
402 } 388 }
403 389
404 p->cfg = GNUNET_CONFIGURATION_create ();
405 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
406
407 if (!GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME"))
408 goto fail;
409
410 fn = GNUNET_DISK_file_open (p->hostkeyfile,
411 GNUNET_DISK_OPEN_READWRITE |
412 GNUNET_DISK_OPEN_CREATE,
413 GNUNET_DISK_PERM_USER_READ |
414 GNUNET_DISK_PERM_USER_WRITE);
415 if (fn == NULL)
416 goto fail;
417 if (GNUNET_OK != GNUNET_DISK_file_close (fn))
418 goto fail;
419
420 p->arm_proc =
421 GNUNET_OS_start_process (GNUNET_YES,
422 NULL, NULL, "gnunet-service-arm",
423 "gnunet-service-arm", "-c", cfgname,
424 "-L", "ERROR",
425 NULL);
426
427 p->th =
428 GNUNET_TRANSPORT_connect (p->cfg, NULL, p, &notify_receive,
429 &notify_connect, &notify_disconnect);
430 GNUNET_assert (p->th != NULL); 390 GNUNET_assert (p->th != NULL);
431 391 GNUNET_assert (p->start_cb == NULL);
432 p->start_cb = restart_cb; 392 p->start_cb = restart_cb;
433 p->cb_cls = cb_cls; 393 p->cb_cls = cb_cls;
434 394
395 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p,
396 &notify_receive,
397 &notify_connect,
398 &notify_disconnect);
399 GNUNET_assert (NULL != p->th);
400
435 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); 401 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p);
436 GNUNET_assert (p->ghh != NULL); 402 GNUNET_assert (p->ghh != NULL);
437 return GNUNET_OK; 403 return GNUNET_OK;
438
439fail:
440 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
441 "Restarting peer %u (`%s') failed, removing peer\n", p->no,
442 GNUNET_i2s (&p->id));
443 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
444 return GNUNET_SYSERR;
445} 404}
446 405
447 406
@@ -461,25 +420,23 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
461 p->ghh = NULL; 420 p->ghh = NULL;
462 } 421 }
463 if (p->th != NULL) 422 if (p->th != NULL)
464 GNUNET_TRANSPORT_disconnect (p->th);
465 if (NULL != p->arm_proc)
466 {
467 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
468 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
469 GNUNET_OS_process_wait (p->arm_proc);
470 GNUNET_OS_process_destroy (p->arm_proc);
471 p->arm_proc = NULL;
472 }
473 if (p->hostkeyfile != NULL)
474 { 423 {
475 GNUNET_DISK_directory_remove (p->hostkeyfile); 424 GNUNET_TRANSPORT_disconnect (p->th);
476 GNUNET_free (p->hostkeyfile); 425 p->th = NULL;
477 } 426 }
478 if (p->servicehome != NULL) 427
428 if (p->peer != NULL)
479 { 429 {
480 GNUNET_DISK_directory_remove (p->servicehome); 430 if (GNUNET_OK != GNUNET_TESTING_peer_stop (p->peer))
481 GNUNET_free (p->servicehome); 431 {
432 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
433 "Testing lib failed to stop peer %u (`%s') \n", p->no,
434 GNUNET_i2s (&p->id));
435 }
436 GNUNET_TESTING_peer_destroy (p->peer);
437 p->peer = NULL;
482 } 438 }
439
483 if (p->hello != NULL) 440 if (p->hello != NULL)
484 { 441 {
485 GNUNET_free (p->hello); 442 GNUNET_free (p->hello);
@@ -606,8 +563,6 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth)
606 p = t; 563 p = t;
607 } 564 }
608 565
609 GNUNET_free_non_null (tth->hostkey_data);
610
611 GNUNET_TESTING_system_destroy (tth->tl_system, GNUNET_YES); 566 GNUNET_TESTING_system_destroy (tth->tl_system, GNUNET_YES);
612 567
613 GNUNET_free (tth); 568 GNUNET_free (tth);
@@ -623,16 +578,12 @@ struct GNUNET_TRANSPORT_TESTING_handle *
623GNUNET_TRANSPORT_TESTING_init () 578GNUNET_TRANSPORT_TESTING_init ()
624{ 579{
625 struct GNUNET_TRANSPORT_TESTING_handle *tth; 580 struct GNUNET_TRANSPORT_TESTING_handle *tth;
626 struct GNUNET_DISK_FileHandle *fd;
627 uint64_t fs;
628 uint64_t total_hostkeys;
629 581
630 /* prepare hostkeys */ 582 /* prepare hostkeys */
631 tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle)); 583 tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle));
632 584
633 /* Init testing the testing lib */ 585 /* Init testing the testing lib */
634 tth->tl_system = GNUNET_TESTING_system_create ("transport-testing", 586 tth->tl_system = GNUNET_TESTING_system_create ("transport-testing", NULL);
635 "127.0.0.1");
636 if (NULL == tth->tl_system) 587 if (NULL == tth->tl_system)
637 { 588 {
638 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to initialize testing library!\n")); 589 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to initialize testing library!\n"));
@@ -640,45 +591,6 @@ GNUNET_TRANSPORT_TESTING_init ()
640 return NULL; 591 return NULL;
641 } 592 }
642 593
643 tth->hostkey_data = NULL;
644 const char *hostkeys_file = "../../contrib/testing_hostkeys.dat";
645
646 if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file))
647 {
648 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not read hostkeys file!\n"));
649 }
650 else
651 {
652 /* Check hostkey file size, read entire thing into memory */
653 fd = GNUNET_DISK_file_open (hostkeys_file, GNUNET_DISK_OPEN_READ,
654 GNUNET_DISK_PERM_NONE);
655 if (NULL == fd)
656 {
657 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", hostkeys_file);
658 GNUNET_free (tth);
659 return NULL;
660 }
661
662 if (GNUNET_OK != GNUNET_DISK_file_size (hostkeys_file, &fs, GNUNET_YES, GNUNET_YES))
663 fs = 0;
664
665 if (0 != (fs % HOSTKEYFILESIZE))
666 {
667 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
668 "File size %llu seems incorrect for hostkeys...\n", fs);
669 }
670 else
671 {
672 total_hostkeys = fs / HOSTKEYFILESIZE;
673 tth->hostkey_data = GNUNET_malloc_large (fs);
674 GNUNET_assert (fs == GNUNET_DISK_file_read (fd, tth->hostkey_data, fs));
675 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
676 "Read %llu hostkeys from file\n", total_hostkeys);
677 tth->hostkeys_total = total_hostkeys;
678 }
679 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
680 }
681
682 return tth; 594 return tth;
683} 595}
684 596