#include "transport.h"
#include "transport-testing.h"
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_EXTRA_LOGGING
-#define VERBOSE_ARM GNUNET_NO
+#define VERBOSE_ARM GNUNET_EXTRA_LOGGING
#define START_ARM GNUNET_YES
struct GNUNET_TRANSPORT_TransmitHandle *th;
+struct GNUNET_TRANSPORT_TESTING_handle * tth;
+
char *cfg_file_p1;
char *cfg_file_p2;
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)
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;
}
{
/* because of starting with 0 */
msg_recv++;
+ fprintf (stderr, "\n");
end ();
}
}
}
else
{
+ fprintf (stderr, "\n");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"All messages scheduled to be sent!!\n");
if (GNUNET_SCHEDULER_NO_TASK != die_task)
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)
{
- char * sec;
- long long unsigned int l_bps;
-
- GNUNET_asprintf(&sec, "transport-%s", test_plugin);
- if (GNUNET_CONFIGURATION_have_value (p1->cfg, sec, "MAX_BPS"))
- {
- GNUNET_CONFIGURATION_get_value_number (p1->cfg, sec, "MAX_BPS",
- &l_bps);
- max_bps_p1 = l_bps;
- }
- else
- max_bps_p1 = 1024 * 1024 * 1024;
- GNUNET_free (sec);
-
+ max_bps_p1 = 1024 * 1024 * 1024;
GNUNET_TRANSPORT_set_quota (p1->th, &p2->id,
GNUNET_BANDWIDTH_value_init (max_bps_p1),
GNUNET_BANDWIDTH_value_init (max_bps_p1));
}
else if (cls == p2)
{
- char * sec;
- long long unsigned int l_bps;
-
- GNUNET_asprintf(&sec, "transport-%s", test_plugin);
- if (GNUNET_CONFIGURATION_have_value (p2->cfg, sec, "MAX_BPS"))
- {
- GNUNET_CONFIGURATION_get_value_number (p2->cfg, sec, "MAX_BPS",
- &l_bps);
- max_bps_p2 = l_bps;
- }
- else
- max_bps_p2 = 1024 * 1024 * 1024;
- GNUNET_free (sec);
-
+ max_bps_p2 = 1024 * 1024 * 1024;
GNUNET_TRANSPORT_set_quota (p2->th, &p1->id,
GNUNET_BANDWIDTH_value_init (max_bps_p2),
GNUNET_BANDWIDTH_value_init (max_bps_p2));
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n",
GNUNET_i2s (peer), cls);
+ if (th != NULL)
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
+ th = NULL;
}
static void
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
{
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, ¬ify_receive,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
+ ¬ify_receive,
¬ify_connect, ¬ify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, ¬ify_receive,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
+ ¬ify_receive,
¬ify_connect, ¬ify_disconnect,
+ &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
return;
}
-
- GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL);
}
static int
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);