summaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_unreliability_constant.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-10-07 16:20:21 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-10-07 16:20:21 +0000
commit0663a057d7611270d5f41ae8b345125d737387f2 (patch)
tree39793c7c288dbef472c66cb1c8f12af48f6989b9 /src/transport/test_transport_api_unreliability_constant.c
parent013cf64f56c0a529f0c11597e912b39e4a0a896c (diff)
transport-testing is not stateless anymore
-> fixed assertion failure transport_api.c:1348 - connecting peers is now unidirectional - added peer_startup callback
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;
struct GNUNET_TRANSPORT_TransmitHandle *th;
+struct TransportTestingHandle * tth;
+
char *cfg_file_p1;
char *cfg_file_p2;
@@ -149,8 +151,10 @@ end ()
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer (p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+
+ GNUNET_TRANSPORT_TESTING_done (tth);
ok = 0;
if (test_failed == GNUNET_NO)
@@ -176,9 +180,11 @@ end_badly ()
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+
+ GNUNET_TRANSPORT_TESTING_done (tth);
ok = GNUNET_SYSERR;
}
@@ -361,7 +367,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
uint32_t ats_count)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (GNUNET_TIME_UNIT_SECONDS%p)!\n",
GNUNET_i2s (peer), cls);
if (cls == p1)
@@ -409,8 +415,24 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
GNUNET_i2s (&p2->id));
GNUNET_free (p1_c);
- // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG!
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &sendtask, NULL);
+ GNUNET_SCHEDULER_add_now (&sendtask, NULL);
+}
+
+void start_cb (struct PeerContext * p,
+ void *cls)
+{
+ static int started;
+ started++;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n",
+ p->no,
+ GNUNET_i2s (&p->id));
+
+ if (started != 2)
+ return;
+
+ GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL);
+
}
static void
@@ -419,11 +441,15 @@ run (void *cls, char *const *args, const char *cfgfile,
{
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, &notify_receive,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
+ &notify_receive,
&notify_connect, &notify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, &notify_receive,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
+ &notify_receive,
&notify_connect, &notify_disconnect,
+ &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
@@ -434,8 +460,6 @@ run (void *cls, char *const *args, const char *cfgfile,
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
return;
}
-
- GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL);
}
static int
@@ -470,6 +494,8 @@ main (int argc, char *argv[])
int ret;
int nat_res;
+ tth = GNUNET_TRANSPORT_TESTING_init ();
+
GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
&test_plugin);