aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_namestore_api_zone_iteration_nick.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_zone_iteration_nick.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_zone_iteration_nick.c')
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_nick.c57
1 files changed, 23 insertions, 34 deletions
diff --git a/src/namestore/test_namestore_api_zone_iteration_nick.c b/src/namestore/test_namestore_api_zone_iteration_nick.c
index a88646864..d950b7e69 100644
--- a/src/namestore/test_namestore_api_zone_iteration_nick.c
+++ b/src/namestore/test_namestore_api_zone_iteration_nick.c
@@ -60,7 +60,6 @@ static struct GNUNET_GNSRECORD_Data *s_rd_3;
60 60
61static struct GNUNET_NAMESTORE_QueueEntry *nsqe; 61static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
62 62
63static char *directory;
64 63
65/** 64/**
66 * Re-establish the connection to the service. 65 * Re-establish the connection to the service.
@@ -265,7 +264,9 @@ fail_cb (void *cls)
265 264
266 265
267static void 266static void
268put_cont (void *cls, int32_t success, const char *emsg) 267put_cont (void *cls,
268 int32_t success,
269 const char *emsg)
269{ 270{
270 static int c = 0; 271 static int c = 0;
271 272
@@ -314,11 +315,11 @@ put_cont (void *cls, int32_t success, const char *emsg)
314static struct GNUNET_GNSRECORD_Data * 315static struct GNUNET_GNSRECORD_Data *
315create_record (unsigned int count) 316create_record (unsigned int count)
316{ 317{
317 unsigned int c;
318 struct GNUNET_GNSRECORD_Data * rd; 318 struct GNUNET_GNSRECORD_Data * rd;
319 319
320 rd = GNUNET_malloc (count * sizeof (struct GNUNET_GNSRECORD_Data)); 320 rd = GNUNET_new_array (count,
321 for (c = 0; c < count; c++) 321 struct GNUNET_GNSRECORD_Data);
322 for (unsigned int c = 0; c < count; c++)
322 { 323 {
323 rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us; 324 rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us;
324 rd[c].record_type = 1111; 325 rd[c].record_type = 1111;
@@ -332,7 +333,9 @@ create_record (unsigned int count)
332 333
333 334
334static void 335static void
335nick_2_cont (void *cls, int32_t success, const char *emsg) 336nick_2_cont (void *cls,
337 int32_t success,
338 const char *emsg)
336{ 339{
337 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 340 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
338 "Nick added : %s\n", 341 "Nick added : %s\n",
@@ -422,25 +425,18 @@ empty_zone_proc (void *cls,
422static void 425static void
423empty_zone_end (void *cls) 426empty_zone_end (void *cls)
424{ 427{
425 char *hostkey_file;
426 GNUNET_assert (nsh == cls); 428 GNUNET_assert (nsh == cls);
427
428 zi = NULL; 429 zi = NULL;
429 GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, 430 privkey = GNUNET_CRYPTO_ecdsa_key_create ();
430 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
431 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file);
432 privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file);
433 GNUNET_free (hostkey_file);
434 GNUNET_assert (privkey != NULL); 431 GNUNET_assert (privkey != NULL);
435 432 privkey2 = GNUNET_CRYPTO_ecdsa_key_create ();
436 GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
437 "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey");
438 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file);
439 privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file);
440 GNUNET_free (hostkey_file);
441 GNUNET_assert (privkey2 != NULL); 433 GNUNET_assert (privkey2 != NULL);
442 434
443 nsqe = GNUNET_NAMESTORE_set_nick (nsh, privkey, ZONE_NICK_1, &nick_1_cont, &privkey); 435 nsqe = GNUNET_NAMESTORE_set_nick (nsh,
436 privkey,
437 ZONE_NICK_1,
438 &nick_1_cont,
439 &privkey);
444 if (NULL == nsqe) 440 if (NULL == nsqe)
445 { 441 {
446 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 442 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -455,15 +451,9 @@ run (void *cls,
455 const struct GNUNET_CONFIGURATION_Handle *cfg, 451 const struct GNUNET_CONFIGURATION_Handle *cfg,
456 struct GNUNET_TESTING_Peer *peer) 452 struct GNUNET_TESTING_Peer *peer)
457{ 453{
458 directory = NULL; 454 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
459 GNUNET_assert (GNUNET_OK == 455 &endbadly,
460 GNUNET_CONFIGURATION_get_value_string (cfg, 456 NULL);
461 "PATHS",
462 "GNUNET_TEST_HOME",
463 &directory));
464 GNUNET_DISK_directory_remove (directory);
465
466 endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, &endbadly, NULL);
467 nsh = GNUNET_NAMESTORE_connect (cfg); 457 nsh = GNUNET_NAMESTORE_connect (cfg);
468 GNUNET_break (NULL != nsh); 458 GNUNET_break (NULL != nsh);
469 459
@@ -498,6 +488,8 @@ main (int argc, char *argv[])
498 "test_namestore_api_%s.conf", 488 "test_namestore_api_%s.conf",
499 plugin_name); 489 plugin_name);
500 res = 1; 490 res = 1;
491 GNUNET_DISK_purge_cfg_dir (cfg_name,
492 "GNUNET_TEST_HOME");
501 if (0 != 493 if (0 !=
502 GNUNET_TESTING_peer_run ("test-namestore-api-zone-iteration-nick", 494 GNUNET_TESTING_peer_run ("test-namestore-api-zone-iteration-nick",
503 cfg_name, 495 cfg_name,
@@ -506,12 +498,9 @@ main (int argc, char *argv[])
506 { 498 {
507 res = 1; 499 res = 1;
508 } 500 }
501 GNUNET_DISK_purge_cfg_dir (cfg_name,
502 "GNUNET_TEST_HOME");
509 GNUNET_free (cfg_name); 503 GNUNET_free (cfg_name);
510 if (NULL != directory)
511 {
512 GNUNET_DISK_directory_remove (directory);
513 GNUNET_free (directory);
514 }
515 return res; 504 return res;
516} 505}
517 506