aboutsummaryrefslogtreecommitdiff
path: root/src/identity/test_identity.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-21 22:27:17 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-21 22:27:17 +0000
commitdd9ed7931e52705b216c346127108520c5e4460b (patch)
tree3091fc4c7d2eaa93c5cd746e3d7ac155c2ff815e /src/identity/test_identity.c
parent028d6d5d44aa4affbc5e78d5bb26a9254fe7a13b (diff)
downloadgnunet-dd9ed7931e52705b216c346127108520c5e4460b.tar.gz
gnunet-dd9ed7931e52705b216c346127108520c5e4460b.zip
rework identity API to use new MQ API
Diffstat (limited to 'src/identity/test_identity.c')
-rw-r--r--src/identity/test_identity.c64
1 files changed, 50 insertions, 14 deletions
diff --git a/src/identity/test_identity.c b/src/identity/test_identity.c
index 37065ce08..7c88e0ace 100644
--- a/src/identity/test_identity.c
+++ b/src/identity/test_identity.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2013 GNUnet e.V. 3 Copyright (C) 2013, 2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -50,7 +50,7 @@ static struct GNUNET_IDENTITY_Operation *op;
50/** 50/**
51 * Handle for task for timeout termination. 51 * Handle for task for timeout termination.
52 */ 52 */
53static struct GNUNET_SCHEDULER_Task * endbadly_task; 53static struct GNUNET_SCHEDULER_Task *endbadly_task;
54 54
55 55
56/** 56/**
@@ -105,12 +105,12 @@ end_normally (void *cls)
105static void 105static void
106end () 106end ()
107{ 107{
108 if (endbadly_task != NULL) 108 if (NULL != endbadly_task)
109 { 109 {
110 GNUNET_SCHEDULER_cancel (endbadly_task); 110 GNUNET_SCHEDULER_cancel (endbadly_task);
111 endbadly_task = NULL; 111 endbadly_task = NULL;
112 } 112 }
113 GNUNET_SCHEDULER_add_now (&end_normally, NULL); 113 GNUNET_SCHEDULER_shutdown ();
114} 114}
115 115
116 116
@@ -142,21 +142,38 @@ notification_cb (void *cls,
142 break; 142 break;
143 case 1: /* create */ 143 case 1: /* create */
144 GNUNET_assert (NULL != ego); 144 GNUNET_assert (NULL != ego);
145 GNUNET_assert (0 == strcmp (identifier, "test-id")); 145 GNUNET_assert (0 == strcmp (identifier,
146 "test-id"));
146 my_ego = ego; 147 my_ego = ego;
147 *ctx = &round; 148 *ctx = &round;
148 break; 149 break;
149 case 2: /* rename */ 150 case 2: /* rename */
150 GNUNET_assert (my_ego == ego); 151 GNUNET_assert (my_ego == ego);
151 GNUNET_assert (0 == strcmp (identifier, "test")); 152 GNUNET_assert (0 == strcmp (identifier,
153 "test"));
152 GNUNET_assert (*ctx == &round); 154 GNUNET_assert (*ctx == &round);
153 break; 155 break;
154 case 3: /* delete */ 156 case 3: /* reconnect-down */
155 GNUNET_assert (my_ego == ego); 157 GNUNET_assert (my_ego == ego);
156 GNUNET_assert (NULL == identifier); 158 GNUNET_assert (NULL == identifier);
157 GNUNET_assert (*ctx == &round); 159 GNUNET_assert (*ctx == &round);
158 *ctx = NULL; 160 *ctx = NULL;
159 break; 161 break;
162 case 4: /* reconnect-up */
163 GNUNET_assert (0 == strcmp (identifier,
164 "test"));
165 my_ego = ego;
166 *ctx = &round;
167 break;
168 case 5: /* end of iteration after reconnect */
169 GNUNET_assert (NULL == ego);
170 GNUNET_assert (NULL == identifier);
171 break;
172 case 6: /* delete */
173 GNUNET_assert (my_ego == ego);
174 GNUNET_assert (*ctx == &round);
175 *ctx = NULL;
176 break;
160 default: 177 default:
161 GNUNET_break (0); 178 GNUNET_break (0);
162 } 179 }
@@ -181,6 +198,21 @@ delete_cont (void *cls,
181 198
182 199
183/** 200/**
201 * Continue by deleting the "test" identity.
202 *
203 * @param cls NULL
204 */
205static void
206finally_delete (void *cls)
207{
208 op = GNUNET_IDENTITY_delete (h,
209 "test",
210 &delete_cont,
211 NULL);
212}
213
214
215/**
184 * Continuation called from expected-to-fail rename operation. 216 * Continuation called from expected-to-fail rename operation.
185 * 217 *
186 * @param cls NULL 218 * @param cls NULL
@@ -191,11 +223,10 @@ fail_rename_cont (void *cls,
191 const char *emsg) 223 const char *emsg)
192{ 224{
193 GNUNET_assert (NULL != emsg); 225 GNUNET_assert (NULL != emsg);
194 op = GNUNET_IDENTITY_delete (h, 226 op = NULL;
195 "test", 227 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
196 &delete_cont, 228 &finally_delete,
197 NULL); 229 NULL);
198 end (); /* yepee */
199} 230}
200 231
201 232
@@ -250,8 +281,13 @@ run (void *cls,
250 struct GNUNET_TESTING_Peer *peer) 281 struct GNUNET_TESTING_Peer *peer)
251{ 282{
252 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 283 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
253 &endbadly, NULL); 284 &endbadly,
254 h = GNUNET_IDENTITY_connect (cfg, &notification_cb, NULL); 285 NULL);
286 GNUNET_SCHEDULER_add_shutdown (&end_normally,
287 NULL);
288 h = GNUNET_IDENTITY_connect (cfg,
289 &notification_cb,
290 NULL);
255 GNUNET_assert (NULL != h); 291 GNUNET_assert (NULL != h);
256 op = GNUNET_IDENTITY_create (h, 292 op = GNUNET_IDENTITY_create (h,
257 "test-id", 293 "test-id",