aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_namestore_api_monitoring.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-05-09 17:33:04 +0200
committerChristian Grothoff <christian@grothoff.org>2018-05-09 17:33:04 +0200
commit8bb475af99260f1d107dbc8908268ae93960aa83 (patch)
tree1a7a1fc03424df841a6f977b137482439b09bc9f /src/namestore/test_namestore_api_monitoring.c
parent1f80a11e90ee982bffaae4685e281f75ee1c225d (diff)
downloadgnunet-8bb475af99260f1d107dbc8908268ae93960aa83.tar.gz
gnunet-8bb475af99260f1d107dbc8908268ae93960aa83.zip
implement new functions in libgnunetsq, clean up sqlite namestore plugin, implement flow control in namestore API and tests
Diffstat (limited to 'src/namestore/test_namestore_api_monitoring.c')
-rw-r--r--src/namestore/test_namestore_api_monitoring.c65
1 files changed, 26 insertions, 39 deletions
diff --git a/src/namestore/test_namestore_api_monitoring.c b/src/namestore/test_namestore_api_monitoring.c
index cd38b2c80..de202d535 100644
--- a/src/namestore/test_namestore_api_monitoring.c
+++ b/src/namestore/test_namestore_api_monitoring.c
@@ -56,7 +56,6 @@ static struct GNUNET_GNSRECORD_Data *s_rd_3;
56 56
57struct GNUNET_NAMESTORE_QueueEntry * ns_ops[3]; 57struct GNUNET_NAMESTORE_QueueEntry * ns_ops[3];
58 58
59static char *directory;
60 59
61static void 60static void
62do_shutdown () 61do_shutdown ()
@@ -66,7 +65,6 @@ do_shutdown ()
66 GNUNET_NAMESTORE_zone_monitor_stop (zm); 65 GNUNET_NAMESTORE_zone_monitor_stop (zm);
67 zm = NULL; 66 zm = NULL;
68 } 67 }
69
70 if (NULL != ns_ops[0]) 68 if (NULL != ns_ops[0])
71 { 69 {
72 GNUNET_NAMESTORE_cancel(ns_ops[0]); 70 GNUNET_NAMESTORE_cancel(ns_ops[0]);
@@ -82,13 +80,11 @@ do_shutdown ()
82 GNUNET_NAMESTORE_cancel(ns_ops[2]); 80 GNUNET_NAMESTORE_cancel(ns_ops[2]);
83 ns_ops[2] = NULL; 81 ns_ops[2] = NULL;
84 } 82 }
85
86 if (NULL != nsh) 83 if (NULL != nsh)
87 { 84 {
88 GNUNET_NAMESTORE_disconnect (nsh); 85 GNUNET_NAMESTORE_disconnect (nsh);
89 nsh = NULL; 86 nsh = NULL;
90 } 87 }
91
92 GNUNET_free_non_null(s_name_1); 88 GNUNET_free_non_null(s_name_1);
93 GNUNET_free_non_null(s_name_2); 89 GNUNET_free_non_null(s_name_2);
94 GNUNET_free_non_null(s_name_3); 90 GNUNET_free_non_null(s_name_3);
@@ -284,23 +280,8 @@ run (void *cls,
284 const struct GNUNET_CONFIGURATION_Handle *cfg, 280 const struct GNUNET_CONFIGURATION_Handle *cfg,
285 struct GNUNET_TESTING_Peer *peer) 281 struct GNUNET_TESTING_Peer *peer)
286{ 282{
287 char *hostkey_file;
288
289 res = 1; 283 res = 1;
290 284 privkey = GNUNET_CRYPTO_ecdsa_key_create ();
291 directory = NULL;
292 GNUNET_assert (GNUNET_OK ==
293 GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "GNUNET_TEST_HOME", &directory));
294 GNUNET_DISK_directory_remove (directory);
295
296 GNUNET_asprintf(&hostkey_file,
297 "zonefiles%s%s",
298 DIR_SEPARATOR_STR,
299 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
301 "Using zonekey file `%s' \n", hostkey_file);
302 privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file);
303 GNUNET_free (hostkey_file);
304 GNUNET_assert (privkey != NULL); 285 GNUNET_assert (privkey != NULL);
305 286
306 /* Start monitoring */ 287 /* Start monitoring */
@@ -333,16 +314,12 @@ run (void *cls,
333 return; 314 return;
334 } 315 }
335 316
336 GNUNET_asprintf(&hostkey_file,"zonefiles%s%s", 317 privkey2 = GNUNET_CRYPTO_ecdsa_key_create ();
337 DIR_SEPARATOR_STR,
338 "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey");
339 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file);
340 privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file);
341 GNUNET_free (hostkey_file);
342 GNUNET_assert (privkey2 != NULL); 318 GNUNET_assert (privkey2 != NULL);
343 319
344 320
345 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n"); 321 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
322 "Created record 3\n");
346 /* name in different zone */ 323 /* name in different zone */
347 GNUNET_asprintf(&s_name_3, "dummy3"); 324 GNUNET_asprintf(&s_name_3, "dummy3");
348 s_rd_3 = create_record(1); 325 s_rd_3 = create_record(1);
@@ -358,22 +335,33 @@ run (void *cls,
358 "Created record 1\n"); 335 "Created record 1\n");
359 GNUNET_asprintf(&s_name_1, "dummy1"); 336 GNUNET_asprintf(&s_name_1, "dummy1");
360 s_rd_1 = create_record(1); 337 s_rd_1 = create_record(1);
361 GNUNET_assert (NULL != (ns_ops[0] = GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, 338 GNUNET_assert (NULL != (ns_ops[0] =
362 1, s_rd_1, &put_cont, s_name_1))); 339 GNUNET_NAMESTORE_records_store (nsh,
340 privkey,
341 s_name_1,
342 1,
343 s_rd_1,
344 &put_cont,
345 s_name_1)));
363 346
364 347
365 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); 348 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n");
366 GNUNET_asprintf(&s_name_2, "dummy2"); 349 GNUNET_asprintf(&s_name_2, "dummy2");
367 s_rd_2 = create_record(1); 350 s_rd_2 = create_record(1);
368 GNUNET_assert (NULL != (ns_ops[1] = GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_2, 351 GNUNET_assert (NULL != (ns_ops[1] =
369 1, s_rd_2, &put_cont, s_name_2))); 352 GNUNET_NAMESTORE_records_store (nsh,
370 353 privkey,
371 354 s_name_2,
355 1,
356 s_rd_2,
357 &put_cont,
358 s_name_2)));
372} 359}
373 360
374 361
375int 362int
376main (int argc, char *argv[]) 363main (int argc,
364 char *argv[])
377{ 365{
378 const char *plugin_name; 366 const char *plugin_name;
379 char *cfg_name; 367 char *cfg_name;
@@ -382,6 +370,8 @@ main (int argc, char *argv[])
382 GNUNET_asprintf (&cfg_name, 370 GNUNET_asprintf (&cfg_name,
383 "test_namestore_api_%s.conf", 371 "test_namestore_api_%s.conf",
384 plugin_name); 372 plugin_name);
373 GNUNET_DISK_purge_cfg_dir (cfg_name,
374 "GNUNET_TEST_HOME");
385 res = 1; 375 res = 1;
386 if (0 != 376 if (0 !=
387 GNUNET_TESTING_peer_run ("test-namestore-api-monitoring", 377 GNUNET_TESTING_peer_run ("test-namestore-api-monitoring",
@@ -391,12 +381,9 @@ main (int argc, char *argv[])
391 { 381 {
392 res = 1; 382 res = 1;
393 } 383 }
384 GNUNET_DISK_purge_cfg_dir (cfg_name,
385 "GNUNET_TEST_HOME");
394 GNUNET_free (cfg_name); 386 GNUNET_free (cfg_name);
395 if (NULL != directory)
396 {
397 GNUNET_DISK_directory_remove (directory);
398 GNUNET_free (directory);
399 }
400 return res; 387 return res;
401} 388}
402 389