aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_namestore_api_zone_iteration.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/namestore/test_namestore_api_zone_iteration.c')
-rw-r--r--src/namestore/test_namestore_api_zone_iteration.c162
1 files changed, 82 insertions, 80 deletions
diff --git a/src/namestore/test_namestore_api_zone_iteration.c b/src/namestore/test_namestore_api_zone_iteration.c
index 92fb43a28..f7e4fe489 100644
--- a/src/namestore/test_namestore_api_zone_iteration.c
+++ b/src/namestore/test_namestore_api_zone_iteration.c
@@ -66,16 +66,16 @@ static struct GNUNET_GNSRECORD_Data *s_rd_3;
66static void 66static void
67endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 67endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
68{ 68{
69 if (NULL != zi) 69 if (NULL != zi)
70 { 70 {
71 GNUNET_NAMESTORE_zone_iteration_stop (zi); 71 GNUNET_NAMESTORE_zone_iteration_stop (zi);
72 zi = NULL; 72 zi = NULL;
73 } 73 }
74
75 if (nsh != NULL) 74 if (nsh != NULL)
75 {
76 GNUNET_NAMESTORE_disconnect (nsh); 76 GNUNET_NAMESTORE_disconnect (nsh);
77 nsh = NULL; 77 nsh = NULL;
78 78 }
79 GNUNET_free_non_null(s_name_1); 79 GNUNET_free_non_null(s_name_1);
80 GNUNET_free_non_null(s_name_2); 80 GNUNET_free_non_null(s_name_2);
81 GNUNET_free_non_null(s_name_3); 81 GNUNET_free_non_null(s_name_3);
@@ -110,12 +110,11 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
110static void 110static void
111end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 111end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
112{ 112{
113 if (NULL != zi) 113 if (NULL != zi)
114 { 114 {
115 GNUNET_NAMESTORE_zone_iteration_stop (zi); 115 GNUNET_NAMESTORE_zone_iteration_stop (zi);
116 zi = NULL; 116 zi = NULL;
117 } 117 }
118
119 if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) 118 if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
120 { 119 {
121 GNUNET_SCHEDULER_cancel (endbadly_task); 120 GNUNET_SCHEDULER_cancel (endbadly_task);
@@ -156,12 +155,13 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
156 155
157static void 156static void
158zone_proc (void *cls, 157zone_proc (void *cls,
159 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 158 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
160 const char *label, 159 const char *label,
161 unsigned int rd_count, 160 unsigned int rd_count,
162 const struct GNUNET_GNSRECORD_Data *rd) 161 const struct GNUNET_GNSRECORD_Data *rd)
163{ 162{
164 int failed = GNUNET_NO; 163 int failed = GNUNET_NO;
164
165 if ((zone == NULL) && (label == NULL)) 165 if ((zone == NULL) && (label == NULL))
166 { 166 {
167 GNUNET_break (3 == returned_records); 167 GNUNET_break (3 == returned_records);
@@ -175,90 +175,88 @@ zone_proc (void *cls,
175 175
176 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 176 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
177 "Received last result, iteration done after receing %u results\n", 177 "Received last result, iteration done after receing %u results\n",
178 returned_records ); 178 returned_records);
179 GNUNET_SCHEDULER_add_now (&end, NULL); 179 GNUNET_SCHEDULER_add_now (&end, NULL);
180 return; 180 return;
181 } 181 }
182 else 182 if (0 == memcmp (zone, privkey, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
183 { 183 {
184 if (0 == memcmp (zone, privkey, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) 184 if (0 == strcmp (label, s_name_1))
185 { 185 {
186 if (0 == strcmp (label, s_name_1)) 186 if (rd_count == 1)
187 { 187 {
188 if (rd_count == 1) 188 if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_1))
189 {
190 if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_1))
191 {
192 failed = GNUNET_YES;
193 GNUNET_break (0);
194 }
195 }
196 else
197 { 189 {
198 failed = GNUNET_YES; 190 failed = GNUNET_YES;
199 GNUNET_break (0); 191 GNUNET_break (0);
200 } 192 }
201 } 193 }
202 else if (0 == strcmp (label, s_name_2)) 194 else
203 { 195 {
204 if (rd_count == 1) 196 failed = GNUNET_YES;
205 { 197 GNUNET_break (0);
206 if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_2)) 198 }
207 { 199 }
208 failed = GNUNET_YES; 200 else if (0 == strcmp (label, s_name_2))
209 GNUNET_break (0); 201 {
210 } 202 if (rd_count == 1)
211 } 203 {
212 else 204 if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_2))
213 { 205 {
214 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
215 "Received invalid record count\n");
216 failed = GNUNET_YES; 206 failed = GNUNET_YES;
217 GNUNET_break (0); 207 GNUNET_break (0);
218 } 208 }
219 } 209 }
220 else 210 else
221 { 211 {
222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 212 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
223 "Comparing result failed: got name `%s' for first zone\n", label); 213 "Received invalid record count\n");
224 failed = GNUNET_YES; 214 failed = GNUNET_YES;
225 GNUNET_break (0); 215 GNUNET_break (0);
226 } 216 }
227 } 217 }
228 else if (0 == memcmp (zone, privkey2, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) 218 else
229 { 219 {
230 if (0 == strcmp (label, s_name_3)) 220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
221 "Comparing result failed: got name `%s' for first zone\n", label);
222 failed = GNUNET_YES;
223 GNUNET_break (0);
224 }
225 }
226 else if (0 == memcmp (zone, privkey2, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
227 {
228 if (0 == strcmp (label, s_name_3))
229 {
230 if (rd_count == 1)
231 { 231 {
232 if (rd_count == 1) 232 if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_3))
233 { 233 {
234 if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_3))
235 {
236 failed = GNUNET_YES;
237 GNUNET_break (0);
238 }
239 }
240 else
241 {
242 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
243 "Received invalid record count\n");
244 failed = GNUNET_YES; 234 failed = GNUNET_YES;
245 GNUNET_break (0); 235 GNUNET_break (0);
246 } 236 }
247 } 237 }
248 else 238 else
249 { 239 {
250 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 240 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
251 "Comparing result failed: got name `%s' for first zone\n", label); 241 "Received invalid record count\n");
252 failed = GNUNET_YES; 242 failed = GNUNET_YES;
253 GNUNET_break (0); 243 GNUNET_break (0);
254 } 244 }
255 } 245 }
256 else 246 else
257 { 247 {
258 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Received invalid zone\n"); 248 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
249 "Comparing result failed: got name `%s' for first zone\n", label);
259 failed = GNUNET_YES; 250 failed = GNUNET_YES;
260 GNUNET_break (0); 251 GNUNET_break (0);
261 } 252 }
253 }
254 else
255 {
256 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
257 "Received invalid zone\n");
258 failed = GNUNET_YES;
259 GNUNET_break (0);
262 } 260 }
263 261
264 if (failed == GNUNET_NO) 262 if (failed == GNUNET_NO)
@@ -302,10 +300,10 @@ put_cont (void *cls, int32_t success, const char *emsg)
302 res = 1; 300 res = 1;
303 returned_records = 0; 301 returned_records = 0;
304 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n"); 302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n");
305 zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, 303 zi = GNUNET_NAMESTORE_zone_iteration_start (nsh,
306 NULL, 304 NULL,
307 &zone_proc, 305 &zone_proc,
308 NULL); 306 NULL);
309 if (zi == NULL) 307 if (zi == NULL)
310 { 308 {
311 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); 309 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n");
@@ -394,22 +392,26 @@ empty_zone_proc (void *cls,
394 392
395 GNUNET_asprintf(&s_name_1, "dummy1"); 393 GNUNET_asprintf(&s_name_1, "dummy1");
396 s_rd_1 = create_record(1); 394 s_rd_1 = create_record(1);
397 GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, 395 GNUNET_NAMESTORE_records_store (nsh, privkey, s_name_1,
398 1, s_rd_1, &put_cont, NULL); 396 1, s_rd_1,
397 &put_cont, NULL);
399 398
400 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); 399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
400 "Created record 2 \n");
401 GNUNET_asprintf(&s_name_2, "dummy2"); 401 GNUNET_asprintf(&s_name_2, "dummy2");
402 s_rd_2 = create_record(1); 402 s_rd_2 = create_record(1);
403 GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_2, 403 GNUNET_NAMESTORE_records_store (nsh, privkey, s_name_2,
404 1, s_rd_2, &put_cont, NULL); 404 1, s_rd_2, &put_cont, NULL);
405 405
406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n"); 406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
407 "Created record 3\n");
407 408
408 /* name in different zone */ 409 /* name in different zone */
409 GNUNET_asprintf(&s_name_3, "dummy3"); 410 GNUNET_asprintf(&s_name_3, "dummy3");
410 s_rd_3 = create_record(1); 411 s_rd_3 = create_record(1);
411 GNUNET_NAMESTORE_records_store(nsh, privkey2, s_name_3, 412 GNUNET_NAMESTORE_records_store (nsh, privkey2, s_name_3,
412 1, s_rd_3, &put_cont, NULL); 413 1, s_rd_3,
414 &put_cont, NULL);
413} 415}
414 416
415 417