aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_namestore_api_store.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/namestore/test_namestore_api_store.c')
-rw-r--r--src/namestore/test_namestore_api_store.c54
1 files changed, 22 insertions, 32 deletions
diff --git a/src/namestore/test_namestore_api_store.c b/src/namestore/test_namestore_api_store.c
index 4e51678a1..61b534781 100644
--- a/src/namestore/test_namestore_api_store.c
+++ b/src/namestore/test_namestore_api_store.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_store.c 19 * @file namestore/test_namestore_api_store.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
@@ -46,7 +45,6 @@ static int res;
46 45
47static struct GNUNET_NAMESTORE_QueueEntry *nsqe; 46static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
48 47
49static char *directory;
50 48
51static void 49static void
52cleanup () 50cleanup ()
@@ -114,23 +112,11 @@ run (void *cls,
114 struct GNUNET_TESTING_Peer *peer) 112 struct GNUNET_TESTING_Peer *peer)
115{ 113{
116 struct GNUNET_GNSRECORD_Data rd; 114 struct GNUNET_GNSRECORD_Data rd;
117 char *hostkey_file;
118 const char * name = "dummy.dummy.gnunet"; 115 const char * name = "dummy.dummy.gnunet";
119 116
120 directory = NULL;
121 GNUNET_assert (GNUNET_OK ==
122 GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "GNUNET_TEST_HOME", &directory));
123 GNUNET_DISK_directory_remove (directory);
124
125 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 117 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
126 &endbadly, NULL); 118 &endbadly, NULL);
127 GNUNET_asprintf (&hostkey_file, 119 privkey = GNUNET_CRYPTO_ecdsa_key_create ();
128 "zonefiles%s%s",
129 DIR_SEPARATOR_STR,
130 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
131 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file);
132 privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file);
133 GNUNET_free (hostkey_file);
134 GNUNET_assert (privkey != NULL); 120 GNUNET_assert (privkey != NULL);
135 GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey); 121 GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey);
136 122
@@ -144,8 +130,13 @@ run (void *cls,
144 130
145 nsh = GNUNET_NAMESTORE_connect (cfg); 131 nsh = GNUNET_NAMESTORE_connect (cfg);
146 GNUNET_break (NULL != nsh); 132 GNUNET_break (NULL != nsh);
147 nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, 133 nsqe = GNUNET_NAMESTORE_records_store (nsh,
148 1, &rd, &put_cont, (void *) name); 134 privkey,
135 name,
136 1,
137 &rd,
138 &put_cont,
139 (void *) name);
149 if (NULL == nsqe) 140 if (NULL == nsqe)
150 { 141 {
151 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 142 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -167,6 +158,8 @@ main (int argc, char *argv[])
167 "test_namestore_api_%s.conf", 158 "test_namestore_api_%s.conf",
168 plugin_name); 159 plugin_name);
169 res = 1; 160 res = 1;
161 GNUNET_DISK_purge_cfg_dir (cfg_name,
162 "GNUNET_TEST_HOME");
170 if (0 != 163 if (0 !=
171 GNUNET_TESTING_peer_run ("test-namestore-api", 164 GNUNET_TESTING_peer_run ("test-namestore-api",
172 cfg_name, 165 cfg_name,
@@ -175,12 +168,9 @@ main (int argc, char *argv[])
175 { 168 {
176 res = 1; 169 res = 1;
177 } 170 }
171 GNUNET_DISK_purge_cfg_dir (cfg_name,
172 "GNUNET_TEST_HOME");
178 GNUNET_free (cfg_name); 173 GNUNET_free (cfg_name);
179 if (NULL != directory)
180 {
181 GNUNET_DISK_directory_remove (directory);
182 GNUNET_free (directory);
183 }
184 return res; 174 return res;
185} 175}
186 176