aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_namestore_api_remove.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/namestore/test_namestore_api_remove.c')
-rw-r--r--src/namestore/test_namestore_api_remove.c63
1 files changed, 25 insertions, 38 deletions
diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c
index 532a751da..7d993d4d9 100644
--- a/src/namestore/test_namestore_api_remove.c
+++ b/src/namestore/test_namestore_api_remove.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.c 19 * @file namestore/test_namestore_api.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
@@ -48,7 +47,6 @@ static int removed;
48 47
49static struct GNUNET_NAMESTORE_QueueEntry *nsqe; 48static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
50 49
51static char *directory;
52 50
53static void 51static void
54cleanup () 52cleanup ()
@@ -157,29 +155,12 @@ run (void *cls,
157 struct GNUNET_TESTING_Peer *peer) 155 struct GNUNET_TESTING_Peer *peer)
158{ 156{
159 struct GNUNET_GNSRECORD_Data rd; 157 struct GNUNET_GNSRECORD_Data rd;
160 char *hostkey_file;
161 const char * name = "dummy.dummy.gnunet"; 158 const char * name = "dummy.dummy.gnunet";
162 159
163 directory = NULL;
164 GNUNET_assert (GNUNET_OK ==
165 GNUNET_CONFIGURATION_get_value_string(cfg,
166 "PATHS",
167 "GNUNET_TEST_HOME",
168 &directory));
169 GNUNET_DISK_directory_remove (directory);
170
171 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 160 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
172 &endbadly, 161 &endbadly,
173 NULL); 162 NULL);
174 GNUNET_asprintf (&hostkey_file, 163 privkey = GNUNET_CRYPTO_ecdsa_key_create ();
175 "zonefiles%s%s",
176 DIR_SEPARATOR_STR,
177 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
178 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
179 "Using zonekey file `%s' \n",
180 hostkey_file);
181 privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file);
182 GNUNET_free (hostkey_file);
183 GNUNET_assert (privkey != NULL); 164 GNUNET_assert (privkey != NULL);
184 GNUNET_CRYPTO_ecdsa_key_get_public (privkey, 165 GNUNET_CRYPTO_ecdsa_key_get_public (privkey,
185 &pubkey); 166 &pubkey);
@@ -191,12 +172,19 @@ run (void *cls,
191 rd.data_size = TEST_RECORD_DATALEN; 172 rd.data_size = TEST_RECORD_DATALEN;
192 rd.data = GNUNET_malloc (TEST_RECORD_DATALEN); 173 rd.data = GNUNET_malloc (TEST_RECORD_DATALEN);
193 rd.flags = 0; 174 rd.flags = 0;
194 memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN); 175 memset ((char *) rd.data,
176 'a',
177 TEST_RECORD_DATALEN);
195 178
196 nsh = GNUNET_NAMESTORE_connect (cfg); 179 nsh = GNUNET_NAMESTORE_connect (cfg);
197 GNUNET_break (NULL != nsh); 180 GNUNET_break (NULL != nsh);
198 nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, 181 nsqe = GNUNET_NAMESTORE_records_store (nsh,
199 1, &rd, &put_cont, (void *) name); 182 privkey,
183 name,
184 1,
185 &rd,
186 &put_cont,
187 (void *) name);
200 if (NULL == nsqe) 188 if (NULL == nsqe)
201 { 189 {
202 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 190 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -216,6 +204,8 @@ main (int argc, char *argv[])
216 GNUNET_asprintf (&cfg_name, 204 GNUNET_asprintf (&cfg_name,
217 "test_namestore_api_%s.conf", 205 "test_namestore_api_%s.conf",
218 plugin_name); 206 plugin_name);
207 GNUNET_DISK_purge_cfg_dir (cfg_name,
208 "GNUNET_TEST_HOME");
219 res = 1; 209 res = 1;
220 if (0 != 210 if (0 !=
221 GNUNET_TESTING_peer_run ("test-namestore-api-remove", 211 GNUNET_TESTING_peer_run ("test-namestore-api-remove",
@@ -225,12 +215,9 @@ main (int argc, char *argv[])
225 { 215 {
226 res = 1; 216 res = 1;
227 } 217 }
218 GNUNET_DISK_purge_cfg_dir (cfg_name,
219 "GNUNET_TEST_HOME");
228 GNUNET_free (cfg_name); 220 GNUNET_free (cfg_name);
229 if (NULL != directory)
230 {
231 GNUNET_DISK_directory_remove (directory);
232 GNUNET_free (directory);
233 }
234 return res; 221 return res;
235} 222}
236 223