- disable try_connect to force topology
[oweals/gnunet.git] / src / mesh / test_mesh2_local.c
index 4c108c3e7dc3f0ee6ebea65ef0ad5608622ba02f..b62cc9ac82a0539a1be5d3239a04af331b20d9bb 100644 (file)
@@ -114,6 +114,7 @@ data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx,
   shutdown_task =
     GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_shutdown,
                                   NULL);
+  GNUNET_MESH_receive_done (tunnel);
   return GNUNET_OK;
 }
 
@@ -138,7 +139,7 @@ inbound_tunnel (void *cls, struct GNUNET_MESH_Tunnel *tunnel,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "test: received incoming tunnel on peer %d, port %u\n",
               id, port);
-  if (id != 1L)
+  if (id != 2L)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "test: wrong peer\n");
@@ -161,13 +162,13 @@ static void
 inbound_end (void *cls, const struct GNUNET_MESH_Tunnel *tunnel,
              void *tunnel_ctx)
 {
-  unsigned int id = *(unsigned int *) cls;
+  long id = (long) cls;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: incoming tunnel closed\n");
-  if (id != 1)
+  if (id != 2)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "test: received closing tunnel on peer 2\n");
+                "test: received closing tunnel on peer != 2\n");
     result = GNUNET_SYSERR;
   }
 }
@@ -185,14 +186,22 @@ static struct GNUNET_MESH_MessageHandler handlers1[] = {
 /**
  * Handler array for traffic received on peer2 (none expected)
  */
-static struct GNUNET_MESH_MessageHandler handlers2[] = { {NULL, 0, 0} };
-
+static struct GNUNET_MESH_MessageHandler handlers2[] = {
+  {&data_callback, 1, 0},
+  {NULL, 0, 0}
+};
 
 static size_t
 do_send (void *cls, size_t size, void *buf)
 {
   struct GNUNET_MessageHeader *m = buf;
 
+  if (NULL == buf)
+  {
+    GNUNET_break (0);
+    result = GNUNET_SYSERR;
+    return 0;
+  }
   m->size = htons (sizeof (struct GNUNET_MessageHeader));
   m->type = htons (1);
   GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));