diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/pseudonym.c | 201 | ||||
-rw-r--r-- | src/util/test_pseudonym.c | 30 |
2 files changed, 173 insertions, 58 deletions
diff --git a/src/util/pseudonym.c b/src/util/pseudonym.c index 782a405fc..dd8ad08b3 100644 --- a/src/util/pseudonym.c +++ b/src/util/pseudonym.c | |||
@@ -96,7 +96,7 @@ internal_notify (const GNUNET_HashCode * id, | |||
96 | pos = head; | 96 | pos = head; |
97 | while (pos != NULL) | 97 | while (pos != NULL) |
98 | { | 98 | { |
99 | pos->callback (pos->closure, id, md, rating); | 99 | pos->callback (pos->closure, id, NULL, NULL, md, rating); |
100 | pos = pos->next; | 100 | pos = pos->next; |
101 | } | 101 | } |
102 | } | 102 | } |
@@ -104,6 +104,9 @@ internal_notify (const GNUNET_HashCode * id, | |||
104 | /** | 104 | /** |
105 | * Register callback to be invoked whenever we discover | 105 | * Register callback to be invoked whenever we discover |
106 | * a new pseudonym. | 106 | * a new pseudonym. |
107 | * Will immediately call provided iterator callback for all | ||
108 | * already discovered pseudonyms. | ||
109 | * | ||
107 | * @param cfg configuration to use | 110 | * @param cfg configuration to use |
108 | * @param iterator iterator over pseudonym | 111 | * @param iterator iterator over pseudonym |
109 | * @param closure point to a closure | 112 | * @param closure point to a closure |
@@ -185,7 +188,7 @@ get_data_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
185 | * @param nsid hash code of a pseudonym | 188 | * @param nsid hash code of a pseudonym |
186 | * @param meta meta data to be written into a file | 189 | * @param meta meta data to be written into a file |
187 | * @param ranking ranking of a pseudonym | 190 | * @param ranking ranking of a pseudonym |
188 | * @param ns_name name of a pseudonym | 191 | * @param ns_name non-unique name of a pseudonym |
189 | */ | 192 | */ |
190 | static void | 193 | static void |
191 | write_pseudonym_info (const struct GNUNET_CONFIGURATION_Handle *cfg, | 194 | write_pseudonym_info (const struct GNUNET_CONFIGURATION_Handle *cfg, |
@@ -219,9 +222,9 @@ write_pseudonym_info (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
219 | } | 222 | } |
220 | GNUNET_free (fn); | 223 | GNUNET_free (fn); |
221 | /* create entry for pseudonym name in names */ | 224 | /* create entry for pseudonym name in names */ |
222 | /* FIXME: 90% of what this call does is not needed | 225 | if (ns_name != NULL) |
223 | * here => refactor code to only create the entry! */ | 226 | GNUNET_free_non_null (GNUNET_PSEUDONYM_name_uniquify (cfg, nsid, ns_name, |
224 | GNUNET_free_non_null (GNUNET_PSEUDONYM_id_to_name (cfg, nsid)); | 227 | NULL)); |
225 | } | 228 | } |
226 | 229 | ||
227 | 230 | ||
@@ -285,57 +288,31 @@ read_info (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
285 | return GNUNET_OK; | 288 | return GNUNET_OK; |
286 | } | 289 | } |
287 | 290 | ||
288 | |||
289 | |||
290 | /** | 291 | /** |
291 | * Return the unique, human readable name for the given namespace. | 292 | * Return unique variant of the namespace name. |
293 | * Use it after GNUNET_PSEUDONYM_get_info() to make sure | ||
294 | * that name is unique. | ||
292 | * | 295 | * |
293 | * @param cfg configuration | 296 | * @param cfg configuration |
294 | * @param nsid cryptographic ID of the namespace | 297 | * @param nsid cryptographic ID of the namespace |
295 | * @return NULL on failure (should never happen) | 298 | * @param name name to uniquify |
299 | * @param suffix if not NULL, filled with the suffix value | ||
300 | * @return NULL on failure (should never happen), name on success. | ||
301 | * Free the name with GNUNET_free(). | ||
296 | */ | 302 | */ |
297 | char * | 303 | char * |
298 | GNUNET_PSEUDONYM_id_to_name (const struct GNUNET_CONFIGURATION_Handle *cfg, | 304 | GNUNET_PSEUDONYM_name_uniquify (const struct GNUNET_CONFIGURATION_Handle *cfg, |
299 | const GNUNET_HashCode * nsid) | 305 | const GNUNET_HashCode * nsid, const char *name, unsigned int *suffix) |
300 | { | 306 | { |
301 | struct GNUNET_CONTAINER_MetaData *meta; | ||
302 | char *name; | ||
303 | GNUNET_HashCode nh; | 307 | GNUNET_HashCode nh; |
304 | char *fn; | ||
305 | uint64_t len; | 308 | uint64_t len; |
309 | char *fn; | ||
306 | struct GNUNET_DISK_FileHandle *fh; | 310 | struct GNUNET_DISK_FileHandle *fh; |
307 | unsigned int i; | 311 | unsigned int i; |
308 | unsigned int idx; | 312 | unsigned int idx; |
309 | char *ret; | 313 | char *ret; |
310 | struct stat sbuf; | 314 | struct stat sbuf; |
311 | int32_t temp = 0; | ||
312 | int32_t *rank = &temp; | ||
313 | 315 | ||
314 | meta = NULL; | ||
315 | name = NULL; | ||
316 | if (GNUNET_OK == read_info (cfg, nsid, &meta, rank, &name)) | ||
317 | { | ||
318 | if ((meta != NULL) && (name == NULL)) | ||
319 | name = | ||
320 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | ||
321 | EXTRACTOR_METATYPE_TITLE, | ||
322 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | ||
323 | EXTRACTOR_METATYPE_FILENAME, | ||
324 | EXTRACTOR_METATYPE_DESCRIPTION, | ||
325 | EXTRACTOR_METATYPE_SUBJECT, | ||
326 | EXTRACTOR_METATYPE_PUBLISHER, | ||
327 | EXTRACTOR_METATYPE_AUTHOR_NAME, | ||
328 | EXTRACTOR_METATYPE_COMMENT, | ||
329 | EXTRACTOR_METATYPE_SUMMARY, | ||
330 | -1); | ||
331 | if (meta != NULL) | ||
332 | { | ||
333 | GNUNET_CONTAINER_meta_data_destroy (meta); | ||
334 | meta = NULL; | ||
335 | } | ||
336 | } | ||
337 | if (name == NULL) | ||
338 | name = GNUNET_strdup (_("no-name")); | ||
339 | GNUNET_CRYPTO_hash (name, strlen (name), &nh); | 316 | GNUNET_CRYPTO_hash (name, strlen (name), &nh); |
340 | fn = get_data_filename (cfg, PS_NAMES_DIR, &nh); | 317 | fn = get_data_filename (cfg, PS_NAMES_DIR, &nh); |
341 | GNUNET_assert (fn != NULL); | 318 | GNUNET_assert (fn != NULL); |
@@ -372,22 +349,107 @@ GNUNET_PSEUDONYM_id_to_name (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
372 | GNUNET_DISK_file_close (fh); | 349 | GNUNET_DISK_file_close (fh); |
373 | ret = GNUNET_malloc (strlen (name) + 32); | 350 | ret = GNUNET_malloc (strlen (name) + 32); |
374 | GNUNET_snprintf (ret, strlen (name) + 32, "%s-%u", name, idx); | 351 | GNUNET_snprintf (ret, strlen (name) + 32, "%s-%u", name, idx); |
375 | GNUNET_free (name); | 352 | if (suffix != NULL) |
353 | *suffix = idx; | ||
376 | GNUNET_free (fn); | 354 | GNUNET_free (fn); |
377 | return ret; | 355 | return ret; |
378 | } | 356 | } |
379 | 357 | ||
380 | /** | 358 | /** |
359 | * Get namespace name, metadata and rank | ||
360 | * This is a wrapper around internal read_info() call, and ensures that | ||
361 | * returned data is not invalid (not NULL). | ||
362 | * | ||
363 | * @param cfg configuration | ||
364 | * @param nsid cryptographic ID of the namespace | ||
365 | * @param ret_meta a location to store metadata pointer. NULL, if metadata | ||
366 | * is not needed. Destroy with GNUNET_CONTAINER_meta_data_destroy(). | ||
367 | * @param ret_rank a location to store rank. NULL, if rank not needed. | ||
368 | * @param ret_name a location to store human-readable name. Name is not unique. | ||
369 | * NULL, if name is not needed. Free with GNUNET_free(). | ||
370 | * @param name_is_a_dup is set to GNUNET_YES, if ret_name was filled with | ||
371 | * a duplicate of a "no-name" placeholder | ||
372 | * @return GNUNET_OK on success. GNUENT_SYSERR if the data was | ||
373 | * unobtainable (in that case ret_* are filled with placeholders - | ||
374 | * empty metadata container, rank -1 and a "no-name" name). | ||
375 | */ | ||
376 | int | ||
377 | GNUNET_PSEUDONYM_get_info (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
378 | const GNUNET_HashCode * nsid, struct GNUNET_CONTAINER_MetaData **ret_meta, | ||
379 | int32_t *ret_rank, char **ret_name, int *name_is_a_dup) | ||
380 | { | ||
381 | struct GNUNET_CONTAINER_MetaData *meta; | ||
382 | char *name; | ||
383 | int32_t rank = -1; | ||
384 | |||
385 | meta = NULL; | ||
386 | name = NULL; | ||
387 | if (GNUNET_OK == read_info (cfg, nsid, &meta, &rank, &name)) | ||
388 | { | ||
389 | if ((meta != NULL) && (name == NULL)) | ||
390 | name = | ||
391 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | ||
392 | EXTRACTOR_METATYPE_TITLE, | ||
393 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | ||
394 | EXTRACTOR_METATYPE_FILENAME, | ||
395 | EXTRACTOR_METATYPE_DESCRIPTION, | ||
396 | EXTRACTOR_METATYPE_SUBJECT, | ||
397 | EXTRACTOR_METATYPE_PUBLISHER, | ||
398 | EXTRACTOR_METATYPE_AUTHOR_NAME, | ||
399 | EXTRACTOR_METATYPE_COMMENT, | ||
400 | EXTRACTOR_METATYPE_SUMMARY, | ||
401 | -1); | ||
402 | if (ret_name != NULL) | ||
403 | { | ||
404 | if (name == NULL) | ||
405 | { | ||
406 | name = GNUNET_strdup (_("no-name")); | ||
407 | if (name_is_a_dup != NULL) | ||
408 | *name_is_a_dup = GNUNET_YES; | ||
409 | } | ||
410 | else if (name_is_a_dup != NULL) | ||
411 | *name_is_a_dup = GNUNET_NO; | ||
412 | *ret_name = name; | ||
413 | } | ||
414 | else if (name != NULL) | ||
415 | GNUNET_free (name); | ||
416 | |||
417 | if (ret_meta != NULL) | ||
418 | { | ||
419 | if (meta == NULL) | ||
420 | meta = GNUNET_CONTAINER_meta_data_create (); | ||
421 | *ret_meta = meta; | ||
422 | } | ||
423 | else if (meta != NULL) | ||
424 | GNUNET_CONTAINER_meta_data_destroy (meta); | ||
425 | |||
426 | if (ret_rank != NULL) | ||
427 | *ret_rank = rank; | ||
428 | |||
429 | return GNUNET_OK; | ||
430 | } | ||
431 | if (ret_name != NULL) | ||
432 | *ret_name = GNUNET_strdup (_("no-name")); | ||
433 | if (ret_meta != NULL) | ||
434 | *ret_meta = GNUNET_CONTAINER_meta_data_create (); | ||
435 | if (ret_rank != NULL) | ||
436 | *ret_rank = -1; | ||
437 | if (name_is_a_dup != NULL) | ||
438 | *name_is_a_dup = GNUNET_YES; | ||
439 | return GNUNET_SYSERR; | ||
440 | } | ||
441 | |||
442 | /** | ||
381 | * Get the namespace ID belonging to the given namespace name. | 443 | * Get the namespace ID belonging to the given namespace name. |
382 | * | 444 | * |
383 | * @param cfg configuration to use | 445 | * @param cfg configuration to use |
384 | * @param ns_uname human-readable name for the namespace | 446 | * @param ns_uname unique (!) human-readable name for the namespace |
385 | * @param nsid set to namespace ID based on 'ns_uname' | 447 | * @param nsid set to namespace ID based on 'ns_uname' |
386 | * @return GNUNET_OK on success | 448 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
387 | */ | 449 | */ |
388 | int | 450 | int |
389 | GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, | 451 | GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, |
390 | const char *ns_uname, GNUNET_HashCode * nsid) | 452 | const char *ns_uname, GNUNET_HashCode * nsid) |
391 | { | 453 | { |
392 | size_t slen; | 454 | size_t slen; |
393 | uint64_t len; | 455 | uint64_t len; |
@@ -405,6 +467,7 @@ GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
405 | return GNUNET_SYSERR; | 467 | return GNUNET_SYSERR; |
406 | name = GNUNET_strdup (ns_uname); | 468 | name = GNUNET_strdup (ns_uname); |
407 | name[slen - 1] = '\0'; | 469 | name[slen - 1] = '\0'; |
470 | |||
408 | GNUNET_CRYPTO_hash (name, strlen (name), &nh); | 471 | GNUNET_CRYPTO_hash (name, strlen (name), &nh); |
409 | GNUNET_free (name); | 472 | GNUNET_free (name); |
410 | fn = get_data_filename (cfg, PS_NAMES_DIR, &nh); | 473 | fn = get_data_filename (cfg, PS_NAMES_DIR, &nh); |
@@ -472,10 +535,10 @@ list_pseudonym_helper (void *cls, const char *fullname) | |||
472 | struct ListPseudonymClosure *c = cls; | 535 | struct ListPseudonymClosure *c = cls; |
473 | int ret; | 536 | int ret; |
474 | GNUNET_HashCode id; | 537 | GNUNET_HashCode id; |
475 | int rating; | 538 | int32_t rating; |
476 | struct GNUNET_CONTAINER_MetaData *meta; | 539 | struct GNUNET_CONTAINER_MetaData *meta; |
477 | const char *fn; | 540 | const char *fn; |
478 | char *str; | 541 | char *str, *name_unique; |
479 | 542 | ||
480 | if (strlen (fullname) < sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) | 543 | if (strlen (fullname) < sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) |
481 | return GNUNET_OK; | 544 | return GNUNET_OK; |
@@ -487,11 +550,22 @@ list_pseudonym_helper (void *cls, const char *fullname) | |||
487 | if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (fn, &id)) | 550 | if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (fn, &id)) |
488 | return GNUNET_OK; /* invalid name */ | 551 | return GNUNET_OK; /* invalid name */ |
489 | str = NULL; | 552 | str = NULL; |
490 | if (GNUNET_OK != read_info (c->cfg, &id, &meta, &rating, &str)) | 553 | if (GNUNET_OK != GNUNET_PSEUDONYM_get_info (c->cfg, &id, &meta, &rating, |
491 | return GNUNET_OK; /* ignore entry */ | 554 | &str, NULL)) |
492 | GNUNET_free_non_null (str); | 555 | { |
556 | /* ignore entry. FIXME: Why? Lack of data about a pseudonym is not a reason | ||
557 | * to ignore it... So yeah, it will have placeholders instead of name, | ||
558 | * empty metadata container and a default rank == -1, so what? We know | ||
559 | * its nsid - that's all we really need. Right? */ | ||
560 | GNUNET_free (str); | ||
561 | GNUNET_CONTAINER_meta_data_destroy (meta); | ||
562 | return GNUNET_OK; | ||
563 | } | ||
564 | name_unique = GNUNET_PSEUDONYM_name_uniquify (c->cfg, &id, str, NULL); | ||
493 | if (c->iterator != NULL) | 565 | if (c->iterator != NULL) |
494 | ret = c->iterator (c->closure, &id, meta, rating); | 566 | ret = c->iterator (c->closure, &id, str, name_unique, meta, rating); |
567 | GNUNET_free_non_null (str); | ||
568 | GNUNET_free_non_null (name_unique); | ||
495 | GNUNET_CONTAINER_meta_data_destroy (meta); | 569 | GNUNET_CONTAINER_meta_data_destroy (meta); |
496 | return ret; | 570 | return ret; |
497 | } | 571 | } |
@@ -559,6 +633,31 @@ GNUNET_PSEUDONYM_rank (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
559 | 633 | ||
560 | 634 | ||
561 | /** | 635 | /** |
636 | * Set the pseudonym metadata, rank and name. | ||
637 | * | ||
638 | * @param cfg overall configuration | ||
639 | * @param nsid id of the pseudonym | ||
640 | * @param name name to set. Must be the non-unique version of it. | ||
641 | * May be NULL, in which case it erases pseudonym's name! | ||
642 | * @param md metadata to set | ||
643 | * May be NULL, in which case it erases pseudonym's metadata! | ||
644 | * @param rank rank to assign | ||
645 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | ||
646 | */ | ||
647 | int | ||
648 | GNUNET_PSEUDONYM_set_info (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
649 | const GNUNET_HashCode * nsid, const char *name, | ||
650 | const struct GNUNET_CONTAINER_MetaData *md, int rank) | ||
651 | { | ||
652 | GNUNET_assert (cfg != NULL); | ||
653 | GNUNET_assert (nsid != NULL); | ||
654 | |||
655 | write_pseudonym_info (cfg, nsid, md, rank, name); | ||
656 | return GNUNET_OK; | ||
657 | } | ||
658 | |||
659 | |||
660 | /** | ||
562 | * Add a pseudonym to the set of known pseudonyms. | 661 | * Add a pseudonym to the set of known pseudonyms. |
563 | * For all pseudonym advertisements that we discover | 662 | * For all pseudonym advertisements that we discover |
564 | * FS should automatically call this function. | 663 | * FS should automatically call this function. |
diff --git a/src/util/test_pseudonym.c b/src/util/test_pseudonym.c index 20a3d3d96..4ce8b3853 100644 --- a/src/util/test_pseudonym.c +++ b/src/util/test_pseudonym.c | |||
@@ -39,6 +39,7 @@ static GNUNET_HashCode id1; | |||
39 | 39 | ||
40 | static int | 40 | static int |
41 | iter (void *cls, const GNUNET_HashCode * pseudonym, | 41 | iter (void *cls, const GNUNET_HashCode * pseudonym, |
42 | const char *name, const char *unique_name, | ||
42 | const struct GNUNET_CONTAINER_MetaData *md, int rating) | 43 | const struct GNUNET_CONTAINER_MetaData *md, int rating) |
43 | { | 44 | { |
44 | int *ok = cls; | 45 | int *ok = cls; |
@@ -54,6 +55,7 @@ iter (void *cls, const GNUNET_HashCode * pseudonym, | |||
54 | 55 | ||
55 | static int | 56 | static int |
56 | noti_callback (void *cls, const GNUNET_HashCode * pseudonym, | 57 | noti_callback (void *cls, const GNUNET_HashCode * pseudonym, |
58 | const char *name, const char *unique_name, | ||
57 | const struct GNUNET_CONTAINER_MetaData *md, int rating) | 59 | const struct GNUNET_CONTAINER_MetaData *md, int rating) |
58 | { | 60 | { |
59 | int *ret = cls; | 61 | int *ret = cls; |
@@ -64,6 +66,7 @@ noti_callback (void *cls, const GNUNET_HashCode * pseudonym, | |||
64 | 66 | ||
65 | static int | 67 | static int |
66 | fake_noti_callback (void *cls, const GNUNET_HashCode * pseudonym, | 68 | fake_noti_callback (void *cls, const GNUNET_HashCode * pseudonym, |
69 | const char *name, const char *unique_name, | ||
67 | const struct GNUNET_CONTAINER_MetaData *md, int rating) | 70 | const struct GNUNET_CONTAINER_MetaData *md, int rating) |
68 | { | 71 | { |
69 | int *ret = cls; | 72 | int *ret = cls; |
@@ -74,6 +77,7 @@ fake_noti_callback (void *cls, const GNUNET_HashCode * pseudonym, | |||
74 | 77 | ||
75 | static int | 78 | static int |
76 | false_callback (void *cls, const GNUNET_HashCode * pseudonym, | 79 | false_callback (void *cls, const GNUNET_HashCode * pseudonym, |
80 | const char *name, const char *unique_name, | ||
77 | const struct GNUNET_CONTAINER_MetaData *md, int rating) | 81 | const struct GNUNET_CONTAINER_MetaData *md, int rating) |
78 | { | 82 | { |
79 | return GNUNET_OK; | 83 | return GNUNET_OK; |
@@ -95,7 +99,10 @@ main (int argc, char *argv[]) | |||
95 | char *name1; | 99 | char *name1; |
96 | char *name2; | 100 | char *name2; |
97 | char *name3; | 101 | char *name3; |
102 | char *name1_unique; | ||
103 | char *name2_unique; | ||
98 | char *noname; | 104 | char *noname; |
105 | int noname_is_a_dup; | ||
99 | int notiCount, fakenotiCount; | 106 | int notiCount, fakenotiCount; |
100 | int count; | 107 | int count; |
101 | static char m[1024 * 1024 * 10]; | 108 | static char m[1024 * 1024 * 10]; |
@@ -152,15 +159,21 @@ main (int argc, char *argv[]) | |||
152 | strlen (m) + 1)); | 159 | strlen (m) + 1)); |
153 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id3); | 160 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id3); |
154 | GNUNET_PSEUDONYM_add (cfg, &id3, meta); | 161 | GNUNET_PSEUDONYM_add (cfg, &id3, meta); |
155 | name3 = GNUNET_PSEUDONYM_id_to_name (cfg, &id3); | 162 | GNUNET_PSEUDONYM_get_info (cfg, &id3, NULL, NULL, &name3, NULL); |
156 | name2 = GNUNET_PSEUDONYM_id_to_name (cfg, &id2); | 163 | CHECK (name3 != NULL); |
164 | GNUNET_PSEUDONYM_get_info (cfg, &id2, NULL, NULL, &name2, NULL); | ||
157 | CHECK (name2 != NULL); | 165 | CHECK (name2 != NULL); |
158 | name1 = GNUNET_PSEUDONYM_id_to_name (cfg, &id1); | 166 | GNUNET_PSEUDONYM_get_info (cfg, &id1, NULL, NULL, &name1, NULL); |
159 | CHECK (name1 != NULL); | 167 | CHECK (name1 != NULL); |
160 | CHECK (0 != strcmp (name1, name2)); | 168 | CHECK (0 == strcmp (name1, name2)); |
169 | name1_unique = GNUNET_PSEUDONYM_name_uniquify (cfg, &id1, name1, NULL); | ||
170 | name2_unique = GNUNET_PSEUDONYM_name_uniquify (cfg, &id2, name2, NULL); | ||
171 | CHECK (0 != strcmp (name1_unique, name2_unique)); | ||
161 | CHECK (GNUNET_SYSERR == GNUNET_PSEUDONYM_name_to_id (cfg, "fake", &rid2)); | 172 | CHECK (GNUNET_SYSERR == GNUNET_PSEUDONYM_name_to_id (cfg, "fake", &rid2)); |
162 | CHECK (GNUNET_OK == GNUNET_PSEUDONYM_name_to_id (cfg, name2, &rid2)); | 173 | CHECK (GNUNET_SYSERR == GNUNET_PSEUDONYM_name_to_id (cfg, name2, &rid2)); |
163 | CHECK (GNUNET_OK == GNUNET_PSEUDONYM_name_to_id (cfg, name1, &rid1)); | 174 | CHECK (GNUNET_SYSERR == GNUNET_PSEUDONYM_name_to_id (cfg, name1, &rid1)); |
175 | CHECK (GNUNET_OK == GNUNET_PSEUDONYM_name_to_id (cfg, name2_unique, &rid2)); | ||
176 | CHECK (GNUNET_OK == GNUNET_PSEUDONYM_name_to_id (cfg, name1_unique, &rid1)); | ||
164 | CHECK (0 == memcmp (&id1, &rid1, sizeof (GNUNET_HashCode))); | 177 | CHECK (0 == memcmp (&id1, &rid1, sizeof (GNUNET_HashCode))); |
165 | CHECK (0 == memcmp (&id2, &rid2, sizeof (GNUNET_HashCode))); | 178 | CHECK (0 == memcmp (&id2, &rid2, sizeof (GNUNET_HashCode))); |
166 | 179 | ||
@@ -168,14 +181,17 @@ main (int argc, char *argv[]) | |||
168 | GNUNET_log_skip (1, GNUNET_NO); | 181 | GNUNET_log_skip (1, GNUNET_NO); |
169 | CHECK (0 == GNUNET_PSEUDONYM_rank (cfg, &fid, 0)); | 182 | CHECK (0 == GNUNET_PSEUDONYM_rank (cfg, &fid, 0)); |
170 | GNUNET_log_skip (0, GNUNET_YES); | 183 | GNUNET_log_skip (0, GNUNET_YES); |
171 | noname = GNUNET_PSEUDONYM_id_to_name (cfg, &fid); | 184 | CHECK (GNUNET_OK == GNUNET_PSEUDONYM_get_info (cfg, &fid, NULL, NULL, &noname, &noname_is_a_dup)); |
172 | CHECK (noname != NULL); | 185 | CHECK (noname != NULL); |
186 | CHECK (noname_is_a_dup == GNUNET_YES); | ||
173 | CHECK (0 == GNUNET_PSEUDONYM_rank (cfg, &id1, 0)); | 187 | CHECK (0 == GNUNET_PSEUDONYM_rank (cfg, &id1, 0)); |
174 | CHECK (5 == GNUNET_PSEUDONYM_rank (cfg, &id1, 5)); | 188 | CHECK (5 == GNUNET_PSEUDONYM_rank (cfg, &id1, 5)); |
175 | CHECK (-5 == GNUNET_PSEUDONYM_rank (cfg, &id1, -10)); | 189 | CHECK (-5 == GNUNET_PSEUDONYM_rank (cfg, &id1, -10)); |
176 | CHECK (0 == GNUNET_PSEUDONYM_rank (cfg, &id1, 5)); | 190 | CHECK (0 == GNUNET_PSEUDONYM_rank (cfg, &id1, 5)); |
177 | GNUNET_free (name1); | 191 | GNUNET_free (name1); |
178 | GNUNET_free (name2); | 192 | GNUNET_free (name2); |
193 | GNUNET_free (name1_unique); | ||
194 | GNUNET_free (name2_unique); | ||
179 | GNUNET_free (name3); | 195 | GNUNET_free (name3); |
180 | GNUNET_free (noname); | 196 | GNUNET_free (noname); |
181 | /* END OF TEST CODE */ | 197 | /* END OF TEST CODE */ |