- allow slow botnets enough time
[oweals/gnunet.git] / src / mesh / test_mesh_regex.c
index a58828deebbbe623d0eb40cd83b983dbd0b3e094..878ca2f6847438c2834e0c12688ec8ffbf7cd3d8 100644 (file)
 
 #define VERBOSE GNUNET_YES
 #define REMOVE_DIR GNUNET_YES
-#define MESH_REGEX_PEERS 1
+#define MESH_REGEX_PEERS 3
 
 /**
  * How long until we give up on connecting the peers?
  */
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
 
 /**
  * Time to wait for stuff that should be rather fast
  */
 #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
 
+/**
+ * Initial regex padding.
+ */
+#define REGEX_INITIAL_PADDING "PADPADPADPADPADP"
 
 /**
  * Which strings have been found & connected.
@@ -50,7 +54,7 @@ static int ok[MESH_REGEX_PEERS];
 /**
  * How many connects have happened.
  */
-static int connected_peers;
+static int regex_peers;
 
 /**
  * Be verbose
@@ -120,11 +124,11 @@ static struct GNUNET_MESH_Tunnel *incoming_t[MESH_REGEX_PEERS];
 /**
  * Regular expressions for the announces.
  */
-static char *regexes[MESH_REGEX_PEERS] = {/*"(0|1)"
+static char *regexes[MESH_REGEX_PEERS] = {"(0|1)"
                                           "(0|1)"
                                           "23456789ABC",
 
-                                          "0123456789A*BC",*/
+                                          "0123456789A*BC",
 
                                           "0*123456789ABC*"};
 
@@ -132,9 +136,9 @@ static char *regexes[MESH_REGEX_PEERS] = {/*"(0|1)"
 /**
  * Service strings to look for.
  */
-static char *strings[MESH_REGEX_PEERS] = {/*"1123456789ABC",
+static char *strings[MESH_REGEX_PEERS] = {"1123456789ABC",
 
-                                          "0123456789AABC",*/
+                                          "0123456789AABC",
 
                                           "00123456789ABCCCC"};
 
@@ -188,7 +192,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 /**
  * Ends test: Disconnects peers and calls shutdown.
  * @param cls Closure (not used).
- * @param tc TaskContext. 
+ * @param tc TaskContext.
  */
 static void
 disconnect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -225,7 +229,7 @@ tunnel_cleaner (void *cls, const struct GNUNET_MESH_Tunnel *tunnel,
 {
   long i = (long) cls;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Incoming tunnel disconnected at peer %d\n",
               i);
   return;
@@ -286,9 +290,9 @@ ch (void *cls, const struct GNUNET_PeerIdentity *peer,
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Peer connected: %s\n",
               GNUNET_i2s (peer));
-  connected_peers++;
-  GNUNET_MESH_notify_transmit_ready(t[i], 0, 0,
+  regex_peers++;
+
+  GNUNET_MESH_notify_transmit_ready(t[i], GNUNET_NO,
                                     GNUNET_TIME_UNIT_FOREVER_REL,
                                     peer,
                                     sizeof(struct GNUNET_MessageHeader),
@@ -370,7 +374,7 @@ data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx,
     GNUNET_SCHEDULER_cancel (disconnect_task);
     disconnect_task =
         GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
-  } 
+  }
   return GNUNET_OK;
 }
 
@@ -427,17 +431,17 @@ peergroup_ready (void *cls, const char *emsg)
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Connect to mesh\n");
-  h1 = GNUNET_MESH_connect (d->cfg, 5, (void *) 1L,
+  h1 = GNUNET_MESH_connect (d->cfg, (void *) 1L,
                             NULL,
                             NULL,
                             handlers,
                             &app);
-  connected_peers = 0;
+  regex_peers = 0;
   for (i = 0; i < MESH_REGEX_PEERS; i++)
   {
     ok[i] = GNUNET_NO;
     d = GNUNET_TESTING_daemon_get (pg, 10 + i);
-    h2[i] = GNUNET_MESH_connect (d->cfg, 5, (void *) (long) (i + 2),
+    h2[i] = GNUNET_MESH_connect (d->cfg, (void *) (long) (i + 2),
                                  &incoming_tunnel,
                                  &tunnel_cleaner,
                                  handlers,
@@ -449,7 +453,7 @@ peergroup_ready (void *cls, const char *emsg)
 
   for (i = 0; i < MESH_REGEX_PEERS; i++)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Create tunnel\n");
     t[i] = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, (void *) (long) i);
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -457,7 +461,7 @@ peergroup_ready (void *cls, const char *emsg)
     GNUNET_MESH_peer_request_connect_by_string (t[i], strings[i]);
   }
   /* connect handler = success, timeout = error */
-  
+
 }
 
 
@@ -601,14 +605,14 @@ main (int argc, char *argv[])
                   i, strings[i]);
     }
   }
-  if (GNUNET_OK != result || connected_peers != MESH_REGEX_PEERS)
+  if (GNUNET_OK != result || regex_peers != MESH_REGEX_PEERS)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "test: FAILED! %u connected peers\n",
-                connected_peers);
+                regex_peers);
     return 1;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: success\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "test: success\n");
   return 0;
 }