aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_unreliability_constant.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api_unreliability_constant.c')
-rw-r--r--src/transport/test_transport_api_unreliability_constant.c48
1 files changed, 37 insertions, 11 deletions
diff --git a/src/transport/test_transport_api_unreliability_constant.c b/src/transport/test_transport_api_unreliability_constant.c
index d7c70df83..670e34f7a 100644
--- a/src/transport/test_transport_api_unreliability_constant.c
+++ b/src/transport/test_transport_api_unreliability_constant.c
@@ -71,6 +71,8 @@ struct PeerContext *p2;
71 71
72struct GNUNET_TRANSPORT_TransmitHandle *th; 72struct GNUNET_TRANSPORT_TransmitHandle *th;
73 73
74struct TransportTestingHandle * tth;
75
74char *cfg_file_p1; 76char *cfg_file_p1;
75 77
76char *cfg_file_p2; 78char *cfg_file_p2;
@@ -149,8 +151,10 @@ end ()
149 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 151 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
150 th = NULL; 152 th = NULL;
151 153
152 GNUNET_TRANSPORT_TESTING_stop_peer (p1); 154 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
153 GNUNET_TRANSPORT_TESTING_stop_peer (p2); 155 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
156
157 GNUNET_TRANSPORT_TESTING_done (tth);
154 158
155 ok = 0; 159 ok = 0;
156 if (test_failed == GNUNET_NO) 160 if (test_failed == GNUNET_NO)
@@ -176,9 +180,11 @@ end_badly ()
176 th = NULL; 180 th = NULL;
177 181
178 if (p1 != NULL) 182 if (p1 != NULL)
179 GNUNET_TRANSPORT_TESTING_stop_peer (p1); 183 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
180 if (p2 != NULL) 184 if (p2 != NULL)
181 GNUNET_TRANSPORT_TESTING_stop_peer (p2); 185 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
186
187 GNUNET_TRANSPORT_TESTING_done (tth);
182 188
183 ok = GNUNET_SYSERR; 189 ok = GNUNET_SYSERR;
184} 190}
@@ -361,7 +367,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
361 uint32_t ats_count) 367 uint32_t ats_count)
362{ 368{
363 369
364 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", 370 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (GNUNET_TIME_UNIT_SECONDS%p)!\n",
365 GNUNET_i2s (peer), cls); 371 GNUNET_i2s (peer), cls);
366 372
367 if (cls == p1) 373 if (cls == p1)
@@ -409,8 +415,24 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
409 GNUNET_i2s (&p2->id)); 415 GNUNET_i2s (&p2->id));
410 GNUNET_free (p1_c); 416 GNUNET_free (p1_c);
411 417
412 // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG! 418 GNUNET_SCHEDULER_add_now (&sendtask, NULL);
413 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &sendtask, NULL); 419}
420
421void start_cb (struct PeerContext * p,
422 void *cls)
423{
424 static int started;
425 started++;
426
427 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n",
428 p->no,
429 GNUNET_i2s (&p->id));
430
431 if (started != 2)
432 return;
433
434 GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL);
435
414} 436}
415 437
416static void 438static void
@@ -419,11 +441,15 @@ run (void *cls, char *const *args, const char *cfgfile,
419{ 441{
420 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 442 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
421 443
422 p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, &notify_receive, 444 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
445 &notify_receive,
423 &notify_connect, &notify_disconnect, 446 &notify_connect, &notify_disconnect,
447 &start_cb,
424 NULL); 448 NULL);
425 p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, &notify_receive, 449 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
450 &notify_receive,
426 &notify_connect, &notify_disconnect, 451 &notify_connect, &notify_disconnect,
452 &start_cb,
427 NULL); 453 NULL);
428 454
429 if ((p1 == NULL) || (p2 == NULL)) 455 if ((p1 == NULL) || (p2 == NULL))
@@ -434,8 +460,6 @@ run (void *cls, char *const *args, const char *cfgfile,
434 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); 460 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
435 return; 461 return;
436 } 462 }
437
438 GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL);
439} 463}
440 464
441static int 465static int
@@ -470,6 +494,8 @@ main (int argc, char *argv[])
470 int ret; 494 int ret;
471 int nat_res; 495 int nat_res;
472 496
497 tth = GNUNET_TRANSPORT_TESTING_init ();
498
473 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 499 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
474 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 500 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
475 &test_plugin); 501 &test_plugin);