aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/namestore/gnunet-service-namestore.c20
-rw-r--r--src/namestore/test_namestore_api_monitoring_existing.c104
2 files changed, 56 insertions, 68 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 101f2bd45..2286abecc 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -922,7 +922,7 @@ continue_store_activity (struct StoreActivity *sa)
922 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) ) 922 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) )
923 { 923 {
924 sa->zm_pos = zm->next; /* not interesting to this monitor */ 924 sa->zm_pos = zm->next; /* not interesting to this monitor */
925 // continue; -- fails tests, but why not here? 925 continue; // -- fails tests, but why not here?
926 } 926 }
927 if (zm->limit == zm->iteration_cnt) 927 if (zm->limit == zm->iteration_cnt)
928 { 928 {
@@ -1980,23 +1980,9 @@ monitor_iterate_cb (void *cls,
1980{ 1980{
1981 struct ZoneMonitor *zm = cls; 1981 struct ZoneMonitor *zm = cls;
1982 1982
1983 if ( (0 != memcmp (&zone_key,
1984 &zm->zone,
1985 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) &&
1986 (0 != memcmp (&zm->zone,
1987 &zero,
1988 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) )
1989 {
1990 GNUNET_break (0);
1991 return;
1992 }
1993 zm->seq = seq; 1983 zm->seq = seq;
1994 if (NULL == name) 1984 GNUNET_assert (NULL != name);
1995 { 1985 GNUNET_assert (zone_key == &zm->zone);
1996 /* finished with iteration */
1997 monitor_sync (zm);
1998 return;
1999 }
2000 GNUNET_STATISTICS_update (statistics, 1986 GNUNET_STATISTICS_update (statistics,
2001 "Monitor notifications sent", 1987 "Monitor notifications sent",
2002 1, 1988 1,
diff --git a/src/namestore/test_namestore_api_monitoring_existing.c b/src/namestore/test_namestore_api_monitoring_existing.c
index 9c8ddf7ad..867f18b27 100644
--- a/src/namestore/test_namestore_api_monitoring_existing.c
+++ b/src/namestore/test_namestore_api_monitoring_existing.c
@@ -44,15 +44,15 @@ static struct GNUNET_NAMESTORE_ZoneMonitor *zm;
44 44
45static int res; 45static int res;
46 46
47static char * s_name_1; 47static const char * s_name_1;
48 48
49static struct GNUNET_GNSRECORD_Data *s_rd_1; 49static struct GNUNET_GNSRECORD_Data *s_rd_1;
50 50
51static char * s_name_2; 51static const char * s_name_2;
52 52
53static struct GNUNET_GNSRECORD_Data *s_rd_2; 53static struct GNUNET_GNSRECORD_Data *s_rd_2;
54 54
55static char * s_name_3; 55static const char * s_name_3;
56 56
57static struct GNUNET_GNSRECORD_Data *s_rd_3; 57static struct GNUNET_GNSRECORD_Data *s_rd_3;
58 58
@@ -107,27 +107,21 @@ end (void *cls)
107 GNUNET_NAMESTORE_disconnect (nsh); 107 GNUNET_NAMESTORE_disconnect (nsh);
108 nsh = NULL; 108 nsh = NULL;
109 } 109 }
110 110 if (NULL != s_rd_1)
111 GNUNET_free_non_null(s_name_1);
112 GNUNET_free_non_null(s_name_2);
113 GNUNET_free_non_null(s_name_3);
114
115 if (s_rd_1 != NULL)
116 { 111 {
117 GNUNET_free ((void *)s_rd_1->data); 112 GNUNET_free ((void *)s_rd_1->data);
118 GNUNET_free (s_rd_1); 113 GNUNET_free (s_rd_1);
119 } 114 }
120 if (s_rd_2 != NULL) 115 if (NULL != s_rd_2)
121 { 116 {
122 GNUNET_free ((void *)s_rd_2->data); 117 GNUNET_free ((void *)s_rd_2->data);
123 GNUNET_free (s_rd_2); 118 GNUNET_free (s_rd_2);
124 } 119 }
125 if (s_rd_3 != NULL) 120 if (NULL != s_rd_3)
126 { 121 {
127 GNUNET_free ((void *)s_rd_3->data); 122 GNUNET_free ((void *)s_rd_3->data);
128 GNUNET_free (s_rd_3); 123 GNUNET_free (s_rd_3);
129 } 124 }
130
131 if (NULL != privkey) 125 if (NULL != privkey)
132 { 126 {
133 GNUNET_free (privkey); 127 GNUNET_free (privkey);
@@ -154,43 +148,45 @@ zone_proc (void *cls,
154 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
155 "Comparing results name %s\n", 149 "Comparing results name %s\n",
156 name); 150 name);
157
158 if (0 != memcmp (zone_key, 151 if (0 != memcmp (zone_key,
159 privkey, 152 privkey,
160 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) 153 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
161 { 154 {
162 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 155 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
163 "Monitoring returned wrong zone key\n"); 156 "Monitoring returned wrong zone key\n");
164 GNUNET_break (0); 157 GNUNET_break (0);
165 GNUNET_SCHEDULER_shutdown (); 158 GNUNET_SCHEDULER_shutdown ();
166 return; 159 return;
167 } 160 }
168 161
169 if (0 == strcmp (name, s_name_1)) 162 if (0 == strcmp (name,
163 s_name_1))
170 { 164 {
171 if (GNUNET_YES != 165 if (GNUNET_YES !=
172 GNUNET_GNSRECORD_records_cmp (rd, 166 GNUNET_GNSRECORD_records_cmp (rd,
173 s_rd_1)) 167 s_rd_1))
174 { 168 {
175 GNUNET_break (0); 169 GNUNET_break (0);
176 fail = GNUNET_YES; 170 fail = GNUNET_YES;
177 } 171 }
178 } 172 }
179 else if (0 == strcmp (name, s_name_2)) 173 else if (0 == strcmp (name,
174 s_name_2))
180 { 175 {
181 if (GNUNET_YES != 176 if (GNUNET_YES !=
182 GNUNET_GNSRECORD_records_cmp (rd, 177 GNUNET_GNSRECORD_records_cmp (rd,
183 s_rd_2)) 178 s_rd_2))
184 { 179 {
185 GNUNET_break (0); 180 GNUNET_break (0);
186 fail = GNUNET_YES; 181 fail = GNUNET_YES;
187 } 182 }
188 } 183 }
189 else 184 else
190 { 185 {
191 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 186 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
192 "Invalid name %s\n", name); 187 "Invalid name %s\n",
193 GNUNET_break (0); 188 name);
189 GNUNET_break (0);
194 fail = GNUNET_YES; 190 fail = GNUNET_YES;
195 } 191 }
196 GNUNET_NAMESTORE_zone_monitor_next (zm, 192 GNUNET_NAMESTORE_zone_monitor_next (zm,
@@ -231,14 +227,17 @@ put_cont (void *cls,
231 const char *emsg) 227 const char *emsg)
232{ 228{
233 static int c = 0; 229 static int c = 0;
234 char *label = cls; 230 const char *label = cls;
235 231
236 if (0 == strcmp (label, s_name_1)) 232 if (0 == strcmp (label,
237 ns_ops[0] = NULL; 233 s_name_1))
238 else if (0 == strcmp (label, s_name_2)) 234 ns_ops[0] = NULL;
239 ns_ops[1] = NULL; 235 else if (0 == strcmp (label,
240 else if (0 == strcmp (label, s_name_3)) 236 s_name_2))
241 ns_ops[2] = NULL; 237 ns_ops[1] = NULL;
238 else if (0 == strcmp (label,
239 s_name_3))
240 ns_ops[2] = NULL;
242 241
243 if (success == GNUNET_OK) 242 if (success == GNUNET_OK)
244 { 243 {
@@ -286,7 +285,7 @@ put_cont (void *cls,
286static struct GNUNET_GNSRECORD_Data * 285static struct GNUNET_GNSRECORD_Data *
287create_record (unsigned int count) 286create_record (unsigned int count)
288{ 287{
289 struct GNUNET_GNSRECORD_Data * rd; 288 struct GNUNET_GNSRECORD_Data *rd;
290 289
291 rd = GNUNET_new_array (count, 290 rd = GNUNET_new_array (count,
292 struct GNUNET_GNSRECORD_Data); 291 struct GNUNET_GNSRECORD_Data);
@@ -312,7 +311,9 @@ run (void *cls,
312{ 311{
313 res = 1; 312 res = 1;
314 privkey = GNUNET_CRYPTO_ecdsa_key_create (); 313 privkey = GNUNET_CRYPTO_ecdsa_key_create ();
315 GNUNET_assert (privkey != NULL); 314 GNUNET_assert (NULL != privkey);
315 privkey2 = GNUNET_CRYPTO_ecdsa_key_create ();
316 GNUNET_assert (NULL != privkey2);
316 317
317 cfg = mycfg; 318 cfg = mycfg;
318 GNUNET_SCHEDULER_add_shutdown (&end, 319 GNUNET_SCHEDULER_add_shutdown (&end,
@@ -324,19 +325,18 @@ run (void *cls,
324 nsh = GNUNET_NAMESTORE_connect (cfg); 325 nsh = GNUNET_NAMESTORE_connect (cfg);
325 if (NULL == nsh) 326 if (NULL == nsh)
326 { 327 {
327 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connect to namestore\n"); 328 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
329 "Connect to namestore failed\n");
328 GNUNET_break (0); 330 GNUNET_break (0);
329 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); 331 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly,
332 NULL);
330 return; 333 return;
331 } 334 }
332 335
333 privkey2 = GNUNET_CRYPTO_ecdsa_key_create (); 336 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
334 GNUNET_assert (privkey2 != NULL); 337 "Created record 3\n");
335
336
337 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n");
338 /* name in different zone */ 338 /* name in different zone */
339 GNUNET_asprintf(&s_name_3, "dummy3"); 339 s_name_3 = "dummy3";
340 s_rd_3 = create_record(1); 340 s_rd_3 = create_record(1);
341 GNUNET_assert (NULL != (ns_ops[2] = 341 GNUNET_assert (NULL != (ns_ops[2] =
342 GNUNET_NAMESTORE_records_store (nsh, 342 GNUNET_NAMESTORE_records_store (nsh,
@@ -345,24 +345,24 @@ run (void *cls,
345 1, 345 1,
346 s_rd_3, 346 s_rd_3,
347 &put_cont, 347 &put_cont,
348 s_name_3))); 348 (void *) s_name_3)));
349 349
350 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 350 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
351 "Created record 1\n"); 351 "Created record 1\n");
352 GNUNET_asprintf(&s_name_1, "dummy1"); 352 s_name_1 = "dummy1";
353 s_rd_1 = create_record(1); 353 s_rd_1 = create_record (1);
354 GNUNET_assert (NULL != (ns_ops[0] = 354 GNUNET_assert (NULL != (ns_ops[0] =
355 GNUNET_NAMESTORE_records_store(nsh, 355 GNUNET_NAMESTORE_records_store (nsh,
356 privkey, 356 privkey,
357 s_name_1, 357 s_name_1,
358 1, 358 1,
359 s_rd_1, 359 s_rd_1,
360 &put_cont, 360 &put_cont,
361 s_name_1))); 361 (void *) s_name_1)));
362 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 362 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
363 "Created record 2 \n"); 363 "Created record 2 \n");
364 GNUNET_asprintf(&s_name_2, "dummy2"); 364 s_name_2 = "dummy2";
365 s_rd_2 = create_record(1); 365 s_rd_2 = create_record (1);
366 GNUNET_assert (NULL != (ns_ops[1] = 366 GNUNET_assert (NULL != (ns_ops[1] =
367 GNUNET_NAMESTORE_records_store (nsh, 367 GNUNET_NAMESTORE_records_store (nsh,
368 privkey, 368 privkey,
@@ -370,12 +370,13 @@ run (void *cls,
370 1, 370 1,
371 s_rd_2, 371 s_rd_2,
372 &put_cont, 372 &put_cont,
373 s_name_2))); 373 (void *) s_name_2)));
374} 374}
375 375
376 376
377int 377int
378main (int argc, char *argv[]) 378main (int argc,
379 char *argv[])
379{ 380{
380 const char *plugin_name; 381 const char *plugin_name;
381 char *cfg_name; 382 char *cfg_name;
@@ -393,6 +394,7 @@ main (int argc, char *argv[])
393 &run, 394 &run,
394 NULL)) 395 NULL))
395 { 396 {
397 GNUNET_break (0);
396 res = 1; 398 res = 1;
397 } 399 }
398 GNUNET_DISK_purge_cfg_dir (cfg_name, 400 GNUNET_DISK_purge_cfg_dir (cfg_name,