-cleanup, FIXMEs
[oweals/gnunet.git] / src / scalarproduct / test_scalarproduct_api_regression2.c
index 8a0162b40ab8bbf907a7f0d20c6ab6121caee5c7..7fb4e0c01ec4c3bc67378530b40801b3c2624ab3 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 /**
- * @file vectorproduct/test_vectorproduct_api_regression2.c
+ * @file scalarproduct/test_scalarproduct_api_regression2.c
  * @brief Regression test, destroys requester service before receiving response
  *        responder service
  * @author Gaurav Kukreja
 #include "gnunet_util_lib.h"
 #include "gnunet_testbed_service.h"
 #include "gnunet_common.h"
-#include "gnunet_vectorproduct_service.h"
+#include "gnunet_scalarproduct_service.h"
 #include "gnunet_protocols.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "test-vectorproduct-api-regression2",__VA_ARGS__)
+#define LOG(kind,...) GNUNET_log_from (kind, "test-scalarproduct-api-regression2",__VA_ARGS__)
 #define NUM_PEERS 2
 
 /**
@@ -62,7 +62,7 @@ struct PeerData
   /**
    * Pointer to Vector Product Handle
    */
-  struct GNUNET_VECTORPRODUCT_Handle *vh;
+  struct GNUNET_SCALARPRODUCT_Handle *vh;
 };
 
 /**
@@ -83,12 +83,12 @@ enum SetupState
   /**
    * Connect to stream service of peer 1
    */
-  PEER1_VECTORPRODUCT_CONNECT,
+  PEER1_SCALARPRODUCT_CONNECT,
 
   /**
    * Connect to stream service of peer 2
    */
-  PEER2_VECTORPRODUCT_CONNECT
+  PEER2_SCALARPRODUCT_CONNECT
 
 };
 
@@ -241,7 +241,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   struct PeerData* peer = (struct PeerData*) cls;
 
   // peer->op contains handle to the TESTBED_connect_service operation
