diff options
Diffstat (limited to 'src/namestore/test_namestore_api_lookup_shadow.c')
-rw-r--r-- | src/namestore/test_namestore_api_lookup_shadow.c | 61 |
1 files changed, 26 insertions, 35 deletions
diff --git a/src/namestore/test_namestore_api_lookup_shadow.c b/src/namestore/test_namestore_api_lookup_shadow.c index e80335796..08977712b 100644 --- a/src/namestore/test_namestore_api_lookup_shadow.c +++ b/src/namestore/test_namestore_api_lookup_shadow.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_shadow.c | 19 | * @file namestore/test_namestore_api_lookup_shadow.c |
@@ -27,8 +25,9 @@ | |||
27 | #include "gnunet_namecache_service.h" | 25 | #include "gnunet_namecache_service.h" |
28 | #include "gnunet_namestore_service.h" | 26 | #include "gnunet_namestore_service.h" |
29 | #include "gnunet_testing_lib.h" | 27 | #include "gnunet_testing_lib.h" |
28 | #include "gnunet_dnsparser_lib.h" | ||
30 | 29 | ||
31 | #define TEST_RECORD_TYPE 1234 | 30 | #define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT |
32 | 31 | ||
33 | #define TEST_RECORD_DATALEN 123 | 32 | #define TEST_RECORD_DATALEN 123 |
34 | 33 | ||
@@ -53,7 +52,6 @@ static struct GNUNET_NAMESTORE_QueueEntry *nsqe; | |||
53 | 52 | ||
54 | static struct GNUNET_NAMECACHE_QueueEntry *ncqe; | 53 | static struct GNUNET_NAMECACHE_QueueEntry *ncqe; |
55 | 54 | ||
56 | static char *directory; | ||
57 | 55 | ||
58 | static void | 56 | static void |
59 | cleanup () | 57 | cleanup () |
@@ -222,26 +220,15 @@ run (void *cls, | |||
222 | struct GNUNET_TESTING_Peer *peer) | 220 | struct GNUNET_TESTING_Peer *peer) |
223 | { | 221 | { |
224 | struct GNUNET_GNSRECORD_Data rd; | 222 | struct GNUNET_GNSRECORD_Data rd; |
225 | char *hostkey_file; | ||
226 | const char * name = "dummy.dummy.gnunet"; | 223 | const char * name = "dummy.dummy.gnunet"; |
227 | 224 | ||
228 | directory = NULL; | ||
229 | GNUNET_assert (GNUNET_OK == | ||
230 | GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "GNUNET_TEST_HOME", &directory)); | ||
231 | GNUNET_DISK_directory_remove (directory); | ||
232 | |||
233 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 225 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
234 | &endbadly, NULL); | 226 | &endbadly, |
235 | GNUNET_asprintf (&hostkey_file, | 227 | NULL); |
236 | "zonefiles%s%s", | 228 | privkey = GNUNET_CRYPTO_ecdsa_key_create (); |
237 | DIR_SEPARATOR_STR, | ||
238 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | ||
239 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | ||
240 | privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file); | ||
241 | GNUNET_free (hostkey_file); | ||
242 | GNUNET_assert (privkey != NULL); | 229 | GNUNET_assert (privkey != NULL); |
243 | GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey); | 230 | GNUNET_CRYPTO_ecdsa_key_get_public (privkey, |
244 | 231 | &pubkey); | |
245 | rd.expiration_time = GNUNET_TIME_absolute_get().abs_value_us + 1000000000; | 232 | rd.expiration_time = GNUNET_TIME_absolute_get().abs_value_us + 1000000000; |
246 | rd.record_type = TEST_RECORD_TYPE; | 233 | rd.record_type = TEST_RECORD_TYPE; |
247 | rd.data_size = TEST_RECORD_DATALEN; | 234 | rd.data_size = TEST_RECORD_DATALEN; |
@@ -253,8 +240,13 @@ run (void *cls, | |||
253 | nch = GNUNET_NAMECACHE_connect (cfg); | 240 | nch = GNUNET_NAMECACHE_connect (cfg); |
254 | GNUNET_break (NULL != nsh); | 241 | GNUNET_break (NULL != nsh); |
255 | GNUNET_break (NULL != nch); | 242 | GNUNET_break (NULL != nch); |
256 | nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, | 243 | nsqe = GNUNET_NAMESTORE_records_store (nsh, |
257 | 1, &rd, &put_cont, (void *) name); | 244 | privkey, |
245 | name, | ||
246 | 1, | ||
247 | &rd, | ||
248 | &put_cont, | ||
249 | (void *) name); | ||
258 | if (NULL == nsqe) | 250 | if (NULL == nsqe) |
259 | { | 251 | { |
260 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 252 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -274,6 +266,8 @@ main (int argc, char *argv[]) | |||
274 | GNUNET_asprintf (&cfg_name, | 266 | GNUNET_asprintf (&cfg_name, |
275 | "test_namestore_api_%s.conf", | 267 | "test_namestore_api_%s.conf", |
276 | plugin_name); | 268 | plugin_name); |
269 | GNUNET_DISK_purge_cfg_dir (cfg_name, | ||
270 | "GNUNET_TEST_HOME"); | ||
277 | res = 1; | 271 | res = 1; |
278 | if (0 != | 272 | if (0 != |
279 | GNUNET_TESTING_peer_run ("test-namestore-api-lookup-shadow", | 273 | GNUNET_TESTING_peer_run ("test-namestore-api-lookup-shadow", |
@@ -283,12 +277,9 @@ main (int argc, char *argv[]) | |||
283 | { | 277 | { |
284 | res = 1; | 278 | res = 1; |
285 | } | 279 | } |
280 | GNUNET_DISK_purge_cfg_dir (cfg_name, | ||
281 | "GNUNET_TEST_HOME"); | ||
286 | GNUNET_free (cfg_name); | 282 | GNUNET_free (cfg_name); |
287 | if (NULL != directory) | ||
288 | { | ||
289 | GNUNET_DISK_directory_remove (directory); | ||
290 | GNUNET_free (directory); | ||
291 | } | ||
292 | return res; | 283 | return res; |
293 | } | 284 | } |
294 | 285 | ||