- implementation for mantis 0002485
[oweals/gnunet.git] / src / transport / test_transport_testing.c
index 7ba78c04e40ede476b5da512faedcf0e4edd7305..7875f1cfa191709382eb386b6529ba37e63eaa10 100644 (file)
  * C code apparently.
  */
 #include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_hello_lib.h"
-#include "gnunet_getopt_lib.h"
-#include "gnunet_os_lib.h"
-#include "gnunet_program_lib.h"
-#include "gnunet_scheduler_lib.h"
 #include "gnunet_transport_service.h"
-#include "transport.h"
 #include "transport-testing.h"
-
-#define VERBOSE GNUNET_EXTRA_LOGGING
-
-#define VERBOSE_ARM GNUNET_EXTRA_LOGGING
-
-#define START_ARM GNUNET_YES
-
 /**
  * How long until we give up on transmitting the message?
  */
@@ -81,6 +67,12 @@ end_badly ()
   timeout_task = GNUNET_SCHEDULER_NO_TASK;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n");
 
+  if (NULL != cc)
+  {
+    GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+    cc = NULL;
+  }
+
   if (p1 != NULL)
     GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
   if (p2 != NULL)
@@ -94,7 +86,7 @@ end_badly ()
 static void
 testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
 {
-  char *ps = strdup (GNUNET_i2s (&p1->id));
+  char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id));
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Peer %u (`%4s') connected to peer %u (`%s')!\n", p1->no, ps,
@@ -140,7 +132,7 @@ start_cb (struct PeerContext *p, void *cls)
   if (started != 2)
     return;
 
-  char *sender_c = strdup (GNUNET_i2s (&p1->id));
+  char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
@@ -167,15 +159,11 @@ run (void *cls, char *const *args, const char *cfgfile,
                                             1, &notify_receive, &notify_connect,
                                             &notify_disconnect, &start_cb, p1);
 
-  GNUNET_assert (p1->hostkeyfile != NULL);
-
   p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
                                             "test_transport_api_tcp_peer2.conf",
                                             2, &notify_receive, &notify_connect,
                                             &notify_disconnect, &start_cb, p2);
 
-  GNUNET_assert (p2->hostkeyfile != NULL);
-
   if (p1 == NULL)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -198,19 +186,12 @@ int
 main (int argc, char *argv[])
 {
   GNUNET_log_setup ("test_transport_testing",
-#if VERBOSE
-                    "DEBUG",
-#else
                     "WARNING",
-#endif
                     NULL);
 
   char *const argv_1[] = { "test_transport_testing",
     "-c",
     "test_transport_api_data.conf",
-#if VERBOSE
-    "-L", "DEBUG",
-#endif
     NULL
   };