diff options
Diffstat (limited to 'src/namestore/test_namestore_api_zone_iteration_nick.c')
-rw-r--r-- | src/namestore/test_namestore_api_zone_iteration_nick.c | 80 |
1 files changed, 35 insertions, 45 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..efaadff55 100644 --- a/src/namestore/test_namestore_api_zone_iteration_nick.c +++ b/src/namestore/test_namestore_api_zone_iteration_nick.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2013 GNUnet e.V. | 3 | Copyright (C) 2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file namestore/test_namestore_api_zone_iteration.c | 19 | * @file namestore/test_namestore_api_zone_iteration.c |
@@ -25,6 +23,9 @@ | |||
25 | #include "gnunet_namestore_service.h" | 23 | #include "gnunet_namestore_service.h" |
26 | #include "gnunet_testing_lib.h" | 24 | #include "gnunet_testing_lib.h" |
27 | #include "namestore.h" | 25 | #include "namestore.h" |
26 | #include "gnunet_dnsparser_lib.h" | ||
27 | |||
28 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT | ||
28 | 29 | ||
29 | #define ZONE_NICK_1 "nick1" | 30 | #define ZONE_NICK_1 "nick1" |
30 | #define ZONE_NICK_2 "nick2" | 31 | #define ZONE_NICK_2 "nick2" |
@@ -60,7 +61,6 @@ static struct GNUNET_GNSRECORD_Data *s_rd_3; | |||
60 | 61 | ||
61 | static struct GNUNET_NAMESTORE_QueueEntry *nsqe; | 62 | static struct GNUNET_NAMESTORE_QueueEntry *nsqe; |
62 | 63 | ||
63 | static char *directory; | ||
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Re-establish the connection to the service. | 66 | * Re-establish the connection to the service. |
@@ -265,7 +265,9 @@ fail_cb (void *cls) | |||
265 | 265 | ||
266 | 266 | ||
267 | static void | 267 | static void |
268 | put_cont (void *cls, int32_t success, const char *emsg) | 268 | put_cont (void *cls, |
269 | int32_t success, | ||
270 | const char *emsg) | ||
269 | { | 271 | { |
270 | static int c = 0; | 272 | static int c = 0; |
271 | 273 | ||
@@ -314,14 +316,14 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
314 | static struct GNUNET_GNSRECORD_Data * | 316 | static struct GNUNET_GNSRECORD_Data * |
315 | create_record (unsigned int count) | 317 | create_record (unsigned int count) |
316 | { | 318 | { |
317 | unsigned int c; | ||
318 | struct GNUNET_GNSRECORD_Data * rd; | 319 | struct GNUNET_GNSRECORD_Data * rd; |
319 | 320 | ||
320 | rd = GNUNET_malloc (count * sizeof (struct GNUNET_GNSRECORD_Data)); | 321 | rd = GNUNET_new_array (count, |
321 | for (c = 0; c < count; c++) | 322 | struct GNUNET_GNSRECORD_Data); |
323 | for (unsigned int c = 0; c < count; c++) | ||
322 | { | 324 | { |
323 | rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us; | 325 | rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us; |
324 | rd[c].record_type = 1111; | 326 | rd[c].record_type = TEST_RECORD_TYPE; |
325 | rd[c].data_size = 50; | 327 | rd[c].data_size = 50; |
326 | rd[c].data = GNUNET_malloc(50); | 328 | rd[c].data = GNUNET_malloc(50); |
327 | rd[c].flags = 0; | 329 | rd[c].flags = 0; |
@@ -332,7 +334,9 @@ create_record (unsigned int count) | |||
332 | 334 | ||
333 | 335 | ||
334 | static void | 336 | static void |
335 | nick_2_cont (void *cls, int32_t success, const char *emsg) | 337 | nick_2_cont (void *cls, |
338 | int32_t success, | ||
339 | const char *emsg) | ||
336 | { | 340 | { |
337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
338 | "Nick added : %s\n", | 342 | "Nick added : %s\n", |
@@ -422,25 +426,18 @@ empty_zone_proc (void *cls, | |||
422 | static void | 426 | static void |
423 | empty_zone_end (void *cls) | 427 | empty_zone_end (void *cls) |
424 | { | 428 | { |
425 | char *hostkey_file; | ||
426 | GNUNET_assert (nsh == cls); | 429 | GNUNET_assert (nsh == cls); |
427 | |||
428 | zi = NULL; | 430 | zi = NULL; |
429 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 431 | 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); | 432 | GNUNET_assert (privkey != NULL); |
435 | 433 | 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); | 434 | GNUNET_assert (privkey2 != NULL); |
442 | 435 | ||
443 | nsqe = GNUNET_NAMESTORE_set_nick (nsh, privkey, ZONE_NICK_1, &nick_1_cont, &privkey); | 436 | nsqe = GNUNET_NAMESTORE_set_nick (nsh, |
437 | privkey, | ||
438 | ZONE_NICK_1, | ||
439 | &nick_1_cont, | ||
440 | &privkey); | ||
444 | if (NULL == nsqe) | 441 | if (NULL == nsqe) |
445 | { | 442 | { |
446 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 443 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -455,15 +452,9 @@ run (void *cls, | |||
455 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 452 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
456 | struct GNUNET_TESTING_Peer *peer) | 453 | struct GNUNET_TESTING_Peer *peer) |
457 | { | 454 | { |
458 | directory = NULL; | 455 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
459 | GNUNET_assert (GNUNET_OK == | 456 | &endbadly, |
460 | GNUNET_CONFIGURATION_get_value_string (cfg, | 457 | 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); | 458 | nsh = GNUNET_NAMESTORE_connect (cfg); |
468 | GNUNET_break (NULL != nsh); | 459 | GNUNET_break (NULL != nsh); |
469 | 460 | ||
@@ -498,6 +489,8 @@ main (int argc, char *argv[]) | |||
498 | "test_namestore_api_%s.conf", | 489 | "test_namestore_api_%s.conf", |
499 | plugin_name); | 490 | plugin_name); |
500 | res = 1; | 491 | res = 1; |
492 | GNUNET_DISK_purge_cfg_dir (cfg_name, | ||
493 | "GNUNET_TEST_HOME"); | ||
501 | if (0 != | 494 | if (0 != |
502 | GNUNET_TESTING_peer_run ("test-namestore-api-zone-iteration-nick", | 495 | GNUNET_TESTING_peer_run ("test-namestore-api-zone-iteration-nick", |
503 | cfg_name, | 496 | cfg_name, |
@@ -506,12 +499,9 @@ main (int argc, char *argv[]) | |||
506 | { | 499 | { |
507 | res = 1; | 500 | res = 1; |
508 | } | 501 | } |
502 | GNUNET_DISK_purge_cfg_dir (cfg_name, | ||
503 | "GNUNET_TEST_HOME"); | ||
509 | GNUNET_free (cfg_name); | 504 | GNUNET_free (cfg_name); |
510 | if (NULL != directory) | ||
511 | { | ||
512 | GNUNET_DISK_directory_remove (directory); | ||
513 | GNUNET_free (directory); | ||
514 | } | ||
515 | return res; | 505 | return res; |
516 | } | 506 | } |
517 | 507 | ||