diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-06-01 00:52:06 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-06-01 00:52:13 +0200 |
commit | 47a7c12c47fa10728494623ea8f89beab8e5cd77 (patch) | |
tree | 2e37a6a55d169c96e9927c608a12f540e5cd0123 /src/identity | |
parent | 09d0b535d3b5dc8798b18a4791d45b4a9c8ab529 (diff) | |
download | gnunet-47a7c12c47fa10728494623ea8f89beab8e5cd77.tar.gz gnunet-47a7c12c47fa10728494623ea8f89beab8e5cd77.zip |
stash
Diffstat (limited to 'src/identity')
-rw-r--r-- | src/identity/gnunet-service-identity.c | 63 | ||||
-rw-r--r-- | src/identity/identity.h | 48 | ||||
-rw-r--r-- | src/identity/identity_api.c | 38 | ||||
-rw-r--r-- | src/identity/identity_api_lookup.c | 173 | ||||
-rw-r--r-- | src/identity/test_identity.c | 152 | ||||
-rw-r--r-- | src/identity/test_identity_defaults.c | 149 |
6 files changed, 353 insertions, 270 deletions
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c index 0a2fbbcb8..a675a01f0 100644 --- a/src/identity/gnunet-service-identity.c +++ b/src/identity/gnunet-service-identity.c | |||
@@ -291,16 +291,15 @@ create_set_default_message (struct Ego *ego, | |||
291 | * adds the client to the notification context for future | 291 | * adds the client to the notification context for future |
292 | * updates. | 292 | * updates. |
293 | * | 293 | * |
294 | * @param cls unused | 294 | * @param cls a `struct GNUNET_SERVICE_Client *` |
295 | * @param client who sent the message | ||
296 | * @param message the message received | 295 | * @param message the message received |
297 | */ | 296 | */ |
298 | static void | 297 | static void |
299 | handle_start_message (void *cls, | 298 | handle_start_message (void *cls, |
300 | const struct GNUNET_MessageHeader *message) | 299 | const struct GNUNET_MessageHeader *message) |
301 | { | 300 | { |
302 | struct UpdateMessage *ume; | ||
303 | struct GNUNET_SERVICE_Client *client = cls; | 301 | struct GNUNET_SERVICE_Client *client = cls; |
302 | struct UpdateMessage *ume; | ||
304 | struct GNUNET_MQ_Envelope *env; | 303 | struct GNUNET_MQ_Envelope *env; |
305 | struct Ego *ego; | 304 | struct Ego *ego; |
306 | 305 | ||
@@ -324,6 +323,60 @@ handle_start_message (void *cls, | |||
324 | GNUNET_SERVICE_client_continue (client); | 323 | GNUNET_SERVICE_client_continue (client); |
325 | } | 324 | } |
326 | 325 | ||
326 | |||
327 | /** | ||
328 | * Handler for LOOKUP message from client, sends information | ||
329 | * about ONE identity to the client immediately. | ||
330 | * | ||
331 | * @param cls unused | ||
332 | * @param message the message received | ||
333 | * @return #GNUNET_SYSERR if message was ill-formed | ||
334 | */ | ||
335 | static int | ||
336 | check_lookup_message (void *cls, | ||
337 | const struct LookupMessage *message) | ||
338 | { | ||
339 | GNUNET_MQ_check_zero_termination (message); | ||
340 | return GNUNET_OK; | ||
341 | } | ||
342 | |||
343 | |||
344 | /** | ||
345 | * Handler for LOOKUP message from client, sends information | ||
346 | * about ONE identity to the client immediately. | ||
347 | * | ||
348 | * @param cls a `struct GNUNET_SERVICE_Client *` | ||
349 | * @param message the message received | ||
350 | */ | ||
351 | static void | ||
352 | handle_lookup_message (void *cls, | ||
353 | const struct LookupMessage *message) | ||
354 | { | ||
355 | struct GNUNET_SERVICE_Client *client = cls; | ||
356 | const char *name; | ||
357 | struct GNUNET_MQ_Envelope *env; | ||
358 | struct Ego *ego; | ||
359 | |||
360 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
361 | "Received LOOKUP message from client\n"); | ||
362 | name = (const char *) &message[1]; | ||
363 | for (ego = ego_head; NULL != ego; ego = ego->next) | ||
364 | { | ||
365 | if (0 != strcasecmp (name, | ||
366 | ego->identifier)) | ||
367 | continue; | ||
368 | env = create_update_message (ego); | ||
369 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); | ||
370 | GNUNET_SERVICE_client_continue (client); | ||
371 | return; | ||
372 | } | ||
373 | send_result_code (client, | ||
374 | 0, | ||
375 | "ego not found"); | ||
376 | GNUNET_SERVICE_client_continue (client); | ||
377 | } | ||
378 | |||
379 | |||
327 | /** | 380 | /** |
328 | * Checks a #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT message | 381 | * Checks a #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT message |
329 | * | 382 | * |
@@ -1061,6 +1114,10 @@ GNUNET_SERVICE_MAIN | |||
1061 | GNUNET_MESSAGE_TYPE_IDENTITY_START, | 1114 | GNUNET_MESSAGE_TYPE_IDENTITY_START, |
1062 | struct GNUNET_MessageHeader, | 1115 | struct GNUNET_MessageHeader, |
1063 | NULL), | 1116 | NULL), |
1117 | GNUNET_MQ_hd_var_size (lookup_message, | ||
1118 | GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP, | ||
1119 | struct LookupMessage, | ||
1120 | NULL), | ||
1064 | GNUNET_MQ_hd_var_size (get_default_message, | 1121 | GNUNET_MQ_hd_var_size (get_default_message, |
1065 | GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT, | 1122 | GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT, |
1066 | struct GetDefaultMessage, | 1123 | struct GetDefaultMessage, |
diff --git a/src/identity/identity.h b/src/identity/identity.h index 7e7b5d4cd..96550bdf2 100644 --- a/src/identity/identity.h +++ b/src/identity/identity.h | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -53,7 +53,20 @@ struct ResultCodeMessage | |||
53 | uint32_t result_code GNUNET_PACKED; | 53 | uint32_t result_code GNUNET_PACKED; |
54 | 54 | ||
55 | /* followed by 0-terminated error message (on error) */ | 55 | /* followed by 0-terminated error message (on error) */ |
56 | }; | ||
57 | |||
56 | 58 | ||
59 | /** | ||
60 | * Client informs service about desire to lookup a (single) pseudonym. | ||
61 | */ | ||
62 | struct LookupMessage | ||
63 | { | ||
64 | /** | ||
65 | * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP | ||
66 | */ | ||
67 | struct GNUNET_MessageHeader header; | ||
68 | |||
69 | /* followed by 0-terminated ego name */ | ||
57 | }; | 70 | }; |
58 | 71 | ||
59 | 72 | ||
@@ -84,11 +97,9 @@ struct UpdateMessage | |||
84 | struct GNUNET_CRYPTO_EcdsaPrivateKey private_key; | 97 | struct GNUNET_CRYPTO_EcdsaPrivateKey private_key; |
85 | 98 | ||
86 | /* followed by 0-terminated ego name */ | 99 | /* followed by 0-terminated ego name */ |
87 | |||
88 | }; | 100 | }; |
89 | 101 | ||
90 | 102 | ||
91 | |||
92 | /** | 103 | /** |
93 | * Client requests knowledge about default identity for | 104 | * Client requests knowledge about default identity for |
94 | * a subsystem from identity service. | 105 | * a subsystem from identity service. |
@@ -112,7 +123,6 @@ struct GetDefaultMessage | |||
112 | 123 | ||
113 | 124 | ||
114 | /* followed by 0-terminated service name */ | 125 | /* followed by 0-terminated service name */ |
115 | |||
116 | }; | 126 | }; |
117 | 127 | ||
118 | 128 | ||
@@ -143,7 +153,6 @@ struct SetDefaultMessage | |||
143 | struct GNUNET_CRYPTO_EcdsaPrivateKey private_key; | 153 | struct GNUNET_CRYPTO_EcdsaPrivateKey private_key; |
144 | 154 | ||
145 | /* followed by 0-terminated service name */ | 155 | /* followed by 0-terminated service name */ |
146 | |||
147 | }; | 156 | }; |
148 | 157 | ||
149 | 158 | ||
@@ -174,7 +183,6 @@ struct CreateRequestMessage | |||
174 | struct GNUNET_CRYPTO_EcdsaPrivateKey private_key; | 183 | struct GNUNET_CRYPTO_EcdsaPrivateKey private_key; |
175 | 184 | ||
176 | /* followed by 0-terminated identity name */ | 185 | /* followed by 0-terminated identity name */ |
177 | |||
178 | }; | 186 | }; |
179 | 187 | ||
180 | 188 | ||
@@ -226,11 +234,35 @@ struct DeleteMessage | |||
226 | uint16_t reserved GNUNET_PACKED; | 234 | uint16_t reserved GNUNET_PACKED; |
227 | 235 | ||
228 | /* followed by 0-terminated name */ | 236 | /* followed by 0-terminated name */ |
229 | |||
230 | }; | 237 | }; |
231 | 238 | ||
239 | GNUNET_NETWORK_STRUCT_END | ||
232 | 240 | ||
241 | /** | ||
242 | * Handle for an ego. | ||
243 | */ | ||
244 | struct GNUNET_IDENTITY_Ego | ||
245 | { | ||
246 | /** | ||
247 | * Private key associated with this ego. | ||
248 | */ | ||
249 | struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; | ||
250 | |||
251 | /** | ||
252 | * Current name associated with this ego. | ||
253 | */ | ||
254 | char *name; | ||
255 | |||
256 | /** | ||
257 | * Client context associated with this ego. | ||
258 | */ | ||
259 | void *ctx; | ||
260 | |||
261 | /** | ||
262 | * Hash of the public key of this ego. | ||
263 | */ | ||
264 | struct GNUNET_HashCode id; | ||
265 | }; | ||
233 | 266 | ||
234 | GNUNET_NETWORK_STRUCT_END | ||
235 | 267 | ||
236 | #endif | 268 | #endif |
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index 6cf1b65ca..fa7c8b023 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -32,32 +32,6 @@ | |||
32 | 32 | ||
33 | #define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__) | 33 | #define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__) |
34 | 34 | ||
35 | /** | ||
36 | * Handle for an ego. | ||
37 | */ | ||
38 | struct GNUNET_IDENTITY_Ego | ||
39 | { | ||
40 | /** | ||
41 | * Private key associated with this ego. | ||
42 | */ | ||
43 | struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; | ||
44 | |||
45 | /** | ||
46 | * Current name associated with this ego. | ||
47 | */ | ||
48 | char *name; | ||
49 | |||
50 | /** | ||
51 | * Client context associated with this ego. | ||
52 | */ | ||
53 | void *ctx; | ||
54 | |||
55 | /** | ||
56 | * Hash of the public key of this ego. | ||
57 | */ | ||
58 | struct GNUNET_HashCode id; | ||
59 | }; | ||
60 | |||
61 | 35 | ||
62 | /** | 36 | /** |
63 | * Handle for an operation with the identity service. | 37 | * Handle for an operation with the identity service. |
@@ -298,16 +272,8 @@ mq_error_handler (void *cls, enum GNUNET_MQ_Error error) | |||
298 | static int | 272 | static int |
299 | check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) | 273 | check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) |
300 | { | 274 | { |
301 | uint16_t size = ntohs (rcm->header.size) - sizeof (*rcm); | 275 | if (sizeof (*rcm) != htons (rcm->header.size)) |
302 | const char *str = (const char *) &rcm[1]; | 276 | GNUNET_MQ_check_zero_termination (rcm); |
303 | |||
304 | if (0 == size) | ||
305 | return GNUNET_OK; | ||
306 | if ('\0' != str[size - 1]) | ||
307 | { | ||
308 | GNUNET_break (0); | ||
309 | return GNUNET_SYSERR; | ||
310 | } | ||
311 | return GNUNET_OK; | 277 | return GNUNET_OK; |
312 | } | 278 | } |
313 | 279 | ||
diff --git a/src/identity/identity_api_lookup.c b/src/identity/identity_api_lookup.c index 40a22c262..56ebf6f47 100644 --- a/src/identity/identity_api_lookup.c +++ b/src/identity/identity_api_lookup.c | |||
@@ -26,8 +26,9 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_identity_service.h" | 28 | #include "gnunet_identity_service.h" |
29 | #include "identity.h" | ||
29 | 30 | ||
30 | #define LOG(kind,...) GNUNET_log_from (kind, "identity-api",__VA_ARGS__) | 31 | #define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__) |
31 | 32 | ||
32 | 33 | ||
33 | /** | 34 | /** |
@@ -37,9 +38,9 @@ struct GNUNET_IDENTITY_EgoLookup | |||
37 | { | 38 | { |
38 | 39 | ||
39 | /** | 40 | /** |
40 | * Handle to the identity service. | 41 | * Connection to service. |
41 | */ | 42 | */ |
42 | struct GNUNET_IDENTITY_Handle *identity; | 43 | struct GNUNET_MQ_Handle *mq; |
43 | 44 | ||
44 | /** | 45 | /** |
45 | * Name of the ego we are looking up. | 46 | * Name of the ego we are looking up. |
@@ -59,53 +60,103 @@ struct GNUNET_IDENTITY_EgoLookup | |||
59 | 60 | ||
60 | 61 | ||
61 | /** | 62 | /** |
62 | * Method called to inform about the egos of this peer. | 63 | * We received a result code from the service. Check the message |
64 | * is well-formed. | ||
63 | * | 65 | * |
64 | * When used with #GNUNET_IDENTITY_connect, this function is | 66 | * @param cls closure |
65 | * initially called for all egos and then again whenever a | 67 | * @param rcm result message received |
66 | * ego's name changes or if it is deleted. At the end of | 68 | * @return #GNUNET_OK if the message is well-formed |
67 | * the initial pass over all egos, the function is once called | 69 | */ |
68 | * with 'NULL' for @a ego. That does NOT mean that the callback won't | 70 | static int |
69 | * be invoked in the future or that there was an error. | 71 | check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) |
70 | * | 72 | { |
71 | * If the @a name matches the name from @a cls, we found the zone | 73 | if (sizeof (*rcm) != htons (rcm->header.size)) |
72 | * for our computation and will invoke the callback. | 74 | GNUNET_MQ_check_zero_termination (rcm); |
73 | * If we have iterated over all egos and not found the name, we | 75 | return GNUNET_OK; |
74 | * invoke the callback with NULL. | 76 | } |
77 | |||
78 | |||
79 | /** | ||
80 | * We received a result code from the service. | ||
75 | * | 81 | * |
76 | * @param cls closure with the `struct GNUNET_IDENTITY_EgoLookup` | 82 | * @param cls closure |
77 | * @param ego ego handle | 83 | * @param rcm result message received |
78 | * @param ctx context for application to store data for this ego | ||
79 | * (during the lifetime of this process, initially NULL) | ||
80 | * @param name name assigned by the user for this ego, | ||
81 | * NULL if the user just deleted the ego and it | ||
82 | * must thus no longer be used | ||
83 | */ | 84 | */ |
84 | static void | 85 | static void |
85 | identity_cb (void *cls, | 86 | handle_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) |
86 | struct GNUNET_IDENTITY_Ego *ego, | ||
87 | void **ctx, | ||
88 | const char *name) | ||
89 | { | 87 | { |
90 | struct GNUNET_IDENTITY_EgoLookup *el = cls; | 88 | struct GNUNET_IDENTITY_EgoLookup *el = cls; |
91 | 89 | ||
92 | if ( (NULL != name) && | 90 | el->cb (el->cb_cls, NULL); |
93 | (0 == strcmp (name, | 91 | GNUNET_IDENTITY_ego_lookup_cancel (el); |
94 | el->name)) ) | 92 | } |
95 | { | 93 | |
96 | el->cb (el->cb_cls, | 94 | |
97 | ego); | 95 | /** |
98 | GNUNET_IDENTITY_ego_lookup_cancel (el); | 96 | * Check validity of identity update message. |
99 | return; | 97 | * |
100 | } | 98 | * @param cls closure |
101 | if (NULL == ego) | 99 | * @param um message received |
100 | * @return #GNUNET_OK if the message is well-formed | ||
101 | */ | ||
102 | static int | ||
103 | check_identity_update (void *cls, const struct UpdateMessage *um) | ||
104 | { | ||
105 | uint16_t size = ntohs (um->header.size); | ||
106 | uint16_t name_len = ntohs (um->name_len); | ||
107 | const char *str = (const char *) &um[1]; | ||
108 | |||
109 | if ((size != name_len + sizeof (struct UpdateMessage)) || | ||
110 | ((0 != name_len) && ('\0' != str[name_len - 1]))) | ||
102 | { | 111 | { |
103 | /* not found */ | 112 | GNUNET_break (0); |
104 | el->cb (el->cb_cls, | 113 | return GNUNET_SYSERR; |
105 | NULL); | ||
106 | GNUNET_IDENTITY_ego_lookup_cancel (el); | ||
107 | return; | ||
108 | } | 114 | } |
115 | return GNUNET_OK; | ||
116 | } | ||
117 | |||
118 | |||
119 | /** | ||
120 | * Handle identity update message. | ||
121 | * | ||
122 | * @param cls closure | ||
123 | * @param um message received | ||
124 | */ | ||
125 | static void | ||
126 | handle_identity_update (void *cls, const struct UpdateMessage *um) | ||
127 | { | ||
128 | struct GNUNET_IDENTITY_EgoLookup *el = cls; | ||
129 | uint16_t name_len = ntohs (um->name_len); | ||
130 | const char *str = (0 == name_len) ? NULL : (const char *) &um[1]; | ||
131 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; | ||
132 | struct GNUNET_HashCode id; | ||
133 | struct GNUNET_IDENTITY_Ego ego; | ||
134 | |||
135 | GNUNET_break (GNUNET_YES != ntohs (um->end_of_list)); | ||
136 | GNUNET_CRYPTO_ecdsa_key_get_public (&um->private_key, &pub); | ||
137 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id); | ||
138 | ego.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *) &um->private_key; | ||
139 | ego.name = (char *) str; | ||
140 | ego.id = id; | ||
141 | el->cb (el->cb_cls, &ego); | ||
142 | GNUNET_IDENTITY_ego_lookup_cancel (el); | ||
143 | } | ||
144 | |||
145 | |||
146 | /** | ||
147 | * Generic error handler, called with the appropriate error code and | ||
148 | * the same closure specified at the creation of the message queue. | ||
149 | * Not every message queue implementation supports an error handler. | ||
150 | * | ||
151 | * @param cls closure with the `struct GNUNET_IDENTITY_EgoLookup *` | ||
152 | * @param error error code | ||
153 | */ | ||
154 | static void | ||
155 | mq_error_handler (void *cls, enum GNUNET_MQ_Error error) | ||
156 | { | ||
157 | struct GNUNET_IDENTITY_EgoLookup *el = cls; | ||
158 | |||
159 | el->cb (el->cb_cls, NULL); | ||
109 | } | 160 | } |
110 | 161 | ||
111 | 162 | ||
@@ -120,25 +171,45 @@ identity_cb (void *cls, | |||
120 | */ | 171 | */ |
121 | struct GNUNET_IDENTITY_EgoLookup * | 172 | struct GNUNET_IDENTITY_EgoLookup * |
122 | GNUNET_IDENTITY_ego_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, | 173 | GNUNET_IDENTITY_ego_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, |
123 | const char *name, | 174 | const char *name, |
124 | GNUNET_IDENTITY_EgoCallback cb, | 175 | GNUNET_IDENTITY_EgoCallback cb, |
125 | void *cb_cls) | 176 | void *cb_cls) |
126 | { | 177 | { |
127 | struct GNUNET_IDENTITY_EgoLookup *el; | 178 | struct GNUNET_IDENTITY_EgoLookup *el; |
179 | struct GNUNET_MQ_Envelope *env; | ||
180 | struct GNUNET_MessageHeader *req; | ||
181 | size_t nlen; | ||
128 | 182 | ||
183 | GNUNET_assert (NULL != cb); | ||
129 | el = GNUNET_new (struct GNUNET_IDENTITY_EgoLookup); | 184 | el = GNUNET_new (struct GNUNET_IDENTITY_EgoLookup); |
130 | el->name = GNUNET_strdup (name); | ||
131 | el->cb = cb; | 185 | el->cb = cb; |
132 | el->cb_cls = cb_cls; | 186 | el->cb_cls = cb_cls; |
133 | el->identity = GNUNET_IDENTITY_connect (cfg, | ||
134 | &identity_cb, | ||
135 | el); | ||
136 | if (NULL == el->identity) | ||
137 | { | 187 | { |
138 | GNUNET_free (el->name); | 188 | struct GNUNET_MQ_MessageHandler handlers[] = |
189 | {GNUNET_MQ_hd_var_size (identity_result_code, | ||
190 | GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, | ||
191 | struct ResultCodeMessage, | ||
192 | el), | ||
193 | GNUNET_MQ_hd_var_size (identity_update, | ||
194 | GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, | ||
195 | struct UpdateMessage, | ||
196 | el), | ||
197 | GNUNET_MQ_handler_end ()}; | ||
198 | |||
199 | el->mq = | ||
200 | GNUNET_CLIENT_connect (cfg, "identity", handlers, &mq_error_handler, el); | ||
201 | } | ||
202 | if (NULL == el->mq) | ||
203 | { | ||
204 | GNUNET_break (0); | ||
139 | GNUNET_free (el); | 205 | GNUNET_free (el); |
140 | return NULL; | 206 | return NULL; |
141 | } | 207 | } |
208 | el->name = GNUNET_strdup (name); | ||
209 | nlen = strlen (name) + 1; | ||
210 | env = GNUNET_MQ_msg_extra (req, nlen, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP); | ||
211 | memcpy (&req[1], name, nlen); | ||
212 | GNUNET_MQ_send (el->mq, env); | ||
142 | return el; | 213 | return el; |
143 | } | 214 | } |
144 | 215 | ||
@@ -151,7 +222,7 @@ GNUNET_IDENTITY_ego_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
151 | void | 222 | void |
152 | GNUNET_IDENTITY_ego_lookup_cancel (struct GNUNET_IDENTITY_EgoLookup *el) | 223 | GNUNET_IDENTITY_ego_lookup_cancel (struct GNUNET_IDENTITY_EgoLookup *el) |
153 | { | 224 | { |
154 | GNUNET_IDENTITY_disconnect (el->identity); | 225 | GNUNET_MQ_destroy (el->mq); |
155 | GNUNET_free (el->name); | 226 | GNUNET_free (el->name); |
156 | GNUNET_free (el); | 227 | GNUNET_free (el); |
157 | } | 228 | } |
diff --git a/src/identity/test_identity.c b/src/identity/test_identity.c index 163394801..74c052917 100644 --- a/src/identity/test_identity.c +++ b/src/identity/test_identity.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -52,13 +52,25 @@ static struct GNUNET_IDENTITY_Operation *op; | |||
52 | */ | 52 | */ |
53 | static struct GNUNET_SCHEDULER_Task *endbadly_task; | 53 | static struct GNUNET_SCHEDULER_Task *endbadly_task; |
54 | 54 | ||
55 | #define CHECK(cond) \ | ||
56 | do \ | ||
57 | { \ | ||
58 | if (! (cond)) \ | ||
59 | { \ | ||
60 | GNUNET_break (0); \ | ||
61 | end (); \ | ||
62 | return; \ | ||
63 | } \ | ||
64 | } while (0) | ||
65 | |||
55 | 66 | ||
56 | /** | 67 | /** |
57 | * Clean up all resources used. | 68 | * Clean up all resources used. |
58 | */ | 69 | */ |
59 | static void | 70 | static void |
60 | cleanup () | 71 | cleanup (void *cls) |
61 | { | 72 | { |
73 | (void) cls; | ||
62 | if (NULL != op) | 74 | if (NULL != op) |
63 | { | 75 | { |
64 | GNUNET_IDENTITY_cancel (op); | 76 | GNUNET_IDENTITY_cancel (op); |
@@ -69,7 +81,6 @@ cleanup () | |||
69 | GNUNET_IDENTITY_disconnect (h); | 81 | GNUNET_IDENTITY_disconnect (h); |
70 | h = NULL; | 82 | h = NULL; |
71 | } | 83 | } |
72 | GNUNET_SCHEDULER_shutdown (); | ||
73 | } | 84 | } |
74 | 85 | ||
75 | 86 | ||
@@ -81,21 +92,7 @@ cleanup () | |||
81 | static void | 92 | static void |
82 | endbadly (void *cls) | 93 | endbadly (void *cls) |
83 | { | 94 | { |
84 | cleanup (); | 95 | GNUNET_SCHEDULER_shutdown (); |
85 | res = 1; | ||
86 | } | ||
87 | |||
88 | |||
89 | /** | ||
90 | * Termiante the testcase (success). | ||
91 | * | ||
92 | * @param cls NULL | ||
93 | */ | ||
94 | static void | ||
95 | end_normally (void *cls) | ||
96 | { | ||
97 | cleanup (); | ||
98 | res = 0; | ||
99 | } | 96 | } |
100 | 97 | ||
101 | 98 | ||
@@ -127,9 +124,9 @@ end () | |||
127 | */ | 124 | */ |
128 | static void | 125 | static void |
129 | notification_cb (void *cls, | 126 | notification_cb (void *cls, |
130 | struct GNUNET_IDENTITY_Ego *ego, | 127 | struct GNUNET_IDENTITY_Ego *ego, |
131 | void **ctx, | 128 | void **ctx, |
132 | const char *identifier) | 129 | const char *identifier) |
133 | { | 130 | { |
134 | static struct GNUNET_IDENTITY_Ego *my_ego; | 131 | static struct GNUNET_IDENTITY_Ego *my_ego; |
135 | static int round; | 132 | static int round; |
@@ -137,45 +134,45 @@ notification_cb (void *cls, | |||
137 | switch (round) | 134 | switch (round) |
138 | { | 135 | { |
139 | case 0: /* end of initial iteration */ | 136 | case 0: /* end of initial iteration */ |
140 | GNUNET_assert (NULL == ego); | 137 | CHECK (NULL == ego); |
141 | GNUNET_assert (NULL == identifier); | 138 | CHECK (NULL == identifier); |
142 | break; | 139 | break; |
143 | case 1: /* create */ | 140 | case 1: /* create */ |
144 | GNUNET_assert (NULL != ego); | 141 | CHECK (NULL != ego); |
145 | GNUNET_assert (0 == strcmp (identifier, | 142 | CHECK (NULL != identifier); |
146 | "test-id")); | 143 | CHECK (0 == strcmp (identifier, "test-id")); |
147 | my_ego = ego; | 144 | my_ego = ego; |
148 | *ctx = &round; | 145 | *ctx = &round; |
149 | break; | 146 | break; |
150 | case 2: /* rename */ | 147 | case 2: /* rename */ |
151 | GNUNET_assert (my_ego == ego); | 148 | CHECK (my_ego == ego); |
152 | GNUNET_assert (0 == strcmp (identifier, | 149 | CHECK (NULL != identifier); |
153 | "test")); | 150 | CHECK (0 == strcmp (identifier, "test")); |
154 | GNUNET_assert (*ctx == &round); | 151 | CHECK (*ctx == &round); |
155 | break; | 152 | break; |
156 | case 3: /* reconnect-down */ | 153 | case 3: /* reconnect-down */ |
157 | GNUNET_assert (my_ego == ego); | 154 | CHECK (my_ego == ego); |
158 | GNUNET_assert (NULL == identifier); | 155 | CHECK (NULL == identifier); |
159 | GNUNET_assert (*ctx == &round); | 156 | CHECK (*ctx == &round); |
160 | *ctx = NULL; | 157 | *ctx = NULL; |
161 | break; | 158 | break; |
162 | case 4: /* reconnect-up */ | 159 | case 4: /* reconnect-up */ |
163 | GNUNET_assert (0 == strcmp (identifier, | 160 | CHECK (NULL != identifier); |
164 | "test")); | 161 | CHECK (0 == strcmp (identifier, "test")); |
165 | my_ego = ego; | 162 | my_ego = ego; |
166 | *ctx = &round; | 163 | *ctx = &round; |
167 | break; | 164 | break; |
168 | case 5: /* end of iteration after reconnect */ | 165 | case 5: /* end of iteration after reconnect */ |
169 | GNUNET_assert (NULL == ego); | 166 | CHECK (NULL == ego); |
170 | GNUNET_assert (NULL == identifier); | 167 | CHECK (NULL == identifier); |
171 | break; | 168 | break; |
172 | case 6: /* delete */ | 169 | case 6: /* delete */ |
173 | GNUNET_assert (my_ego == ego); | 170 | CHECK (my_ego == ego); |
174 | GNUNET_assert (*ctx == &round); | 171 | CHECK (*ctx == &round); |
175 | *ctx = NULL; | 172 | *ctx = NULL; |
176 | break; | 173 | break; |
177 | default: | 174 | default: |
178 | GNUNET_break (0); | 175 | CHECK (0); |
179 | } | 176 | } |
180 | round++; | 177 | round++; |
181 | } | 178 | } |
@@ -188,11 +185,11 @@ notification_cb (void *cls, | |||
188 | * @param emsg (should also be NULL) | 185 | * @param emsg (should also be NULL) |
189 | */ | 186 | */ |
190 | static void | 187 | static void |
191 | delete_cont (void *cls, | 188 | delete_cont (void *cls, const char *emsg) |
192 | const char *emsg) | ||
193 | { | 189 | { |
194 | op = NULL; | 190 | op = NULL; |
195 | GNUNET_assert (NULL == emsg); | 191 | CHECK (NULL == emsg); |
192 | res = 0; | ||
196 | end (); | 193 | end (); |
197 | } | 194 | } |
198 | 195 | ||
@@ -205,10 +202,7 @@ delete_cont (void *cls, | |||
205 | static void | 202 | static void |
206 | finally_delete (void *cls) | 203 | finally_delete (void *cls) |
207 | { | 204 | { |
208 | op = GNUNET_IDENTITY_delete (h, | 205 | op = GNUNET_IDENTITY_delete (h, "test", &delete_cont, NULL); |
209 | "test", | ||
210 | &delete_cont, | ||
211 | NULL); | ||
212 | } | 206 | } |
213 | 207 | ||
214 | 208 | ||
@@ -219,10 +213,9 @@ finally_delete (void *cls) | |||
219 | * @param emsg (should also be NULL) | 213 | * @param emsg (should also be NULL) |
220 | */ | 214 | */ |
221 | static void | 215 | static void |
222 | fail_rename_cont (void *cls, | 216 | fail_rename_cont (void *cls, const char *emsg) |
223 | const char *emsg) | ||
224 | { | 217 | { |
225 | GNUNET_assert (NULL != emsg); | 218 | CHECK (NULL != emsg); |
226 | op = NULL; | 219 | op = NULL; |
227 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 220 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
228 | &finally_delete, | 221 | &finally_delete, |
@@ -237,15 +230,10 @@ fail_rename_cont (void *cls, | |||
237 | * @param emsg (should also be NULL) | 230 | * @param emsg (should also be NULL) |
238 | */ | 231 | */ |
239 | static void | 232 | static void |
240 | success_rename_cont (void *cls, | 233 | success_rename_cont (void *cls, const char *emsg) |
241 | const char *emsg) | ||
242 | { | 234 | { |
243 | GNUNET_assert (NULL == emsg); | 235 | CHECK (NULL == emsg); |
244 | op = GNUNET_IDENTITY_rename (h, | 236 | op = GNUNET_IDENTITY_rename (h, "test-id", "test", &fail_rename_cont, NULL); |
245 | "test-id", | ||
246 | "test", | ||
247 | &fail_rename_cont, | ||
248 | NULL); | ||
249 | } | 237 | } |
250 | 238 | ||
251 | 239 | ||
@@ -258,16 +246,13 @@ success_rename_cont (void *cls, | |||
258 | */ | 246 | */ |
259 | static void | 247 | static void |
260 | create_cb (void *cls, | 248 | create_cb (void *cls, |
261 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, | 249 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, |
262 | const char *emsg) | 250 | const char *emsg) |
263 | { | 251 | { |
264 | GNUNET_assert (NULL != pk); | 252 | CHECK (NULL != pk); |
265 | GNUNET_assert (NULL == emsg); | 253 | CHECK (NULL == emsg); |
266 | op = GNUNET_IDENTITY_rename (h, | 254 | op = |
267 | "test-id", | 255 | GNUNET_IDENTITY_rename (h, "test-id", "test", &success_rename_cont, NULL); |
268 | "test", | ||
269 | &success_rename_cont, | ||
270 | NULL); | ||
271 | } | 256 | } |
272 | 257 | ||
273 | 258 | ||
@@ -283,35 +268,26 @@ run (void *cls, | |||
283 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 268 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
284 | struct GNUNET_TESTING_Peer *peer) | 269 | struct GNUNET_TESTING_Peer *peer) |
285 | { | 270 | { |
286 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 271 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL); |
287 | &endbadly, | 272 | GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL); |
288 | NULL); | 273 | h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL); |
289 | GNUNET_SCHEDULER_add_shutdown (&end_normally, | 274 | CHECK (NULL != h); |
290 | NULL); | 275 | op = GNUNET_IDENTITY_create (h, "test-id", &create_cb, NULL); |
291 | h = GNUNET_IDENTITY_connect (cfg, | ||
292 | ¬ification_cb, | ||
293 | NULL); | ||
294 | GNUNET_assert (NULL != h); | ||
295 | op = GNUNET_IDENTITY_create (h, | ||
296 | "test-id", | ||
297 | &create_cb, | ||
298 | NULL); | ||
299 | |||
300 | } | 276 | } |
301 | 277 | ||
302 | 278 | ||
303 | int | 279 | int |
304 | main (int argc, char *argv[]) | 280 | main (int argc, char *argv[]) |
305 | { | 281 | { |
306 | GNUNET_DISK_directory_remove ("/tmp/test-identity-service"); | 282 | GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service"); |
307 | res = 1; | 283 | res = 1; |
308 | if (0 != | 284 | if (0 != GNUNET_TESTING_service_run ("test-identity", |
309 | GNUNET_TESTING_service_run ("test-identity", | 285 | "identity", |
310 | "identity", | 286 | "test_identity.conf", |
311 | "test_identity.conf", | 287 | &run, |
312 | &run, | 288 | NULL)) |
313 | NULL)) | ||
314 | return 1; | 289 | return 1; |
290 | GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service"); | ||
315 | return res; | 291 | return res; |
316 | } | 292 | } |
317 | 293 | ||
diff --git a/src/identity/test_identity_defaults.c b/src/identity/test_identity_defaults.c index bcd75e84c..ecda31c4c 100644 --- a/src/identity/test_identity_defaults.c +++ b/src/identity/test_identity_defaults.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -50,15 +50,27 @@ static struct GNUNET_IDENTITY_Operation *op; | |||
50 | /** | 50 | /** |
51 | * Handle for task for timeout termination. | 51 | * Handle for task for timeout termination. |
52 | */ | 52 | */ |
53 | static struct GNUNET_SCHEDULER_Task * endbadly_task; | 53 | static struct GNUNET_SCHEDULER_Task *endbadly_task; |
54 | |||
55 | #define CHECK(cond) \ | ||
56 | do \ | ||
57 | { \ | ||
58 | if (! (cond)) \ | ||
59 | { \ | ||
60 | GNUNET_break (0); \ | ||
61 | end (); \ | ||
62 | return; \ | ||
63 | } \ | ||
64 | } while (0) | ||
54 | 65 | ||
55 | 66 | ||
56 | /** | 67 | /** |
57 | * Clean up all resources used. | 68 | * Clean up all resources used. |
58 | */ | 69 | */ |
59 | static void | 70 | static void |
60 | cleanup () | 71 | cleanup (void *cls) |
61 | { | 72 | { |
73 | (void) cls; | ||
62 | if (NULL != op) | 74 | if (NULL != op) |
63 | { | 75 | { |
64 | GNUNET_IDENTITY_cancel (op); | 76 | GNUNET_IDENTITY_cancel (op); |
@@ -69,7 +81,6 @@ cleanup () | |||
69 | GNUNET_IDENTITY_disconnect (h); | 81 | GNUNET_IDENTITY_disconnect (h); |
70 | h = NULL; | 82 | h = NULL; |
71 | } | 83 | } |
72 | GNUNET_SCHEDULER_shutdown (); | ||
73 | } | 84 | } |
74 | 85 | ||
75 | 86 | ||
@@ -81,37 +92,23 @@ cleanup () | |||
81 | static void | 92 | static void |
82 | endbadly (void *cls) | 93 | endbadly (void *cls) |
83 | { | 94 | { |
84 | cleanup (); | 95 | GNUNET_SCHEDULER_shutdown (); |
85 | res = 1; | 96 | res = 1; |
86 | } | 97 | } |
87 | 98 | ||
88 | 99 | ||
89 | /** | 100 | /** |
90 | * Termiante the testcase (success). | 101 | * Termiante the testcase. |
91 | * | ||
92 | * @param cls NULL | ||
93 | */ | ||
94 | static void | ||
95 | end_normally (void *cls) | ||
96 | { | ||
97 | cleanup (); | ||
98 | res = 0; | ||
99 | } | ||
100 | |||
101 | |||
102 | /** | ||
103 | * Finish the testcase (successfully). | ||
104 | */ | 102 | */ |
105 | static void | 103 | static void |
106 | end () | 104 | end () |
107 | { | 105 | { |
108 | if (endbadly_task != NULL) | 106 | if (NULL != endbadly_task) |
109 | { | 107 | { |
110 | GNUNET_SCHEDULER_cancel (endbadly_task); | 108 | GNUNET_SCHEDULER_cancel (endbadly_task); |
111 | endbadly_task = NULL; | 109 | endbadly_task = NULL; |
112 | } | 110 | } |
113 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, | 111 | GNUNET_SCHEDULER_shutdown (); |
114 | &end_normally, NULL); | ||
115 | } | 112 | } |
116 | 113 | ||
117 | 114 | ||
@@ -122,11 +119,11 @@ end () | |||
122 | * @param emsg (should also be NULL) | 119 | * @param emsg (should also be NULL) |
123 | */ | 120 | */ |
124 | static void | 121 | static void |
125 | delete_cont (void *cls, | 122 | delete_cont (void *cls, const char *emsg) |
126 | const char *emsg) | ||
127 | { | 123 | { |
128 | op = NULL; | 124 | op = NULL; |
129 | GNUNET_assert (NULL == emsg); | 125 | CHECK (NULL == emsg); |
126 | res = 0; | ||
130 | end (); | 127 | end (); |
131 | } | 128 | } |
132 | 129 | ||
@@ -139,17 +136,15 @@ delete_cont (void *cls, | |||
139 | */ | 136 | */ |
140 | static void | 137 | static void |
141 | get_cb (void *cls, | 138 | get_cb (void *cls, |
142 | struct GNUNET_IDENTITY_Ego *ego, | 139 | struct GNUNET_IDENTITY_Ego *ego, |
143 | void **ctx, | 140 | void **ctx, |
144 | const char *identifier) | 141 | const char *identifier) |
145 | { | 142 | { |
146 | GNUNET_assert (NULL != ego); | 143 | op = NULL; |
147 | GNUNET_assert (NULL != identifier); | 144 | CHECK (NULL != ego); |
148 | GNUNET_assert (0 == strcmp (identifier, "test-id")); | 145 | CHECK (NULL != identifier); |
149 | op = GNUNET_IDENTITY_delete (h, | 146 | CHECK (0 == strcmp (identifier, "test-id")); |
150 | "test-id", | 147 | op = GNUNET_IDENTITY_delete (h, "test-id", &delete_cont, NULL); |
151 | &delete_cont, | ||
152 | NULL); | ||
153 | } | 148 | } |
154 | 149 | ||
155 | 150 | ||
@@ -162,17 +157,14 @@ get_cb (void *cls, | |||
162 | */ | 157 | */ |
163 | static void | 158 | static void |
164 | run_get (void *cls, | 159 | run_get (void *cls, |
165 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 160 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
166 | struct GNUNET_TESTING_Peer *peer) | 161 | struct GNUNET_TESTING_Peer *peer) |
167 | { | 162 | { |
168 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 163 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL); |
169 | &endbadly, NULL); | 164 | GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL); |
170 | h = GNUNET_IDENTITY_connect (cfg, NULL, NULL); | 165 | h = GNUNET_IDENTITY_connect (cfg, NULL, NULL); |
171 | GNUNET_assert (NULL != h); | 166 | CHECK (NULL != h); |
172 | op = GNUNET_IDENTITY_get (h, | 167 | op = GNUNET_IDENTITY_get (h, "test-service", &get_cb, NULL); |
173 | "test-service", | ||
174 | &get_cb, | ||
175 | NULL); | ||
176 | } | 168 | } |
177 | 169 | ||
178 | 170 | ||
@@ -183,11 +175,10 @@ run_get (void *cls, | |||
183 | * @param emsg (should also be NULL) | 175 | * @param emsg (should also be NULL) |
184 | */ | 176 | */ |
185 | static void | 177 | static void |
186 | success_set_cont (void *cls, | 178 | success_set_cont (void *cls, const char *emsg) |
187 | const char *emsg) | ||
188 | { | 179 | { |
189 | op = NULL; | 180 | op = NULL; |
190 | GNUNET_assert (NULL == emsg); | 181 | CHECK (NULL == emsg); |
191 | end (); | 182 | end (); |
192 | } | 183 | } |
193 | 184 | ||
@@ -205,19 +196,15 @@ success_set_cont (void *cls, | |||
205 | */ | 196 | */ |
206 | static void | 197 | static void |
207 | notification_cb (void *cls, | 198 | notification_cb (void *cls, |
208 | struct GNUNET_IDENTITY_Ego *ego, | 199 | struct GNUNET_IDENTITY_Ego *ego, |
209 | void **ctx, | 200 | void **ctx, |
210 | const char *identifier) | 201 | const char *identifier) |
211 | { | 202 | { |
212 | if (NULL == ego) | 203 | if (NULL == ego) |
213 | return; /* skip first call */ | 204 | return; /* skip first call */ |
214 | if (NULL == identifier) | 205 | if (NULL == identifier) |
215 | return; /* deletion / shutdown */ | 206 | return; /* deletion / shutdown */ |
216 | op = GNUNET_IDENTITY_set (h, | 207 | op = GNUNET_IDENTITY_set (h, "test-service", ego, &success_set_cont, NULL); |
217 | "test-service", | ||
218 | ego, | ||
219 | &success_set_cont, | ||
220 | NULL); | ||
221 | } | 208 | } |
222 | 209 | ||
223 | 210 | ||
@@ -230,11 +217,11 @@ notification_cb (void *cls, | |||
230 | */ | 217 | */ |
231 | static void | 218 | static void |
232 | create_cb (void *cls, | 219 | create_cb (void *cls, |
233 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, | 220 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, |
234 | const char *emsg) | 221 | const char *emsg) |
235 | { | 222 | { |
236 | GNUNET_assert (NULL == emsg); | 223 | CHECK (NULL == emsg); |
237 | GNUNET_assert (NULL != pk); | 224 | CHECK (NULL != pk); |
238 | op = NULL; | 225 | op = NULL; |
239 | } | 226 | } |
240 | 227 | ||
@@ -248,43 +235,37 @@ create_cb (void *cls, | |||
248 | */ | 235 | */ |
249 | static void | 236 | static void |
250 | run_set (void *cls, | 237 | run_set (void *cls, |
251 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 238 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
252 | struct GNUNET_TESTING_Peer *peer) | 239 | struct GNUNET_TESTING_Peer *peer) |
253 | { | 240 | { |
254 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 241 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL); |
255 | &endbadly, NULL); | 242 | GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL); |
256 | h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL); | 243 | h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL); |
257 | GNUNET_assert (NULL != h); | 244 | CHECK (NULL != h); |
258 | op = GNUNET_IDENTITY_create (h, | 245 | op = GNUNET_IDENTITY_create (h, "test-id", &create_cb, NULL); |
259 | "test-id", | ||
260 | &create_cb, | ||
261 | NULL); | ||
262 | |||
263 | } | 246 | } |
264 | 247 | ||
265 | 248 | ||
266 | int | 249 | int |
267 | main (int argc, char *argv[]) | 250 | main (int argc, char *argv[]) |
268 | { | 251 | { |
269 | GNUNET_DISK_directory_remove ("/tmp/test-identity-service"); | 252 | GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service"); |
270 | res = 1; | 253 | res = 1; |
271 | if (0 != | 254 | if (0 != GNUNET_TESTING_service_run ("test-identity-defaults", |
272 | GNUNET_TESTING_service_run ("test-identity-defaults", | 255 | "identity", |
273 | "identity", | 256 | "test_identity.conf", |
274 | "test_identity.conf", | 257 | &run_set, |
275 | &run_set, | 258 | NULL)) |
276 | NULL)) | ||
277 | return 1; | 259 | return 1; |
278 | if (0 != | 260 | if (0 != GNUNET_TESTING_service_run ("test-identity-defaults", |
279 | GNUNET_TESTING_service_run ("test-identity-defaults", | 261 | "identity", |
280 | "identity", | 262 | "test_identity.conf", |
281 | "test_identity.conf", | 263 | &run_get, |
282 | &run_get, | 264 | NULL)) |
283 | NULL)) | ||
284 | return 1; | 265 | return 1; |
285 | GNUNET_DISK_directory_remove ("/tmp/test-identity-service"); | 266 | GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service"); |
286 | return res; | 267 | return res; |
287 | } | 268 | } |
288 | 269 | ||
289 | 270 | ||
290 | /* end of test_identity.c */ | 271 | /* end of test_identity_defaults.c */ |