summaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_limited_sockets.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api_limited_sockets.c')
-rw-r--r--src/transport/test_transport_api_limited_sockets.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/src/transport/test_transport_api_limited_sockets.c b/src/transport/test_transport_api_limited_sockets.c
index 66816671c..7ceed03aa 100644
--- a/src/transport/test_transport_api_limited_sockets.c
+++ b/src/transport/test_transport_api_limited_sockets.c
@@ -77,6 +77,8 @@ static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
struct GNUNET_TRANSPORT_TransmitHandle *th;
+struct TransportTestingHandle * tth;
+
char *cfg_file_p1;
char *cfg_file_p2;
@@ -103,8 +105,8 @@ 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);
}
static void
@@ -118,16 +120,16 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_SCHEDULER_cancel (send_task);
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
if (th != NULL)
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
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);
ok = GNUNET_SYSERR;
}
@@ -228,19 +230,42 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &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;
+
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ NULL);
+
+}
+
static void
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, &notify_receive,
+ tth = GNUNET_TRANSPORT_TESTING_init ();
+
+ 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))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n");
@@ -249,9 +274,6 @@ run (void *cls, char *const *args, const char *cfgfile,
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
return;
}
-
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb,
- NULL);
}