[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28110 - gnunet/src/identity
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28110 - gnunet/src/identity |
Date: |
Wed, 17 Jul 2013 14:37:57 +0200 |
Author: grothoff
Date: 2013-07-17 14:37:57 +0200 (Wed, 17 Jul 2013)
New Revision: 28110
Modified:
gnunet/src/identity/test_identity.c
Log:
-improve test
Modified: gnunet/src/identity/test_identity.c
===================================================================
--- gnunet/src/identity/test_identity.c 2013-07-17 10:33:49 UTC (rev 28109)
+++ gnunet/src/identity/test_identity.c 2013-07-17 12:37:57 UTC (rev 28110)
@@ -113,7 +113,8 @@
GNUNET_SCHEDULER_cancel (endbadly_task);
endbadly_task = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_SCHEDULER_add_now (&end_normally, NULL);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
+ &end_normally, NULL);
}
@@ -134,11 +135,94 @@
void **ctx,
const char *identifier)
{
- // fprintf (stderr, "Notification: %s\n", identifier);
+ 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++;
}
/**
+ * Continuation called from successful delete operation.
+ *
+ * @param cls NULL
+ * @param emsg (should also be NULL)
+ */
+static void
+delete_cont (void *cls,
+ const char *emsg)
+{
+ op = NULL;
+ GNUNET_assert (NULL == emsg);
+ end ();
+}
+
+
+/**
+ * Continuation called from expected-to-fail rename operation.
+ *
+ * @param cls NULL
+ * @param emsg (should also be NULL)
+ */
+static void
+fail_rename_cont (void *cls,
+ const char *emsg)
+{
+ GNUNET_assert (NULL != emsg);
+ op = GNUNET_IDENTITY_delete (h,
+ "test",
+ &delete_cont,
+ NULL);
+ end (); /* yepee */
+}
+
+
+/**
+ * Continuation called from successful rename operation.
+ *
+ * @param cls NULL
+ * @param emsg (should also be NULL)
+ */
+static void
+success_rename_cont (void *cls,
+ const char *emsg)
+{
+ GNUNET_assert (NULL == emsg);
+ op = GNUNET_IDENTITY_rename (h,
+ "test-id",
+ "test",
+ &fail_rename_cont,
+ NULL);
+}
+
+
+/**
* Called with events about created ego.
*
* @param cls NULL
@@ -154,10 +238,12 @@
struct GNUNET_IDENTITY_Ego *ego,
void **ctx,
const char *identifier)
-{
- op = NULL;
- // fprintf (stderr, "HERE!\n");
- end (); /* yepee */
+{
+ op = GNUNET_IDENTITY_rename (h,
+ "test-id",
+ "test",
+ &success_rename_cont,
+ NULL);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28110 - gnunet/src/identity,
gnunet <=