gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r28126 - gnunet/src/identity


From: gnunet
Subject: [GNUnet-SVN] r28126 - gnunet/src/identity
Date: Wed, 17 Jul 2013 22:26:03 +0200

Author: grothoff
Date: 2013-07-17 22:26:02 +0200 (Wed, 17 Jul 2013)
New Revision: 28126

Modified:
   gnunet/src/identity/Makefile.am
   gnunet/src/identity/gnunet-service-identity.c
   gnunet/src/identity/identity_api.c
   gnunet/src/identity/test_identity.c
   gnunet/src/identity/test_identity.conf
   gnunet/src/identity/test_identity_defaults.c
Log:
-misc bugfixes and test-fixes

Modified: gnunet/src/identity/Makefile.am
===================================================================
--- gnunet/src/identity/Makefile.am     2013-07-17 19:33:34 UTC (rev 28125)
+++ gnunet/src/identity/Makefile.am     2013-07-17 20:26:02 UTC (rev 28126)
@@ -56,7 +56,8 @@
 
 if HAVE_TESTING
 check_PROGRAMS = \
- test_identity
+ test_identity \
+ test_identity_defaults 
 endif
 
 if ENABLE_TEST_RUN
@@ -70,7 +71,14 @@
   $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 
+test_identity_defaults_SOURCES = \
+ test_identity_defaults.c
+test_identity_defaults_LDADD = \
+  $(top_builddir)/src/identity/libgnunetidentity.la \
+  $(top_builddir)/src/testing/libgnunettesting.la \
+  $(top_builddir)/src/util/libgnunetutil.la 
 
+
 EXTRA_DIST = \
   test_identity.conf 
 

Modified: gnunet/src/identity/gnunet-service-identity.c
===================================================================
--- gnunet/src/identity/gnunet-service-identity.c       2013-07-17 19:33:34 UTC 
(rev 28125)
+++ gnunet/src/identity/gnunet-service-identity.c       2013-07-17 20:26:02 UTC 
(rev 28126)
@@ -27,7 +27,6 @@
  * represent the various egos/pseudonyms/identities of a GNUnet user.
  *
  * Todo:
- * - testcases
  * - auto-initialze default egos; maybe trigger default
  *   initializations (such as gnunet-gns-import.sh?)
  */
@@ -320,8 +319,6 @@
   const char *name;
   char *identifier;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
-             "Received GET_DEFAULT message from client\n");
   size = ntohs (message->size);
   if (size <= sizeof (struct GNUNET_IDENTITY_GetDefaultMessage))
   {
@@ -340,6 +337,9 @@
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+             "Received GET_DEFAULT for service `%s' from client\n",
+             name);
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
                                             name,
@@ -363,6 +363,9 @@
       return;
     }
   }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Failed to find ego `%s'\n",
+             name);
   send_result_code (client, 1, 
                    gettext_noop ("default configured, but ego unknown 
(internal error)"));
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -409,8 +412,6 @@
   const char *str;
   struct GNUNET_CRYPTO_EccPrivateKey *pk;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
-             "Received SET_DEFAULT message from client\n");
   size = ntohs (message->size);
   if (size <= sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
   {
@@ -436,6 +437,9 @@
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+             "Received SET_DEFAULT for service `%s' from client\n",
+             str);
   for (ego = ego_head; NULL != ego; ego = ego->next)
   {
     if (0 == key_cmp (ego->pk,
@@ -848,8 +852,10 @@
                  filename);
       return GNUNET_OK;
     }
-  
-  ego->identifier = GNUNET_strdup (fn);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Loaded ego `%s'\n",
+             fn + 1);  
+  ego->identifier = GNUNET_strdup (fn + 1);
   GNUNET_CONTAINER_DLL_insert (ego_head,
                               ego_tail,
                               ego);
@@ -904,6 +910,9 @@
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Loading subsystem configuration `%s'\n",
+             subsystem_cfg_file);
   subsystem_cfg = GNUNET_CONFIGURATION_create ();
   if ( (GNUNET_YES ==
        GNUNET_DISK_file_test (subsystem_cfg_file)) &&

Modified: gnunet/src/identity/identity_api.c
===================================================================
--- gnunet/src/identity/identity_api.c  2013-07-17 19:33:34 UTC (rev 28125)
+++ gnunet/src/identity/identity_api.c  2013-07-17 20:26:02 UTC (rev 28126)
@@ -707,15 +707,15 @@
  *
  * @param id identity service to use
  * @param identifier desired identifier
- * @param cb function to call with the result (will only be called once)
- * @param cb_cls closure for cb
+ * @param cont function to call with the result (will only be called once)
+ * @param cont_cls closure for cont
  * @return handle to abort the operation
  */
 struct GNUNET_IDENTITY_Operation *
 GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
                        const char *identifier,
-                       GNUNET_IDENTITY_Callback cb,
-                       void *cb_cls)
+                       GNUNET_IDENTITY_Continuation cont,
+                       void *cont_cls)
 {
   struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *enc;
   struct GNUNET_IDENTITY_Operation *op;
@@ -741,8 +741,8 @@
                      sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
                      enc_len + slen);  
   op->h = id;
