gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r38074 - in gnunet/src: my psycstore


From: gnunet
Subject: [GNUnet-SVN] r38074 - in gnunet/src: my psycstore
Date: Thu, 6 Oct 2016 18:01:51 +0200

Author: tg
Date: 2016-10-06 18:01:51 +0200 (Thu, 06 Oct 2016)
New Revision: 38074

Modified:
   gnunet/src/my/my.c
   gnunet/src/psycstore/plugin_psycstore_mysql.c
   gnunet/src/psycstore/test_plugin_psycstore.c
Log:
psycstore: mysql stmt fix, logging for tests

Modified: gnunet/src/my/my.c
===================================================================
--- gnunet/src/my/my.c  2016-10-06 16:01:48 UTC (rev 38073)
+++ gnunet/src/my/my.c  2016-10-06 16:01:51 UTC (rev 38074)
@@ -104,7 +104,7 @@
 
 /**
  * Free all memory that was allocated in @a qp during
- * #GNUNET_MY_exect_prepared().
+ * #GNUNET_MY_exec_prepared().
  *
  * @param qp query specification to clean up
  * @param qbind array of parameter to clean up

Modified: gnunet/src/psycstore/plugin_psycstore_mysql.c
===================================================================
--- gnunet/src/psycstore/plugin_psycstore_mysql.c       2016-10-06 16:01:48 UTC 
(rev 38073)
+++ gnunet/src/psycstore/plugin_psycstore_mysql.c       2016-10-06 16:01:51 UTC 
(rev 38074)
@@ -423,7 +423,7 @@
                 "       multicast_flags, psycstore_flags, data\n"
                 "FROM messages\n"
                 "WHERE channel_id = (SELECT id FROM channels WHERE pub_key = 
?)\n"
-                "      AND ? <= message_id AND message_id <= ?"
+                "      AND ? <= message_id AND message_id <= ?\n"
                 "LIMIT ?;",
                 &plugin->select_messages);
 
@@ -1101,21 +1101,16 @@
 
 
 static int
-fragment_select (struct Plugin *plugin, struct GNUNET_MYSQL_StatementHandle 
*stmt,
+fragment_select (struct Plugin *plugin,
+                 struct GNUNET_MYSQL_StatementHandle *stmt,
                  struct GNUNET_MY_QueryParam *params,
                  uint64_t *returned_fragments,
-                 GNUNET_PSYCSTORE_FragmentCallback cb, void *cb_cls)
+                 GNUNET_PSYCSTORE_FragmentCallback cb,
+                 void *cb_cls)
 {
   int ret = GNUNET_SYSERR;
   int sql_ret;
 
-  // FIXME
-  if (NULL == plugin->mc || NULL == stmt || NULL == params)
-  {
-    fprintf(stderr, "%p %p %p\n", plugin->mc, stmt, params);
-    return GNUNET_SYSERR;
-  }
-
   sql_ret = GNUNET_MY_exec_prepared (plugin->mc, stmt, params);
   switch (sql_ret)
   {

Modified: gnunet/src/psycstore/test_plugin_psycstore.c
===================================================================
--- gnunet/src/psycstore/test_plugin_psycstore.c        2016-10-06 16:01:48 UTC 
(rev 38073)
+++ gnunet/src/psycstore/test_plugin_psycstore.c        2016-10-06 16:01:51 UTC 
(rev 38074)
@@ -25,6 +25,9 @@
  * @file
  * Test for the PSYCstore plugins.
  */
+
+#include <inttypes.h>
+
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_testing_lib.h"
@@ -175,6 +178,8 @@
 
   /* Store & test membership */
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "MEMBERSHIP\n");
+
   channel_key = GNUNET_CRYPTO_eddsa_key_create ();
   slave_key = GNUNET_CRYPTO_ecdsa_key_create ();
 
@@ -182,10 +187,14 @@
                                                   &channel_pub_key);
   GNUNET_CRYPTO_ecdsa_key_get_public (slave_key, &slave_pub_key);
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "membership_store()\n");
+
   GNUNET_assert (GNUNET_OK == db->membership_store (db->cls, &channel_pub_key,
                                                     &slave_pub_key, GNUNET_YES,
                                                     4, 2, 1));
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "membership_test()\n");
+
   GNUNET_assert (GNUNET_YES == db->membership_test (db->cls, &channel_pub_key,
                                                     &slave_pub_key, 4));
 
@@ -195,9 +204,10 @@
   GNUNET_assert (GNUNET_NO == db->membership_test (db->cls, &channel_pub_key,
                                                    &slave_pub_key, 1));
 
-
   /* Store & get messages */
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "MESSAGES\n");
+
   struct GNUNET_MULTICAST_MessageHeader *msg
     = GNUNET_malloc (sizeof (*msg) + sizeof (channel_pub_key));
   GNUNET_assert (msg != NULL);
@@ -228,6 +238,8 @@
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CRYPTO_eddsa_sign (channel_key, &msg->purpose, 
&msg->signature));
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "fragment_store()\n");
+
   struct FragmentClosure fcls = { 0 };
   fcls.n = 0;
   fcls.msg[0] = msg;
