aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_pseudonym.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/test_pseudonym.c')
-rw-r--r--src/util/test_pseudonym.c30
1 files changed, 23 insertions, 7 deletions
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
40static int 40static int
41iter (void *cls, const GNUNET_HashCode * pseudonym, 41iter (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
55static int 56static int
56noti_callback (void *cls, const GNUNET_HashCode * pseudonym, 57noti_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
65static int 67static int
66fake_noti_callback (void *cls, const GNUNET_HashCode * pseudonym, 68fake_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
75static int 78static int
76false_callback (void *cls, const GNUNET_HashCode * pseudonym, 79false_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 */