plugin datastore mysql
[oweals/gnunet.git] / src / psycstore / test_psycstore.c
index 58e6243b70a1c481677c0a8c275696b4d7ae9ce2..1b589f2b1ee8eaa86a01e382e2196c0edcce967b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of GNUnet
- * Copyright (C) 2013 Christian Grothoff (and other contributing authors)
+ * Copyright (C) 2013 GNUnet e.V.
  *
  * GNUnet is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published
@@ -54,7 +54,7 @@ static struct GNUNET_PSYCSTORE_OperationHandle *op;
 /**
  * Handle for task for timeout termination.
  */
-static struct GNUNET_SCHEDULER_Task * end_badly_task;
+static struct GNUNET_SCHEDULER_Task *end_badly_task;
 
 static struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key;
 static struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key;
@@ -77,7 +77,7 @@ struct StateClosure {
   size_t value_size[16];
 } scls;
 
-static struct GNUNET_ENV_Modifier modifiers[16];
+static struct GNUNET_PSYC_Modifier modifiers[16];
 
 /**
  * Clean up all resources used.
@@ -113,10 +113,9 @@ cleanup ()
  * Terminate the testcase (failure).
  *
  * @param cls NULL
- * @param tc scheduler context
  */
 static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+end_badly (void *cls)
 {
   res = 1;
   cleanup ();
@@ -127,10 +126,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * Terminate the testcase (success).
  *
  * @param cls NULL
- * @param tc scheduler context
  */
 static void
-end_normally (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+end_normally (void *cls)
 {
   res = 0;
   cleanup ();
@@ -143,7 +141,7 @@ end_normally (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 static void
 end ()
 {
-  if (end_badly_task != NULL)
+  if (NULL != end_badly_task)
   {
     GNUNET_SCHEDULER_cancel (end_badly_task);
     end_badly_task = NULL;
@@ -153,12 +151,16 @@ end ()
 }
 
 
-void
-state_reset_result (void *cls, int64_t result,
-                    const char *err_msg, uint16_t err_msg_size)
+static void
+state_reset_result (void *cls,
+                    int64_t result,
+                    const char *err_msg,
+                    uint16_t err_msg_size)
 {
   op = NULL;
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "state_reset_result:\t%d\n", result);
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "state_reset_result:\t%d\n",
+              (int) result);
   GNUNET_assert (GNUNET_OK == result);
 
   op = GNUNET_PSYCSTORE_state_reset (h, &channel_pub_key,
@@ -170,7 +172,10 @@ state_reset_result (void *cls, int64_t result,
 
 
 static int
-state_result (void *cls, const char *name, const void *value, uint32_t value_size)
+state_result (void *cls,
+              const char *name,
+              const void *value,
+              uint32_t value_size)
 {
   struct StateClosure *scls = cls;
   const char *nam = scls->name[scls->n];
@@ -181,7 +186,9 @@ state_result (void *cls, const char *name, const void *value, uint32_t value_siz
       && 0 == memcmp (value, val, val_size)
       && 0 == strcmp (name, nam))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "  variable %s matches\n", name);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "  variable %s matches\n",
+                name);
     return GNUNET_YES;
   }
   else
@@ -195,7 +202,7 @@ state_result (void *cls, const char *name, const void *value, uint32_t value_siz
 }
 
 
-void
+static void
 state_get_prefix_result (void *cls, int64_t result,
                          const char *err_msg, uint16_t err_msg_size)
 {
@@ -209,7 +216,7 @@ state_get_prefix_result (void *cls, int64_t result,
 }
 
 
-void
+static void
 state_get_result (void *cls, int64_t result,
                   const char *err_msg, uint16_t err_msg_size)
 {
@@ -233,7 +240,7 @@ state_get_result (void *cls, int64_t result,
 }
 
 
-void
+static void
 counters_result (void *cls, int status, uint64_t max_fragment_id,
                  uint64_t max_message_id, uint64_t max_group_generation,
                  uint64_t max_state_message_id)
@@ -262,7 +269,7 @@ counters_result (void *cls, int status, uint64_t max_fragment_id,
 }
 
 
-void
+static void
 state_modify_result (void *cls, int64_t result,
                      const char *err_msg, uint16_t err_msg_size)
 {
@@ -275,7 +282,7 @@ state_modify_result (void *cls, int64_t result,
 }
 
 
-void
+static void
 state_sync_result (void *cls, int64_t result,
                    const char *err_msg, uint16_t err_msg_size)
 {
@@ -290,7 +297,7 @@ state_sync_result (void *cls, int64_t result,
 }
 
 
-int
+static int
 fragment_result (void *cls,
                  struct GNUNET_MULTICAST_MessageHeader *msg,
                  enum GNUNET_PSYCSTORE_MessageFlags flags)
@@ -319,7 +326,7 @@ fragment_result (void *cls,
 }
 
 
-void
+static void
 message_get_latest_result (void *cls, int64_t result,
                            const char *err_msg, uint16_t err_msg_size)
 {
@@ -328,13 +335,13 @@ message_get_latest_result (void *cls, int64_t result,
   GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "message_get_latest:\t%d\n", result);
   GNUNET_assert (0 < result && fcls->n == fcls->n_expected);
 
-  modifiers[0] = (struct GNUNET_ENV_Modifier) {
+  modifiers[0] = (struct GNUNET_PSYC_Modifier) {
     .oper = '=',
     .name = "_sync_foo",
     .value = "three two one",
     .value_size = sizeof ("three two one") - 1
   };
-  modifiers[1] = (struct GNUNET_ENV_Modifier) {
+  modifiers[1] = (struct GNUNET_PSYC_Modifier) {
     .oper = '=',
     .name = "_sync_bar",
     .value = "ten eleven twelve",
@@ -348,7 +355,7 @@ message_get_latest_result (void *cls, int64_t result,
 }
 
 
-void
+static void
 message_get_result (void *cls, int64_t result,
                     const char *err_msg, uint16_t err_msg_size)
 {
@@ -365,7 +372,7 @@ message_get_result (void *cls, int64_t result,
 }
 
 
-void
+static void
 message_get_fragment_result (void *cls, int64_t result,
                              const char *err_msg, uint16_t err_msg_size)
 {
@@ -378,13 +385,13 @@ message_get_fragment_result (void *cls, int64_t result,
   fcls->n_expected = 3;
   uint64_t message_id = GNUNET_ntohll (fcls->msg[0]->message_id);
   op = GNUNET_PSYCSTORE_message_get (h, &channel_pub_key, &slave_pub_key,
-                                     message_id, message_id, "",
+                                     message_id, message_id, 0, "",
                                      &fragment_result,
                                      &message_get_result, fcls);
 }
 
 
-void
+static void
 fragment_get_latest_result (void *cls, int64_t result,
                             const char *err_msg, uint16_t err_msg_size)
 {
@@ -403,13 +410,15 @@ fragment_get_latest_result (void *cls, int64_t result,
 }
 
 
-void
+static void
 fragment_get_result (void *cls, int64_t result,
                      const char *err_msg, uint16_t err_msg_size)
 {
   struct FragmentClosure *fcls = cls;
   op = NULL;
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "fragment_get:\t%d\n", result);
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "fragment_get:\t%d\n",
+              (int) result);
   GNUNET_assert (0 < result && fcls->n == fcls->n_expected);
 
   fcls->n = 0;
@@ -421,7 +430,7 @@ fragment_get_result (void *cls, int64_t result,
 }
 
 
-void
+static void
 fragment_store_result (void *cls, int64_t result,
                        const char *err_msg, uint16_t err_msg_size)
 {
@@ -442,7 +451,7 @@ fragment_store_result (void *cls, int64_t result,
 }
 
 
-void
+static void
 fragment_store ()
 {
   struct GNUNET_MULTICAST_MessageHeader *msg;
@@ -493,7 +502,7 @@ fragment_store ()
 }
 
 
-void
+static void
 membership_test_result (void *cls, int64_t result,
                         const char *err_msg, uint16_t err_msg_size)
 {
@@ -505,7 +514,7 @@ membership_test_result (void *cls, int64_t result,
 }
 
 
-void
+static void
 membership_store_result (void *cls, int64_t result,
                          const char *err_msg, uint16_t err_msg_size)
 {