diff options
Diffstat (limited to 'src/namestore/test_namestore_api_lookup_private.c')
-rw-r--r-- | src/namestore/test_namestore_api_lookup_private.c | 73 |
1 files changed, 33 insertions, 40 deletions
diff --git a/src/namestore/test_namestore_api_lookup_private.c b/src/namestore/test_namestore_api_lookup_private.c index 7866749f1..024adaa43 100644 --- a/src/namestore/test_namestore_api_lookup_private.c +++ b/src/namestore/test_namestore_api_lookup_private.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 | ||
@@ -48,7 +47,6 @@ static struct GNUNET_NAMESTORE_QueueEntry *nsqe; | |||
48 | //static const char * name = "dummy.dummy.gnunet"; | 47 | //static const char * name = "dummy.dummy.gnunet"; |
49 | static const char * name = "d"; | 48 | static const char * name = "d"; |
50 | 49 | ||
51 | static char *directory; | ||
52 | 50 | ||
53 | static void | 51 | static void |
54 | cleanup () | 52 | cleanup () |
@@ -71,11 +69,11 @@ cleanup () | |||
71 | * Re-establish the connection to the service. | 69 | * Re-establish the connection to the service. |
72 | * | 70 | * |
73 | * @param cls handle to use to re-connect. | 71 | * @param cls handle to use to re-connect. |
74 | * @param tc scheduler context | ||
75 | */ | 72 | */ |
76 | static void | 73 | static void |
77 | endbadly (void *cls) | 74 | endbadly (void *cls) |
78 | { | 75 | { |
76 | endbadly_task = NULL; | ||
79 | if (NULL != nsqe) | 77 | if (NULL != nsqe) |
80 | { | 78 | { |
81 | GNUNET_NAMESTORE_cancel (nsqe); | 79 | GNUNET_NAMESTORE_cancel (nsqe); |
@@ -109,7 +107,7 @@ lookup_it (void *cls, | |||
109 | { | 107 | { |
110 | GNUNET_break(0); | 108 | GNUNET_break(0); |
111 | GNUNET_SCHEDULER_cancel (endbadly_task); | 109 | GNUNET_SCHEDULER_cancel (endbadly_task); |
112 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL ); | 110 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
113 | return; | 111 | return; |
114 | } | 112 | } |
115 | 113 | ||
@@ -118,7 +116,7 @@ lookup_it (void *cls, | |||
118 | { | 116 | { |
119 | GNUNET_break(0); | 117 | GNUNET_break(0); |
120 | GNUNET_SCHEDULER_cancel (endbadly_task); | 118 | GNUNET_SCHEDULER_cancel (endbadly_task); |
121 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL ); | 119 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
122 | return; | 120 | return; |
123 | } | 121 | } |
124 | 122 | ||
@@ -126,7 +124,7 @@ lookup_it (void *cls, | |||
126 | { | 124 | { |
127 | GNUNET_break(0); | 125 | GNUNET_break(0); |
128 | GNUNET_SCHEDULER_cancel (endbadly_task); | 126 | GNUNET_SCHEDULER_cancel (endbadly_task); |
129 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL ); | 127 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
130 | return; | 128 | return; |
131 | } | 129 | } |
132 | 130 | ||
@@ -134,14 +132,14 @@ lookup_it (void *cls, | |||
134 | { | 132 | { |
135 | GNUNET_break(0); | 133 | GNUNET_break(0); |
136 | GNUNET_SCHEDULER_cancel (endbadly_task); | 134 | GNUNET_SCHEDULER_cancel (endbadly_task); |
137 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL ); | 135 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
138 | return; | 136 | return; |
139 | } | 137 | } |
140 | 138 | ||
141 | /* Done */ | 139 | /* Done */ |
142 | GNUNET_SCHEDULER_cancel (endbadly_task); | 140 | GNUNET_SCHEDULER_cancel (endbadly_task); |
143 | endbadly_task = NULL; | 141 | endbadly_task = NULL; |
144 | GNUNET_SCHEDULER_add_now (&end, NULL ); | 142 | GNUNET_SCHEDULER_add_now (&end, NULL); |
145 | } | 143 | } |
146 | 144 | ||
147 | 145 | ||
@@ -153,7 +151,9 @@ fail_cb (void *cls) | |||
153 | 151 | ||
154 | 152 | ||
155 | static void | 153 | static void |
156 | put_cont (void *cls, int32_t success, const char *emsg) | 154 | put_cont (void *cls, |
155 | int32_t success, | ||
156 | const char *emsg) | ||
157 | { | 157 | { |
158 | const char *name = cls; | 158 | const char *name = cls; |
159 | 159 | ||
@@ -187,22 +187,11 @@ run (void *cls, | |||
187 | struct GNUNET_TESTING_Peer *peer) | 187 | struct GNUNET_TESTING_Peer *peer) |
188 | { | 188 | { |
189 | struct GNUNET_GNSRECORD_Data rd; | 189 | struct GNUNET_GNSRECORD_Data rd; |
190 | char *hostkey_file; | ||
191 | |||
192 | directory = NULL; | ||
193 | GNUNET_assert (GNUNET_OK == | ||
194 | GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "GNUNET_TEST_HOME", &directory)); | ||
195 | GNUNET_DISK_directory_remove (directory); | ||
196 | 190 | ||
197 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 191 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
198 | &endbadly, NULL); | 192 | &endbadly, |
199 | GNUNET_asprintf (&hostkey_file, | 193 | NULL); |
200 | "zonefiles%s%s", | 194 | privkey = GNUNET_CRYPTO_ecdsa_key_create (); |
201 | DIR_SEPARATOR_STR, | ||
202 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | ||
203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | ||
204 | privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file); | ||
205 | GNUNET_free (hostkey_file); | ||
206 | GNUNET_assert (privkey != NULL); | 195 | GNUNET_assert (privkey != NULL); |
207 | GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey); | 196 | GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey); |
208 | 197 | ||
@@ -215,8 +204,13 @@ run (void *cls, | |||
215 | 204 | ||
216 | nsh = GNUNET_NAMESTORE_connect (cfg); | 205 | nsh = GNUNET_NAMESTORE_connect (cfg); |
217 | GNUNET_break (NULL != nsh); | 206 | GNUNET_break (NULL != nsh); |
218 | nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, | 207 | nsqe = GNUNET_NAMESTORE_records_store (nsh, |
219 | 1, &rd, &put_cont, (void *) name); | 208 | privkey, |
209 | name, | ||
210 | 1, | ||
211 | &rd, | ||
212 | &put_cont, | ||
213 | (void *) name); | ||
220 | if (NULL == nsqe) | 214 | if (NULL == nsqe) |
221 | { | 215 | { |
222 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 216 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -237,6 +231,8 @@ main (int argc, char *argv[]) | |||
237 | GNUNET_asprintf (&cfg_name, | 231 | GNUNET_asprintf (&cfg_name, |
238 | "test_namestore_api_%s.conf", | 232 | "test_namestore_api_%s.conf", |
239 | plugin_name); | 233 | plugin_name); |
234 | GNUNET_DISK_purge_cfg_dir (cfg_name, | ||
235 | "GNUNET_TEST_HOME"); | ||
240 | res = 1; | 236 | res = 1; |
241 | if (0 != | 237 | if (0 != |
242 | GNUNET_TESTING_peer_run ("test-namestore-api-lookup-private", | 238 | GNUNET_TESTING_peer_run ("test-namestore-api-lookup-private", |
@@ -246,12 +242,9 @@ main (int argc, char *argv[]) | |||
246 | { | 242 | { |
247 | res = 1; | 243 | res = 1; |
248 | } | 244 | } |
245 | GNUNET_DISK_purge_cfg_dir (cfg_name, | ||
246 | "GNUNET_TEST_HOME"); | ||
249 | GNUNET_free (cfg_name); | 247 | GNUNET_free (cfg_name); |
250 | if (NULL != directory) | ||
251 | { | ||
252 | GNUNET_DISK_directory_remove (directory); | ||
253 | GNUNET_free (directory); | ||
254 | } | ||
255 | return res; | 248 | return res; |
256 | } | 249 | } |
257 | 250 | ||