aboutsummaryrefslogtreecommitdiff
path: root/src/identity/test_identity.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-07-17 12:37:57 +0000
committerChristian Grothoff <christian@grothoff.org>2013-07-17 12:37:57 +0000
commit59fd53ca5b57d1e5bc5aad9099318f4683c742b0 (patch)
tree50ce2341a1a8a2c1284fbb2db1ce68aaacb858fd /src/identity/test_identity.c
parent46446baabff53dc3eccc7a4665a15b3118c535d9 (diff)
downloadgnunet-59fd53ca5b57d1e5bc5aad9099318f4683c742b0.tar.gz
gnunet-59fd53ca5b57d1e5bc5aad9099318f4683c742b0.zip
-improve test
Diffstat (limited to 'src/identity/test_identity.c')
-rw-r--r--src/identity/test_identity.c98
1 files changed, 92 insertions, 6 deletions
diff --git a/src/identity/test_identity.c b/src/identity/test_identity.c
index 7c429770b..f97b469f4 100644
--- a/src/identity/test_identity.c
+++ b/src/identity/test_identity.c
@@ -113,7 +113,8 @@ end ()
113 GNUNET_SCHEDULER_cancel (endbadly_task); 113 GNUNET_SCHEDULER_cancel (endbadly_task);
114 endbadly_task = GNUNET_SCHEDULER_NO_TASK; 114 endbadly_task = GNUNET_SCHEDULER_NO_TASK;
115 } 115 }
116 GNUNET_SCHEDULER_add_now (&end_normally, NULL); 116 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
117 &end_normally, NULL);
117} 118}
118 119
119 120
@@ -134,7 +135,90 @@ notification_cb (void *cls,
134 void **ctx, 135 void **ctx,
135 const char *identifier) 136 const char *identifier)
136{ 137{
137 // fprintf (stderr, "Notification: %s\n", identifier); 138 static struct GNUNET_IDENTITY_Ego *my_ego;
139 static int round;
140
141 switch (round)
142 {
143 case 0: /* end of initial iteration */
144 GNUNET_assert (NULL == ego);
145 GNUNET_assert (NULL == identifier);
146 break;
147 case 1: /* create */
148 GNUNET_assert (NULL != ego);
149 GNUNET_assert (0 == strcmp (identifier, "test-id"));
150 my_ego = ego;
151 *ctx = &round;
152 break;
153 case 2: /* rename */
154 GNUNET_assert (my_ego == ego);
155 GNUNET_assert (0 == strcmp (identifier, "test"));
156 GNUNET_assert (*ctx == &round);
157 break;
158 case 3: /* delete */
159 GNUNET_assert (my_ego == ego);
160 GNUNET_assert (NULL == identifier);
161 GNUNET_assert (*ctx == &round);
162 *ctx = NULL;
163 break;
164 default:
165 GNUNET_break (0);
166 }
167 round++;
168}
169
170
171/**
172 * Continuation called from successful delete operation.
173 *
174 * @param cls NULL
175 * @param emsg (should also be NULL)
176 */
177static void
178delete_cont (void *cls,
179 const char *emsg)
180{
181 op = NULL;
182 GNUNET_assert (NULL == emsg);
183 end ();
184}
185
186
187/**
188 * Continuation called from expected-to-fail rename operation.
189 *
190 * @param cls NULL
191 * @param emsg (should also be NULL)
192 */
193static void
194fail_rename_cont (void *cls,
195 const char *emsg)
196{
197 GNUNET_assert (NULL != emsg);
198 op = GNUNET_IDENTITY_delete (h,
199 "test",
200 &delete_cont,
201 NULL);
202 end (); /* yepee */
203}
204
205
206/**
207 * Continuation called from successful rename operation.
208 *
209 * @param cls NULL
210 * @param emsg (should also be NULL)
211 */
212static void
213success_rename_cont (void *cls,
214 const char *emsg)
215{
216 GNUNET_assert (NULL == emsg);
217 op = GNUNET_IDENTITY_rename (h,
218 "test-id",
219 "test",
220 &fail_rename_cont,
221 NULL);
138} 222}
139 223
140 224
@@ -154,10 +238,12 @@ create_cb (void *cls,
154 struct GNUNET_IDENTITY_Ego *ego, 238 struct GNUNET_IDENTITY_Ego *ego,
155 void **ctx, 239 void **ctx,
156 const char *identifier) 240 const char *identifier)
157{ 241{
158 op = NULL; 242 op = GNUNET_IDENTITY_rename (h,
159 // fprintf (stderr, "HERE!\n"); 243 "test-id",
160 end (); /* yepee */ 244 "test",
245 &success_rename_cont,
246 NULL);
161} 247}
162 248
163 249