[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28096 - gnunet/src/identity
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28096 - gnunet/src/identity |
Date: |
Tue, 16 Jul 2013 17:09:28 +0200 |
Author: grothoff
Date: 2013-07-16 17:09:28 +0200 (Tue, 16 Jul 2013)
New Revision: 28096
Added:
gnunet/src/identity/test_identity.c
gnunet/src/identity/test_identity.conf
Modified:
gnunet/src/identity/Makefile.am
gnunet/src/identity/gnunet-identity.c
gnunet/src/identity/gnunet-service-identity.c
gnunet/src/identity/identity.conf.in
gnunet/src/identity/identity_api.c
Log:
-towards testing identity service
Modified: gnunet/src/identity/Makefile.am
===================================================================
--- gnunet/src/identity/Makefile.am 2013-07-16 13:17:02 UTC (rev 28095)
+++ gnunet/src/identity/Makefile.am 2013-07-16 15:09:28 UTC (rev 28096)
@@ -56,16 +56,16 @@
if HAVE_TESTING
check_PROGRAMS = \
- test_identity_api
+ test_identity
endif
if ENABLE_TEST_RUN
TESTS = $(check_PROGRAMS)
endif
-test_identity_api_SOURCES = \
- test_identity_api.c
-test_identity_api_LDADD = \
+test_identity_SOURCES = \
+ test_identity.c
+test_identity_LDADD = \
$(top_builddir)/src/identity/libgnunetidentity.la \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
Modified: gnunet/src/identity/gnunet-identity.c
===================================================================
--- gnunet/src/identity/gnunet-identity.c 2013-07-16 13:17:02 UTC (rev
28095)
+++ gnunet/src/identity/gnunet-identity.c 2013-07-16 15:09:28 UTC (rev
28096)
@@ -21,6 +21,10 @@
* @file identity/gnunet-identity.c
* @brief IDENTITY management command line tool
* @author Christian Grothoff
+ *
+ * Todo:
+ * - add options to get/set default egos
+ * - print short hashes of egos when printing
*/
#include "platform.h"
#include "gnunet_util_lib.h"
Modified: gnunet/src/identity/gnunet-service-identity.c
===================================================================
--- gnunet/src/identity/gnunet-service-identity.c 2013-07-16 13:17:02 UTC
(rev 28095)
+++ gnunet/src/identity/gnunet-service-identity.c 2013-07-16 15:09:28 UTC
(rev 28096)
@@ -25,6 +25,11 @@
*
* The purpose of this service is to manage private keys that
* 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?)
*/
#include "platform.h"
#include "gnunet_util_lib.h"
Modified: gnunet/src/identity/identity.conf.in
===================================================================
--- gnunet/src/identity/identity.conf.in 2013-07-16 13:17:02 UTC (rev
28095)
+++ gnunet/src/identity/identity.conf.in 2013-07-16 15:09:28 UTC (rev
28096)
@@ -1,39 +1,15 @@
-[nse]
+[identity]
AUTOSTART = YES
address@hidden@PORT = 2097
address@hidden@PORT = 2108
HOSTNAME = localhost
HOME = $SERVICEHOME
-BINARY = gnunet-service-nse
+BINARY = gnunet-service-identity
ACCEPT_FROM = 127.0.0.1;
ACCEPT_FROM6 = ::1;
-UNIXPATH = /tmp/test-nse-service-nse.unix
+UNIXPATH = /tmp/gnunet-service-identity.unix
UNIX_MATCH_UID = NO
UNIX_MATCH_GID = YES
-PROOFFILE = $SERVICEHOME/.nse-proof
-# The directory where the NSE services logs timestamps everytime
-# a size estime flooding message is received
-# This option is only used for benchmarking, not in production.
-HISTOGRAM_DIR = $SERVICEHOME
+# Directory where we store information about our egos
+EGODIR = $SERVICEHOME/egos/
-# How 'slowly' should the proof-of-work be constructed (delay
-# between rounds); sane values between 0 and ~1000.
-# It should rarely make sense to change this value.
-# Only systems with slow CPUs where 5ms is a long time might
-# want it to be reduced.
-WORKDELAY = 5 ms
-
-# Note: changing any of the values below will make this peer
-# completely incompatible with other peers!
-
-# How often do peers exchange network size messages?
-# Note that all peers MUST use the same interval.
-# DO NOT CHANGE THIS VALUE, doing so will break the protocol!
-INTERVAL = 1 h
-
-# 2^22 hash operations take about 2-3h on a modern i7 (single-core)
-# for SCRYPT; with 2ms/op and 5ms workdelay, we can expect
-# the POW calculation to be done by a high-end peer in about 6h
-# DO NOT CHANGE THIS VALUE, doing so will break the protocol!
-WORKBITS = 22
-
Modified: gnunet/src/identity/identity_api.c
===================================================================
--- gnunet/src/identity/identity_api.c 2013-07-16 13:17:02 UTC (rev 28095)
+++ gnunet/src/identity/identity_api.c 2013-07-16 15:09:28 UTC (rev 28096)
@@ -862,7 +862,7 @@
* @param op operation to cancel
*/
void
-GNUNET_IDENITY_cancel (struct GNUNET_IDENTITY_Operation *op)
+GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op)
{
struct GNUNET_IDENTITY_Handle *h = op->h;
Added: gnunet/src/identity/test_identity.c
===================================================================
--- gnunet/src/identity/test_identity.c (rev 0)
+++ gnunet/src/identity/test_identity.c 2013-07-16 15:09:28 UTC (rev 28096)
@@ -0,0 +1,203 @@
+/*
+ This file is part of GNUnet.
+ (C) 2013 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file identity/test_identity.c
+ * @brief testcase for identity service
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_common.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_identity_service.h"
+#include "gnunet_testing_lib.h"
+
+
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
+
+
+/**
+ * Return value from 'main'.
+ */
+static int res;
+
+/**
+ * Handle to identity service.
+ */
+static struct GNUNET_IDENTITY_Handle *h;
+
+/**
+ * Handle to identity operation.
+ */
+static struct GNUNET_IDENTITY_Operation *op;
+
+/**
+ * Handle for task for timeout termination.
+ */
+static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
+
+
+/**
+ * Clean up all resources used.
+ */
+static void
+cleanup ()
+{
+ if (NULL != h)
+ {
+ GNUNET_IDENTITY_disconnect (h);
+ h = NULL;
+ }
+ if (NULL != op)
+ {
+ GNUNET_IDENTITY_cancel (op);
+ op = NULL;
+ }
+ GNUNET_SCHEDULER_shutdown ();
+}
+
+
+/**
+ * Termiante the testcase (failure).
+ *
+ * @param cls NULL
+ * @param tc scheduler context
+ */
+static void
+endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ cleanup ();
+ res = 1;
+}
+
+
+/**
+ * Termiante the testcase (success).
+ *
+ * @param cls NULL
+ * @param tc scheduler context
+ */
+static void
+end_normally (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ cleanup ();
+ res = 0;
+}
+
+
+/**
+ * Finish the testcase (successfully).
+ */
+static void
+end ()
+{
+ if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel (endbadly_task);
+ endbadly_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ GNUNET_SCHEDULER_add_now (&end, NULL);
+}
+
+
+/**
+ * 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)
+{
+}
+
+
+/**
+ * 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
+ */
+static void
+create_cb (void *cls,
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *identifier)
+{
+ op = NULL;
+ end (); /* yepee */
+}
+
+
+
+/**
+ * Main function of the test, run from scheduler.
+ *
+ * @param cls NULL
+ * @param cfg configuration we use (also to connect to identity service)
+ * @param peer handle to access more of the peer (not used)
+ */
+static void
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Peer *peer)
+{
+ endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &endbadly, NULL);
+ h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL);
+ op = GNUNET_IDENTITY_create (h,
+ "test-id",
+ &create_cb,
+ NULL);
+
+}
+
+
+
+
+int
+main (int argc, char *argv[])
+{
+ res = 1;
+ if (0 !=
+ GNUNET_TESTING_service_run ("test-identity",
+ "identity",
+ "test_identity.conf",
+ &run,
+ NULL))
+ return 1;
+ return res;
+}
+
+
+/* end of test_identity.c */
Added: gnunet/src/identity/test_identity.conf
===================================================================
--- gnunet/src/identity/test_identity.conf (rev 0)
+++ gnunet/src/identity/test_identity.conf 2013-07-16 15:09:28 UTC (rev
28096)
@@ -0,0 +1,5 @@
+[arm]
+PORT = 12000
+DEFAULTSERVICES = identity
+UNIXPATH = /tmp/gnunet-p1-service-arm.sock
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28096 - gnunet/src/identity,
gnunet <=