aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_namestore_api_lookup_nick.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/namestore/test_namestore_api_lookup_nick.c')
-rw-r--r--src/namestore/test_namestore_api_lookup_nick.c58
1 files changed, 24 insertions, 34 deletions
diff --git a/src/namestore/test_namestore_api_lookup_nick.c b/src/namestore/test_namestore_api_lookup_nick.c
index 50d1fd9a9..1a5a09e47 100644
--- a/src/namestore/test_namestore_api_lookup_nick.c
+++ b/src/namestore/test_namestore_api_lookup_nick.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2012 GNUnet e.V. 3 Copyright (C) 2012 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_lookup_nick.c 19 * @file namestore/test_namestore_api_lookup_nick.c
@@ -24,8 +22,9 @@
24#include "platform.h" 22#include "platform.h"
25#include "gnunet_namestore_service.h" 23#include "gnunet_namestore_service.h"
26#include "gnunet_testing_lib.h" 24#include "gnunet_testing_lib.h"
25#include "gnunet_dnsparser_lib.h"
27 26
28#define TEST_RECORD_TYPE 1234 27#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
29 28
30#define TEST_RECORD_DATALEN 123 29#define TEST_RECORD_DATALEN 123
31 30
@@ -52,7 +51,6 @@ static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
52//static const char * name = "dummy.dummy.gnunet"; 51//static const char * name = "dummy.dummy.gnunet";
53static const char * name = "d"; 52static const char * name = "d";
54 53
55static char *directory;
56 54
57static void 55static void
58cleanup () 56cleanup ()
@@ -283,29 +281,22 @@ run (void *cls,
283 const struct GNUNET_CONFIGURATION_Handle *cfg, 281 const struct GNUNET_CONFIGURATION_Handle *cfg,
284 struct GNUNET_TESTING_Peer *peer) 282 struct GNUNET_TESTING_Peer *peer)
285{ 283{
286 char *hostkey_file;
287
288 directory = NULL;
289 GNUNET_assert (GNUNET_OK ==
290 GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "GNUNET_TEST_HOME", &directory));
291 GNUNET_DISK_directory_remove (directory);
292
293 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 284 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
294 &endbadly, NULL); 285 &endbadly,
295 GNUNET_asprintf (&hostkey_file, 286 NULL);
296 "zonefiles%s%s", 287 privkey = GNUNET_CRYPTO_ecdsa_key_create ();
297 DIR_SEPARATOR_STR,
298 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
299 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file);
300 privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file);
301 GNUNET_free (hostkey_file);
302 GNUNET_assert (privkey != NULL); 288 GNUNET_assert (privkey != NULL);
303 GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey); 289 GNUNET_CRYPTO_ecdsa_key_get_public (privkey,
290 &pubkey);
304 291
305 nsh = GNUNET_NAMESTORE_connect (cfg); 292 nsh = GNUNET_NAMESTORE_connect (cfg);
306 GNUNET_break (NULL != nsh); 293 GNUNET_break (NULL != nsh);
307 294
308 nsqe = GNUNET_NAMESTORE_set_nick (nsh, privkey, TEST_NICK, &nick_cont, (void *) name); 295 nsqe = GNUNET_NAMESTORE_set_nick (nsh,
296 privkey,
297 TEST_NICK,
298 &nick_cont,
299 (void *) name);
309 if (NULL == nsqe) 300 if (NULL == nsqe)
310 { 301 {
311 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 302 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -324,6 +315,8 @@ main (int argc, char *argv[])
324 GNUNET_asprintf (&cfg_name, 315 GNUNET_asprintf (&cfg_name,
325 "test_namestore_api_%s.conf", 316 "test_namestore_api_%s.conf",
326 plugin_name); 317 plugin_name);
318 GNUNET_DISK_purge_cfg_dir (cfg_name,
319 "GNUNET_TEST_HOME");
327 res = 1; 320 res = 1;
328 if (0 != 321 if (0 !=
329 GNUNET_TESTING_peer_run ("test-namestore-api-lookup-nick", 322 GNUNET_TESTING_peer_run ("test-namestore-api-lookup-nick",
@@ -333,12 +326,9 @@ main (int argc, char *argv[])
333 { 326 {
334 res = 1; 327 res = 1;
335 } 328 }
329 GNUNET_DISK_purge_cfg_dir (cfg_name,
330 "GNUNET_TEST_HOME");
336 GNUNET_free (cfg_name); 331 GNUNET_free (cfg_name);
337 if (NULL != directory)
338 {
339 GNUNET_DISK_directory_remove (directory);
340 GNUNET_free (directory);
341 }
342 return res; 332 return res;
343} 333}
344 334