@@ -237,6 +249,8 @@
     GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key, msg,
                                      fcls.flags[0]));
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "fragment_get(%" PRIu64 ")\n", fragment_id);
+
   uint64_t ret_frags = 0;
   GNUNET_assert (
     GNUNET_OK == db->fragment_get (db->cls, &channel_pub_key,
@@ -244,8 +258,19 @@
                                    &ret_frags, fragment_cb, &fcls));
   GNUNET_assert (fcls.n == 1);
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "fragment_get(%" PRIu64 ")\n", fragment_id+1);
+
+  ret_frags = 0;
+  GNUNET_assert (
+    GNUNET_OK == db->fragment_get (db->cls, &channel_pub_key,
+                                   fragment_id+1, fragment_id+1,
+                                   &ret_frags, fragment_cb, &fcls));
+  GNUNET_assert (fcls.n == 1);
+
   // FIXME: test fragment_get_latest and message_get_latest
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "message_get_fragment()\n");
+
   fcls.n = 0;
 
   GNUNET_assert (
@@ -255,11 +280,15 @@
                                            fragment_cb, &fcls));
   GNUNET_assert (fcls.n == 1);
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "message_add_flags()\n");
+
   GNUNET_assert (
     GNUNET_OK == db->message_add_flags (db->cls, &channel_pub_key,
                                         GNUNET_ntohll (msg->message_id),
                                         
GNUNET_PSYCSTORE_MESSAGE_STATE_APPLIED));
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "fragment_get(%" PRIu64 ")\n", fragment_id);
+
   fcls.n = 0;
   fcls.flags[0] |= GNUNET_PSYCSTORE_MESSAGE_STATE_APPLIED;
 
@@ -270,6 +299,8 @@
 
   GNUNET_assert (fcls.n == 1);
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "fragment_store()\n");
+
   struct GNUNET_MULTICAST_MessageHeader *msg1
     = GNUNET_malloc (sizeof (*msg1) + sizeof (channel_pub_key));
 
@@ -285,6 +316,8 @@
   GNUNET_assert (GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key, 
msg1,
                                                   fcls.flags[1]));
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "message_get()\n");
+
   GNUNET_assert (
     GNUNET_OK == db->message_get (db->cls, &channel_pub_key,
                                   message_id, message_id, 0,
@@ -293,6 +326,8 @@
 
   /* Message counters */
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "counters_message_get()\n");
+
   fragment_id = 0;
   message_id = 0;
   group_generation = 0;
@@ -306,6 +341,10 @@
 
   /* Modify state */
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "STATE\n");
+
+  LOG (GNUNET_ERROR_TYPE_INFO, "state_modify_*()\n");
+
   message_id = GNUNET_ntohll (fcls.msg[0]->message_id) + 1;
   GNUNET_assert (GNUNET_OK == db->state_modify_begin (db->cls, 
&channel_pub_key,
                                                       message_id, 0));
@@ -323,6 +362,8 @@
   GNUNET_assert (GNUNET_OK == db->state_modify_end (db->cls, &channel_pub_key,
                                                     message_id));
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "state_get()\n");
+
   struct StateClosure scls = { 0 };
   scls.n = 0;
   scls.value[0] = "one two three";
@@ -332,6 +373,8 @@
                                              state_cb, &scls));
   GNUNET_assert (scls.n == 1);
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "state_get_prefix()\n");
+
   scls.n = 0;
   scls.value[1] = slave_key;
   scls.value_size[1] = sizeof (*slave_key);
@@ -340,14 +383,20 @@
                                                     "_foo", state_cb, &scls));
   GNUNET_assert (scls.n == 2);
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "state_get_signed()\n");
+
   scls.n = 0;
   GNUNET_assert (GNUNET_NO == db->state_get_signed (db->cls, &channel_pub_key,
                                                     state_cb, &scls));
   GNUNET_assert (scls.n == 0);
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "state_update_signed()\n");
+
   GNUNET_assert (GNUNET_OK == db->state_update_signed (db->cls,
                                                        &channel_pub_key));
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "state_get_signed()\n");
+
   scls.n = 0;
   GNUNET_assert (GNUNET_YES == db->state_get_signed (db->cls, &channel_pub_key,
                                                      state_cb, &scls));
@@ -355,6 +404,8 @@
 
   /* State counters */
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "counters_state_get()\n");
+
   uint64_t max_state_msg_id = 0;
   GNUNET_assert (GNUNET_OK == db->counters_state_get (db->cls, 
&channel_pub_key,
                                                       &max_state_msg_id)
@@ -362,6 +413,8 @@
 
   /* State sync */
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "state_sync_*()\n");
+
   scls.n = 0;
   scls.value[0] = channel_key;
   scls.value_size[0] = sizeof (*channel_key);
@@ -397,6 +450,8 @@
 
   /* Modify state after sync */
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "state_modify_*()\n");
+
   message_id = GNUNET_ntohll (fcls.msg[0]->message_id) + 6;
   GNUNET_assert (GNUNET_OK == db->state_modify_begin (db->cls, 
&channel_pub_key,
                                                       message_id,
@@ -412,6 +467,8 @@
 
   /* Reset state */
 
+  LOG (GNUNET_ERROR_TYPE_INFO, "state_reset()\n");
+
   scls.n = 0;
   GNUNET_assert (GNUNET_OK == db->state_reset (db->cls, &channel_pub_key));
   GNUNET_assert (scls.n == 0);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]