-  // calling operation done, leads to call to vectorproduct_da
+  // calling operation done, leads to call to scalarproduct_da
   if (peer->op != NULL)
     {
       if (peer == &peer1)
@@ -287,8 +287,8 @@ controller_event_cb (void *cls,
     case GNUNET_TESTBED_ET_OPERATION_FINISHED:
       switch (setup_state)
         {
-        case PEER1_VECTORPRODUCT_CONNECT:
-        case PEER2_VECTORPRODUCT_CONNECT:
+        case PEER1_SCALARPRODUCT_CONNECT:
+        case PEER2_SCALARPRODUCT_CONNECT:
           GNUNET_assert (NULL == event->details.operation_finished.emsg);
           break;
         default:
@@ -304,31 +304,31 @@ controller_event_cb (void *cls,
 static void
 responder_callback (void *cls,
                     const struct GNUNET_HashCode * key,
-                    enum GNUNET_VECTORPRODUCT_ResponseStatus status)
+                    enum GNUNET_SCALARPRODUCT_ResponseStatus status)
 {
-  if (status == GNUNET_VECTORPRODUCT_Status_Failure)
+  if (status == GNUNET_SCALARPRODUCT_Status_Failure)
     {
       LOG (GNUNET_ERROR_TYPE_WARNING, "Responder Client received status failure\n");
       responder_ok = -1;
     }
-  else if (status == GNUNET_VECTORPRODUCT_Status_InvalidResponse)
+  else if (status == GNUNET_SCALARPRODUCT_Status_InvalidResponse)
     {
       LOG (GNUNET_ERROR_TYPE_WARNING, "Responder Client received status invalid response\n");
       responder_ok = -1;
     }
-  else if (GNUNET_VECTORPRODUCT_Status_Timeout == status)
+  else if (GNUNET_SCALARPRODUCT_Status_Timeout == status)
     {
       LOG (GNUNET_ERROR_TYPE_WARNING, "Responder Client received timeout occured\n");
       // In this regression test, requester is supposed to fail due to timeout
       // therefore responder_ok is set to 1, to make regression test pass
       responder_ok = 1;
     }
-  else if (GNUNET_VECTORPRODUCT_Status_ServiceDisconnected == status)
+  else if (GNUNET_SCALARPRODUCT_Status_ServiceDisconnected == status)
     {
       LOG (GNUNET_ERROR_TYPE_WARNING, "Responder Client received service disconnected!!\n");
       responder_ok = -1;
     }
-  else if (GNUNET_VECTORPRODUCT_Status_Success == status)
+  else if (GNUNET_SCALARPRODUCT_Status_Success == status)
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG, "Responder Client expected response received!\n");
       responder_ok = 1;
@@ -349,40 +349,40 @@ static void
 requester_callback (void *cls,
                     const struct GNUNET_HashCode * key,
                     const struct GNUNET_PeerIdentity * peer,
-                    enum GNUNET_VECTORPRODUCT_ResponseStatus status,
-                    uint16_t size, struct GNUNET_VECTORPRODUCT_client_response *msg,
+                    enum GNUNET_SCALARPRODUCT_ResponseStatus status,
+                    uint16_t size, struct GNUNET_SCALARPRODUCT_client_response *msg,
                     uint16_t type)
 {
   uint32_t product_len;
 
-  if (status == GNUNET_VECTORPRODUCT_Status_Failure)
+  if (status == GNUNET_SCALARPRODUCT_Status_Failure)
     {
       LOG (GNUNET_ERROR_TYPE_WARNING, "Requester Client received status failure\n");
       // In this regression test, requester is supposed to receive status failure
       // therefore requester_ok is set to 1, to make regression test pass
       requester_ok = 1;
     }
-  else if (status == GNUNET_VECTORPRODUCT_Status_InvalidResponse)
+  else if (status == GNUNET_SCALARPRODUCT_Status_InvalidResponse)
     {
       LOG (GNUNET_ERROR_TYPE_WARNING, "Requester Client received status invalid response\n");
       requester_ok = -1;
     }
-  else if (GNUNET_VECTORPRODUCT_Status_Timeout == status)
+  else if (GNUNET_SCALARPRODUCT_Status_Timeout == status)
     {
       LOG (GNUNET_ERROR_TYPE_WARNING, "Requester Client timeout occured\n");
       requester_ok = -1;
     }
-  else if (GNUNET_VECTORPRODUCT_Status_ServiceDisconnected == status)
+  else if (GNUNET_SCALARPRODUCT_Status_ServiceDisconnected == status)
     {
       LOG (GNUNET_ERROR_TYPE_WARNING, "Requester Client service disconnected!!\n");
       requester_ok = -1;
     }
-  else if (GNUNET_VECTORPRODUCT_Status_Success != status)
+  else if (GNUNET_SCALARPRODUCT_Status_Success != status)
     {
       LOG (GNUNET_ERROR_TYPE_WARNING, "Requester Client Status = %d\n", (int) status);
       requester_ok = -1;
     }
-  else if (GNUNET_VECTORPRODUCT_Status_Success == status)
+  else if (GNUNET_SCALARPRODUCT_Status_Success == status)
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG, "Requester Client expected response received!\n");
 
@@ -475,7 +475,7 @@ requester_callback (void *cls,
 }
 
 
-static struct GNUNET_VECTORPRODUCT_QueueEntry *
+static struct GNUNET_SCALARPRODUCT_QueueEntry *
 requester_request ()
 {
   GNUNET_assert (peer2.vh != NULL);
@@ -487,7 +487,7 @@ requester_request ()
   char * end;
   int32_t element;
 
-  struct GNUNET_VECTORPRODUCT_QueueEntry *qe;
+  struct GNUNET_SCALARPRODUCT_QueueEntry *qe;
 
   struct GNUNET_HashCode key;
   GNUNET_CRYPTO_hash (input_key, strlen (input_key), &key);
@@ -573,7 +573,7 @@ requester_request ()
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Responder peer key %s\n", &peer1.our_id);
 
   // TODO : Create the mask array
-  qe = GNUNET_VECTORPRODUCT_request (peer2.vh,
+  qe = GNUNET_SCALARPRODUCT_request (peer2.vh,
                                      &key,
                                      &peer1.our_id,
                                      element_count_peer2,
@@ -585,7 +585,7 @@ requester_request ()
 
   if (qe == NULL)
     {
-      FPRINTF (stderr, "%s", _ ("Could not send request to vectorproduct service! Exitting!"));
+      FPRINTF (stderr, "%s", _ ("Could not send request to scalarproduct service! Exitting!"));
       ok = -1;
       return NULL;
     }
@@ -595,10 +595,10 @@ requester_request ()
 
 
 /**
- * Function prepares the message to be sent by peer1 to its vectorproduct service
+ * Function prepares the message to be sent by peer1 to its scalarproduct service
  * to prepare response, and wait for a request session to be initiated by peer1
  */
-static struct GNUNET_VECTORPRODUCT_QueueEntry *
+static struct GNUNET_SCALARPRODUCT_QueueEntry *
 responder_prepare_response ()
 {
   GNUNET_assert (peer1.vh != NULL);
@@ -609,7 +609,7 @@ responder_prepare_response ()
   char * end;
   int32_t element;
 
-  struct GNUNET_VECTORPRODUCT_QueueEntry *qe;
+  struct GNUNET_SCALARPRODUCT_QueueEntry *qe;
 
   struct GNUNET_HashCode key;
   GNUNET_CRYPTO_hash (input_key, strlen (input_key), &key);
@@ -648,7 +648,7 @@ responder_prepare_response ()
   GNUNET_assert (elements_peer1 != NULL);
   GNUNET_assert (element_count_peer1 >= 1);
 
-  qe = GNUNET_VECTORPRODUCT_prepare_response (peer1.vh,
+  qe = GNUNET_SCALARPRODUCT_prepare_response (peer1.vh,
                                               &key,
                                               element_count_peer1,
                                               elements_peer1,
@@ -658,7 +658,7 @@ responder_prepare_response ()
 
   if (qe == NULL)
     {
-      FPRINTF (stderr, "%s", _ ("Could not send request to vectorproduct service! Exitting!"));
+      FPRINTF (stderr, "%s", _ ("Could not send request to scalarproduct service! Exitting!"));
       ok = -1;
       return NULL;
     }
@@ -737,11 +737,11 @@ destroy_server (void *cls,
  * @param op_result service handle returned from the connect adapter
  */
 static void
-vectorproduct_da (void *cls, void *op_result)
+scalarproduct_da (void *cls, void *op_result)
 {
   struct PeerData* peer = (struct PeerData*) cls;
 
-  GNUNET_VECTORPRODUCT_disconnect (peer->vh);
+  GNUNET_SCALARPRODUCT_disconnect (peer->vh);
   return;
 }
 
@@ -757,7 +757,7 @@ vectorproduct_da (void *cls, void *op_result)
  * @return service handle to return in 'op_result', NULL on error
  */
 static void *
-vectorproduct_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
+scalarproduct_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct PeerData *p = cls;
 
@@ -766,23 +766,23 @@ vectorproduct_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
   switch (setup_state)
     {
-    case PEER1_VECTORPRODUCT_CONNECT:
-      /* Connect peer 2 to vectorproduct service */
-      /* The connect adapter vectorproduct_ca will be called to perform the actual connection */
+    case PEER1_SCALARPRODUCT_CONNECT:
+      /* Connect peer 2 to scalarproduct service */
+      /* The connect adapter scalarproduct_ca will be called to perform the actual connection */
       {
-        peer2.op = GNUNET_TESTBED_service_connect (&peer2, peer2.peer, "vectorproduct",
-                                                   NULL, NULL, vectorproduct_ca,
-                                                   vectorproduct_da, &peer2);
-        setup_state = PEER2_VECTORPRODUCT_CONNECT;
+        peer2.op = GNUNET_TESTBED_service_connect (&peer2, peer2.peer, "scalarproduct",
+                                                   NULL, NULL, scalarproduct_ca,
+                                                   scalarproduct_da, &peer2);
+        setup_state = PEER2_SCALARPRODUCT_CONNECT;
       }
 
-      /* Actually connect peer 1 to vectorproduct service */
-      peer1.vh = GNUNET_VECTORPRODUCT_connect (cfg);
+      /* Actually connect peer 1 to scalarproduct service */
+      peer1.vh = GNUNET_SCALARPRODUCT_connect (cfg);
       return peer1.vh;
 
-    case PEER2_VECTORPRODUCT_CONNECT:
-      /* Actually connect peer 2 to vectorproduct service */
-      peer2.vh = GNUNET_VECTORPRODUCT_connect (cfg);
+    case PEER2_SCALARPRODUCT_CONNECT:
+      /* Actually connect peer 2 to scalarproduct service */
+      peer2.vh = GNUNET_SCALARPRODUCT_connect (cfg);
 
 
       if (peer1.vh != NULL && peer2.vh != NULL)
@@ -848,12 +848,12 @@ peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op_,
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 2 id: %s\n", GNUNET_i2s_full
                     (&peer2.our_id));
 
-        /* Connect peer 1 to vectorproduct service */
-        /* The connect adapter vectorproduct_ca will be called to perform the actual connection */
-        peer1.op = GNUNET_TESTBED_service_connect (&peer1, peer1.peer, "vectorproduct",
-                                                   NULL, NULL, vectorproduct_ca,
-                                                   vectorproduct_da, &peer1);
-        setup_state = PEER1_VECTORPRODUCT_CONNECT;
+        /* Connect peer 1 to scalarproduct service */
+        /* The connect adapter scalarproduct_ca will be called to perform the actual connection */
+        peer1.op = GNUNET_TESTBED_service_connect (&peer1, peer1.peer, "scalarproduct",
+                                                   NULL, NULL, scalarproduct_ca,
+                                                   scalarproduct_da, &peer1);
+        setup_state = PEER1_SCALARPRODUCT_CONNECT;
       }
       break;
     default:
@@ -904,8 +904,8 @@ main (int argc, char **argv)
   max_mids = (GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_MessageHeader))
           / sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1;
 
-  (void) GNUNET_TESTBED_test_run ("test_vectorproduct_api_regression2",
-                                  "test_vectorproduct_api_data.conf",
+  (void) GNUNET_TESTBED_test_run ("test_scalarproduct_api_regression2",
+                                  "test_scalarproduct_api_data.conf",
                                   NUM_PEERS, event_mask, &controller_event_cb,
                                   NULL,
                                   &test_master, NULL);