-  op->cb = cb;
-  op->cls = cb_cls;
+  op->cont = cont;
+  op->cls = cont_cls;
   crm = (struct GNUNET_IDENTITY_CreateRequestMessage *) &op[1];
   crm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_CREATE);
   crm->header.size = htons (sizeof (struct 
GNUNET_IDENTITY_CreateRequestMessage) +

Modified: gnunet/src/identity/test_identity.c
===================================================================
--- gnunet/src/identity/test_identity.c 2013-07-17 19:33:34 UTC (rev 28125)
+++ gnunet/src/identity/test_identity.c 2013-07-17 20:26:02 UTC (rev 28126)
@@ -226,19 +226,13 @@
  * Called with events about created ego.
  *
  * @param cls NULL
- * @param ego ego handle
- * @param ego_ctx context for application to store data for this ego
- *                 (during the lifetime of this process, initially NULL)
- * @param identifier identifier assigned by the user for this ego,
- *                   NULL if the user just deleted the ego and it
- *                   must thus no longer be used
+ * @param emsg error message
  */
 static void
 create_cb (void *cls,
-          struct GNUNET_IDENTITY_Ego *ego,
-          void **ctx,
-          const char *identifier)
+          const char *emsg)
 {  
+  GNUNET_assert (NULL == emsg);
   op = GNUNET_IDENTITY_rename (h, 
                               "test-id",
                               "test",
@@ -274,6 +268,7 @@
 int
 main (int argc, char *argv[])
 {
+  GNUNET_DISK_directory_remove ("/tmp/test-identity-service");
   res = 1;
   if (0 != 
       GNUNET_TESTING_service_run ("test-identity",

Modified: gnunet/src/identity/test_identity.conf
===================================================================
--- gnunet/src/identity/test_identity.conf      2013-07-17 19:33:34 UTC (rev 
28125)
+++ gnunet/src/identity/test_identity.conf      2013-07-17 20:26:02 UTC (rev 
28126)
@@ -3,3 +3,7 @@
 DEFAULTSERVICES = identity
 UNIXPATH = /tmp/gnunet-p1-service-arm.sock
 
+[identity]
+# need to overwrite paths to ensure they stay the same between runs...
+EGODIR = /tmp/test-identity-service/egos/
+SUBSYSTEM_CFG = /tmp/test-identity-service/s.conf

Modified: gnunet/src/identity/test_identity_defaults.c
===================================================================
--- gnunet/src/identity/test_identity_defaults.c        2013-07-17 19:33:34 UTC 
(rev 28125)
+++ gnunet/src/identity/test_identity_defaults.c        2013-07-17 20:26:02 UTC 
(rev 28126)
@@ -119,58 +119,6 @@
 
 
 /**
- * Called with events about egos.
- *
- * @param cls NULL
- * @param ego ego handle
- * @param ego_ctx context for application to store data for this ego
- *                 (during the lifetime of this process, initially NULL)
- * @param identifier identifier assigned by the user for this ego,
- *                   NULL if the user just deleted the ego and it
- *                   must thus no longer be used
- */
-static void
-notification_cb (void *cls,
-                struct GNUNET_IDENTITY_Ego *ego,
-                void **ctx,
-                const char *identifier)
-{
-#if 0
-  static struct GNUNET_IDENTITY_Ego *my_ego;
-  static int round;
-
-  switch (round)
-  {
-  case 0: /* end of initial iteration */
-    GNUNET_assert (NULL == ego);
-    GNUNET_assert (NULL == identifier);
-    break;
-  case 1: /* create */
-    GNUNET_assert (NULL != ego);
-    GNUNET_assert (0 == strcmp (identifier, "test-id"));
-    my_ego = ego;
-    *ctx = &round;
-    break;
-  case 2: /* rename */
-    GNUNET_assert (my_ego == ego);
-    GNUNET_assert (0 == strcmp (identifier, "test"));
-    GNUNET_assert (*ctx == &round);
-    break;
-  case 3: /* delete */
-    GNUNET_assert (my_ego == ego);
-    GNUNET_assert (NULL == identifier);
-    GNUNET_assert (*ctx == &round);
-    *ctx = NULL;
-    break;
-  default:
-    GNUNET_break (0);
-  }
-  round++;
-#endif
-}
-
-
-/**
  * Continuation called from successful delete operation.
  *
  * @param cls NULL
@@ -198,8 +146,8 @@
        void **ctx,
        const char *identifier)
 {
-  GNUNET_assert (NULL != emsg);
-  GNUNET_assert (my_ego == ego);
+  GNUNET_assert (NULL != ego);
+  GNUNET_assert (NULL != identifier);
   GNUNET_assert (0 == strcmp (identifier, "test-id"));
   op = GNUNET_IDENTITY_delete (h, 
                               "test-id",
@@ -222,7 +170,7 @@
 {
   endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 
                                                &endbadly, NULL); 
-  h = GNUNET_IDENTITY_connect (cfg, &notification_cb, NULL);
+  h = GNUNET_IDENTITY_connect (cfg, NULL, NULL);
   GNUNET_assert (NULL != h);
   op = GNUNET_IDENTITY_get (h,
                            "test-service",
@@ -248,7 +196,7 @@
 
 
 /**
- * Called with events about created ego.
+ * Called with events about egos.
  *
  * @param cls NULL
  * @param ego ego handle
@@ -259,11 +207,13 @@
  *                   must thus no longer be used
  */
 static void
-create_cb (void *cls,
-          struct GNUNET_IDENTITY_Ego *ego,
-          void **ctx,
-          const char *identifier)
-{  
+notification_cb (void *cls,
+                struct GNUNET_IDENTITY_Ego *ego,
+                void **ctx,
+                const char *identifier)
+{
+  if (NULL == ego)
+    return; /* skip first call */
   op = GNUNET_IDENTITY_set (h, 
                            "test-service",
                            ego,
@@ -273,6 +223,21 @@
 
 
 /**
+ * Called with events about created ego.
+ *
+ * @param cls NULL
+ * @param emsg error message
+ */
+static void
+create_cb (void *cls,
+          const char *emsg)
+{  
+  GNUNET_assert (NULL == emsg);
+  op = NULL;
+}
+
+
+/**
  * Main function of the test, run from scheduler.
  *
  * @param cls NULL
@@ -299,21 +264,23 @@
 int
 main (int argc, char *argv[])
 {
+  GNUNET_DISK_directory_remove ("/tmp/test-identity-service");
   res = 1;
   if (0 != 
-      GNUNET_TESTING_service_run ("test-identity",
+      GNUNET_TESTING_service_run ("test-identity-defaults",
                                  "identity",
                                  "test_identity.conf",
                                  &run_set,
                                  NULL))
     return 1;
   if (0 != 
-      GNUNET_TESTING_service_run ("test-identity",
+      GNUNET_TESTING_service_run ("test-identity-defaults",
                                  "identity",
                                  "test_identity.conf",
                                  &run_get,
                                  NULL))
     return 1;
+  GNUNET_DISK_directory_remove ("/tmp/test-identity-service");
   return res;
 }
 




reply via email to

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