tracking forwarded operations
[oweals/gnunet.git] / src / testbed / test_testbed_api.c
index 529072cee5c96fd7e776c1511a881d54d8142c2f..694d06274c5b0b464b60ad3cd79f11417053ef26 100644 (file)
@@ -136,7 +136,7 @@ static enum Test sub_test;
  * @param tc the task context
  */
 static void
-do_shutdown (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down...\n");
   if (GNUNET_SCHEDULER_NO_TASK != abort_task)
@@ -159,7 +159,7 @@ do_shutdown (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc)
  * @param tc the task context
  */
 static void
-do_abort (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
   abort_task = GNUNET_SCHEDULER_NO_TASK;
@@ -198,25 +198,29 @@ dht_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 static void
 dht_disconnect_adapter (void *cls, void *op_result)
 {
-  if (NULL != op_result)
-    GNUNET_DHT_disconnect (op_result);
+  GNUNET_assert (NULL != op_result);
+  GNUNET_assert (op_result == dht_handle);
+  GNUNET_DHT_disconnect (dht_handle);
+  dht_handle = NULL;
   GNUNET_assert (PEER_SERVICE_CONNECT == sub_test);
   GNUNET_assert (NULL != operation);
-  operation = GNUNET_TESTBED_peer_stop (peer);
+  operation = GNUNET_TESTBED_peer_stop (peer, NULL, NULL);
   GNUNET_assert (NULL != operation);
 }
 
 
 /**
- * Callback to be called when an operation is completed
+ * Callback to be called when a service connect operation is completed
  *
  * @param cls the callback closure from functions generating an operation
  * @param op the operation that has been finished
+ * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
  * @param emsg error message in case the operation has failed; will be NULL if
  *          operation has executed successfully.
  */
 static void 
-op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
+service_connect_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
+                        void *ca_result, const char *emsg)
 {
   switch (sub_test)
   {
@@ -224,8 +228,9 @@ op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
     GNUNET_assert (operation == op);
     GNUNET_assert (NULL == emsg);
     GNUNET_assert (NULL == cls);
+    GNUNET_assert (ca_result == dht_handle);
     GNUNET_TESTBED_operation_done (operation);        /* This results in call to
-                                                         * disconnect adapter */
+                                                      * disconnect adapter */
     break;
   default:
     GNUNET_assert (0);
@@ -233,6 +238,7 @@ op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
 }
 
 
+
 /**
  * Callback to be called when the requested peer information is available
  *
@@ -307,7 +313,8 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
     GNUNET_assert (OTHER == sub_test);
     GNUNET_TESTBED_operation_done (operation);
     operation =
-        GNUNET_TESTBED_service_connect (NULL, peer, "dht", &op_comp_cb, NULL,
+        GNUNET_TESTBED_service_connect (NULL, peer, "dht", 
+                                       &service_connect_comp_cb, NULL,
                                        &dht_connect_adapter,
                                        &dht_disconnect_adapter, NULL);
     GNUNET_assert (NULL != operation);
@@ -348,7 +355,7 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
   GNUNET_assert (NULL != peer_ptr);
   *peer_ptr = peer;
   GNUNET_TESTBED_operation_done (operation);
-  operation = GNUNET_TESTBED_peer_start (peer);
+  operation = GNUNET_TESTBED_peer_start (NULL, peer, NULL, NULL);
   GNUNET_assert (NULL != operation);
 }
 
@@ -453,3 +460,5 @@ main (int argc, char **argv)
     return 1;
   return 0;
 }
+
+/* end of test_testbed_api.c */