aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_namestore_api_zone_iteration_stop.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-09-11 08:37:48 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-09-11 08:37:48 +0000
commitbe3a58fef06af2b80315ee27f11b4dc662ac4573 (patch)
tree4957a276ad1df74f8a73ae7d5081964e7c25dafa /src/namestore/test_namestore_api_zone_iteration_stop.c
parent55e1b1d34d49879097db64085a4ca0b9a5d9ffe9 (diff)
downloadgnunet-be3a58fef06af2b80315ee27f11b4dc662ac4573.tar.gz
gnunet-be3a58fef06af2b80315ee27f11b4dc662ac4573.zip
zone iteration stop
Diffstat (limited to 'src/namestore/test_namestore_api_zone_iteration_stop.c')
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_stop.c346
1 files changed, 181 insertions, 165 deletions
diff --git a/src/namestore/test_namestore_api_zone_iteration_stop.c b/src/namestore/test_namestore_api_zone_iteration_stop.c
index f4face314..7e67ae301 100644
--- a/src/namestore/test_namestore_api_zone_iteration_stop.c
+++ b/src/namestore/test_namestore_api_zone_iteration_stop.c
@@ -19,55 +19,40 @@
19*/ 19*/
20/** 20/**
21 * @file namestore/test_namestore_api_zone_iteration.c 21 * @file namestore/test_namestore_api_zone_iteration.c
22 * @brief testcase for zone iteration functionality: iterate of a specific zone 22 * @brief testcase for zone iteration functionality: stop iterating of zones
23 */ 23 */
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_common.h" 25#include "gnunet_common.h"
26#include "gnunet_testing_lib.h"
27#include "gnunet_namestore_service.h" 26#include "gnunet_namestore_service.h"
27#include "gnunet_testing_lib.h"
28#include "namestore.h" 28#include "namestore.h"
29 29
30 30
31#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 150) 31#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
32#define WAIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2)
32 33
33static struct GNUNET_NAMESTORE_Handle * nsh; 34static struct GNUNET_NAMESTORE_Handle * nsh;
34 35
35static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; 36static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
36 37
37static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task;
38
39static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 38static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
40 39
41static struct GNUNET_CRYPTO_EccPublicKey pubkey;
42
43static struct GNUNET_HashCode zone;
44
45static struct GNUNET_CRYPTO_EccPrivateKey * privkey2; 40static struct GNUNET_CRYPTO_EccPrivateKey * privkey2;
46 41
47static struct GNUNET_CRYPTO_EccPublicKey pubkey2;
48
49static struct GNUNET_HashCode zone2;
50
51static struct GNUNET_NAMESTORE_ZoneIterator *zi; 42static struct GNUNET_NAMESTORE_ZoneIterator *zi;
52 43
53static int res; 44static int res;
54 45
55static int returned_records; 46static int returned_records;
56 47
57static struct GNUNET_CRYPTO_EccSignature *sig_1;
58
59static char * s_name_1; 48static char * s_name_1;
60 49
61static struct GNUNET_NAMESTORE_RecordData *s_rd_1; 50static struct GNUNET_NAMESTORE_RecordData *s_rd_1;
62 51
63static struct GNUNET_CRYPTO_EccSignature *sig_2;
64
65static char * s_name_2; 52static char * s_name_2;
66 53
67static struct GNUNET_NAMESTORE_RecordData *s_rd_2; 54static struct GNUNET_NAMESTORE_RecordData *s_rd_2;
68 55
69static struct GNUNET_CRYPTO_EccSignature *sig_3;
70
71static char * s_name_3; 56static char * s_name_3;
72 57
73static struct GNUNET_NAMESTORE_RecordData *s_rd_3; 58static struct GNUNET_NAMESTORE_RecordData *s_rd_3;
@@ -82,20 +67,20 @@ static struct GNUNET_NAMESTORE_RecordData *s_rd_3;
82static void 67static void
83endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 68endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
84{ 69{
85 if (stopiteration_task != GNUNET_SCHEDULER_NO_TASK) 70 if (NULL != zi)
86 { 71 {
87 GNUNET_SCHEDULER_cancel (stopiteration_task); 72 GNUNET_NAMESTORE_zone_iteration_stop (zi);
88 stopiteration_task = GNUNET_SCHEDULER_NO_TASK; 73 zi = NULL;
89 } 74 }
75
90 if (nsh != NULL) 76 if (nsh != NULL)
91 GNUNET_NAMESTORE_disconnect (nsh); 77 GNUNET_NAMESTORE_disconnect (nsh);
92 nsh = NULL; 78 nsh = NULL;
93 GNUNET_free_non_null(sig_1); 79
94 GNUNET_free_non_null(sig_2);
95 GNUNET_free_non_null(sig_3);
96 GNUNET_free_non_null(s_name_1); 80 GNUNET_free_non_null(s_name_1);
97 GNUNET_free_non_null(s_name_2); 81 GNUNET_free_non_null(s_name_2);
98 GNUNET_free_non_null(s_name_3); 82 GNUNET_free_non_null(s_name_3);
83
99 if (s_rd_1 != NULL) 84 if (s_rd_1 != NULL)
100 { 85 {
101 GNUNET_free ((void *)s_rd_1->data); 86 GNUNET_free ((void *)s_rd_1->data);
@@ -111,6 +96,7 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
111 GNUNET_free ((void *)s_rd_3->data); 96 GNUNET_free ((void *)s_rd_3->data);
112 GNUNET_free (s_rd_3); 97 GNUNET_free (s_rd_3);
113 } 98 }
99
114 if (privkey != NULL) 100 if (privkey != NULL)
115 GNUNET_free (privkey); 101 GNUNET_free (privkey);
116 privkey = NULL; 102 privkey = NULL;
@@ -125,27 +111,26 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
125static void 111static void
126end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 112end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
127{ 113{
128 if (stopiteration_task != GNUNET_SCHEDULER_NO_TASK) 114 if (NULL != zi)
129 { 115 {
130 GNUNET_SCHEDULER_cancel (stopiteration_task); 116 GNUNET_NAMESTORE_zone_iteration_stop (zi);
131 stopiteration_task = GNUNET_SCHEDULER_NO_TASK; 117 zi = NULL;
132 } 118 }
133 119
134 if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) 120 if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
135 { 121 {
136 GNUNET_SCHEDULER_cancel (endbadly_task); 122 GNUNET_SCHEDULER_cancel (endbadly_task);
137 endbadly_task = GNUNET_SCHEDULER_NO_TASK; 123 endbadly_task = GNUNET_SCHEDULER_NO_TASK;
138 } 124 }
125
139 if (privkey != NULL) 126 if (privkey != NULL)
140 GNUNET_free (privkey); 127 GNUNET_free (privkey);
141 privkey = NULL; 128 privkey = NULL;
129
142 if (privkey2 != NULL) 130 if (privkey2 != NULL)
143 GNUNET_free (privkey2); 131 GNUNET_free (privkey2);
144 privkey2 = NULL; 132 privkey2 = NULL;
145 133
146 GNUNET_free (sig_1);
147 GNUNET_free (sig_2);
148 GNUNET_free (sig_3);
149 GNUNET_free (s_name_1); 134 GNUNET_free (s_name_1);
150 GNUNET_free (s_name_2); 135 GNUNET_free (s_name_2);
151 GNUNET_free (s_name_3); 136 GNUNET_free (s_name_3);
@@ -167,147 +152,139 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
167 if (nsh != NULL) 152 if (nsh != NULL)
168 GNUNET_NAMESTORE_disconnect (nsh); 153 GNUNET_NAMESTORE_disconnect (nsh);
169 nsh = NULL; 154 nsh = NULL;
170 if (returned_records == 1)
171 res = 0;
172 else
173 res = 1;
174
175} 155}
176 156
177 157
178static void 158static void
179zone_proc (void *cls, 159zone_proc (void *cls,
180 const struct GNUNET_CRYPTO_EccPublicKey *zone_key, 160 const struct GNUNET_CRYPTO_EccPrivateKey *zone,
181 struct GNUNET_TIME_Absolute expire, 161 const char *label,
182 const char *name, 162 unsigned int rd_count,
183 unsigned int rd_count, 163 const struct GNUNET_NAMESTORE_RecordData *rd)
184 const struct GNUNET_NAMESTORE_RecordData *rd,
185 const struct GNUNET_CRYPTO_EccSignature *signature)
186{ 164{
187 int failed = GNUNET_NO; 165 int failed = GNUNET_NO;
188 166 if ((zone == NULL) && (label == NULL))
189 if ((zone_key == NULL) && (name == NULL))
190 { 167 {
191 GNUNET_break (3 == returned_records); 168 GNUNET_break (1 <= returned_records);
192 if (3 == returned_records) 169 if (1 >= returned_records)
193 res = 0; 170 res = 1; /* Last iteraterator callback, we are done */
194 else 171 else
195 res = 1; 172 res = 0;
196 173 zi = NULL;
197 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received last result, iteration done after receing %u results\n",returned_records ); 174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
175 "Received last result, iteration done after receing %u results\n",
176 returned_records );
198 GNUNET_SCHEDULER_add_now (&end, NULL); 177 GNUNET_SCHEDULER_add_now (&end, NULL);
178 return;
199 } 179 }
200 else 180 else
201 { 181 {
202 182 if (0 == memcmp (zone, privkey, sizeof (struct GNUNET_CRYPTO_EccPrivateKey)))
203 /* verify signature returned from name store */ 183 {
204 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(zone_key, expire, name, rd_count, rd, signature)) 184 if (0 == strcmp (label, s_name_1))
205 {
206 failed = GNUNET_YES;
207 GNUNET_break (0);
208 }
209
210
211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Comparing results name %s \n", name);
212 if (0 == strcmp (name, s_name_1))
213 { /* name_1 */
214 if (rd_count == 1)
215 { 185 {
216 if (GNUNET_YES != GNUNET_NAMESTORE_records_cmp(rd, s_rd_1)) 186 if (rd_count == 1)
187 {
188 if (GNUNET_YES != GNUNET_NAMESTORE_records_cmp(rd, s_rd_1))
189 {
190 failed = GNUNET_YES;
191 GNUNET_break (0);
192 }
193 }
194 else
217 { 195 {
218 failed = GNUNET_YES; 196 failed = GNUNET_YES;
219 GNUNET_break (0); 197 GNUNET_break (0);
220 } 198 }
221 } 199 }
222 else 200 else if (0 == strcmp (label, s_name_2))
223 {
224 failed = GNUNET_YES;
225 GNUNET_break (0);
226 }
227 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, s_name_1, 1, s_rd_1, signature))
228 {
229 failed = GNUNET_YES;
230 GNUNET_break (0);
231 }
232 }
233 else if (0 == strcmp (name, s_name_2))
234 { /* name_2 */
235 if (rd_count == 1)
236 { 201 {
237 if (GNUNET_YES != GNUNET_NAMESTORE_records_cmp(rd, s_rd_2)) 202 if (rd_count == 1)
203 {
204 if (GNUNET_YES != GNUNET_NAMESTORE_records_cmp(rd, s_rd_2))
205 {
206 failed = GNUNET_YES;
207 GNUNET_break (0);
208 }
209 }
210 else
238 { 211 {
212 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
213 "Received invalid record count\n");
239 failed = GNUNET_YES; 214 failed = GNUNET_YES;
240 GNUNET_break (0); 215 GNUNET_break (0);
241 } 216 }
242 } 217 }
243 else 218 else
244 { 219 {
220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
221 "Comparing result failed: got name `%s' for first zone\n", label);
245 failed = GNUNET_YES; 222 failed = GNUNET_YES;
246 GNUNET_break (0); 223 GNUNET_break (0);
247 } 224 }
248 225 }
249 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, s_name_2, 1, s_rd_2, signature)) 226 else if (0 == memcmp (zone, privkey2, sizeof (struct GNUNET_CRYPTO_EccPrivateKey)))
227 {
228 if (0 == strcmp (label, s_name_3))
250 { 229 {
251 failed = GNUNET_YES; 230 if (rd_count == 1)
252 GNUNET_break (0); 231 {
253 } 232 if (GNUNET_YES != GNUNET_NAMESTORE_records_cmp(rd, s_rd_3))
254 } 233 {
255 else if (0 == strcmp (name, s_name_3)) 234 failed = GNUNET_YES;
256 { /* name_3 */ 235 GNUNET_break (0);
257 if (rd_count == 1) 236 }
258 { 237 }
259 if (GNUNET_YES != GNUNET_NAMESTORE_records_cmp(rd, s_rd_3)) 238 else
260 { 239 {
240 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
241 "Received invalid record count\n");
261 failed = GNUNET_YES; 242 failed = GNUNET_YES;
262 GNUNET_break (0); 243 GNUNET_break (0);
263 } 244 }
264 } 245 }
265 else 246 else
266 { 247 {
248 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
249 "Comparing result failed: got name `%s' for first zone\n", label);
267 failed = GNUNET_YES; 250 failed = GNUNET_YES;
268 GNUNET_break (0); 251 GNUNET_break (0);
269 } 252 }
270 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey2, expire, s_name_3, 1, s_rd_3, signature)) 253 }
271 { 254 else
272 failed = GNUNET_YES; 255 {
273 GNUNET_break (0); 256 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Received invalid zone\n");
274 } 257 failed = GNUNET_YES;
275 }
276 else
277 {
278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Comparing result failed: got name `%s'\n", name);
279 res = 1;
280 GNUNET_break (0); 258 GNUNET_break (0);
281 GNUNET_SCHEDULER_add_now (&end, NULL); 259 }
282 } 260 }
283
284 if (failed == GNUNET_NO)
285 {
286 returned_records ++;
287 261
288 if (1 == returned_records) 262 if (failed == GNUNET_NO)
289 { 263 {
290 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping zone iteration after %u received record \n",returned_records ); 264 if (1 == returned_records)
291 GNUNET_NAMESTORE_zone_iteration_stop (zi); 265 {
292 if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) 266 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
293 { 267 "Telling namestore to stop zone iteration\n");
294 GNUNET_SCHEDULER_cancel (endbadly_task); 268 GNUNET_NAMESTORE_zone_iteration_stop (zi);
295 endbadly_task = GNUNET_SCHEDULER_NO_TASK; 269 zi = NULL;
296 } 270 if (GNUNET_SCHEDULER_NO_TASK != endbadly_task)
297 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3), &end , NULL);
298 return;
299 }
300 else
301 { 271 {
302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Telling namestore to send the next result\n"); 272 GNUNET_SCHEDULER_cancel (endbadly_task);
303 GNUNET_NAMESTORE_zone_iterator_next (zi); 273 endbadly_task = GNUNET_SCHEDULER_NO_TASK;
304 } 274 }
305 } 275 res = 0;
306 else 276 GNUNET_SCHEDULER_add_delayed (WAIT, &end, NULL);
307 { 277 return;
308 GNUNET_break (0); 278 }
309 GNUNET_SCHEDULER_add_now (&end, NULL); 279 returned_records ++;
310 } 280 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
281 "Telling namestore to send the next result\n");
282 GNUNET_NAMESTORE_zone_iterator_next (zi);
283 }
284 else
285 {
286 GNUNET_break (0);
287 GNUNET_SCHEDULER_add_now (&end, NULL);
311 } 288 }
312} 289}
313 290
@@ -324,10 +301,13 @@ put_cont (void *cls, int32_t success, const char *emsg)
324 } 301 }
325 else 302 else
326 { 303 {
327 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records\n"); 304 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records: `%s'\n",
305 emsg);
328 GNUNET_break (0); 306 GNUNET_break (0);
329 GNUNET_SCHEDULER_cancel (endbadly_task); 307 if (GNUNET_SCHEDULER_NO_TASK != endbadly_task)
308 GNUNET_SCHEDULER_cancel (endbadly_task);
330 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); 309 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
310 return;
331 } 311 }
332 312
333 if (c == 3) 313 if (c == 3)
@@ -336,17 +316,17 @@ put_cont (void *cls, int32_t success, const char *emsg)
336 returned_records = 0; 316 returned_records = 0;
337 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n"); 317 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n");
338 zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, 318 zi = GNUNET_NAMESTORE_zone_iteration_start(nsh,
339 NULL, 319 NULL,
340 GNUNET_NAMESTORE_RF_NONE, 320 &zone_proc,
341 GNUNET_NAMESTORE_RF_NONE, 321 NULL);
342 zone_proc,
343 &zone);
344 if (zi == NULL) 322 if (zi == NULL)
345 { 323 {
346 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); 324 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n");
347 GNUNET_break (0); 325 GNUNET_break (0);
348 GNUNET_SCHEDULER_cancel (endbadly_task); 326 if (GNUNET_SCHEDULER_NO_TASK != endbadly_task)
327 GNUNET_SCHEDULER_cancel (endbadly_task);
349 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); 328 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
329 return;
350 } 330 }
351 } 331 }
352} 332}
@@ -371,23 +351,50 @@ create_record (unsigned int count)
371} 351}
372 352
373 353
354/**
355 * Callback called from the zone iterator when we iterate over
356 * the empty zone. Check that we got no records and then
357 * start the actual tests by filling the zone.
358 */
374static void 359static void
375run (void *cls, 360empty_zone_proc (void *cls,
376 const struct GNUNET_CONFIGURATION_Handle *cfg, 361 const struct GNUNET_CRYPTO_EccPrivateKey *zone,
377 struct GNUNET_TESTING_Peer *peer) 362 const char *label,
363 unsigned int rd_count,
364 const struct GNUNET_NAMESTORE_RecordData *rd)
378{ 365{
379 char *hostkey_file; 366 char *hostkey_file;
380 struct GNUNET_TIME_Absolute et;
381 367
382 endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL); 368 GNUNET_assert (nsh == cls);
369 if (NULL != zone)
370 {
371 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
372 _("Expected empty zone but received zone private key\n"));
373 GNUNET_break (0);
374 if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
375 GNUNET_SCHEDULER_cancel (endbadly_task);
376 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
377 return;
378 }
379 if ((NULL != label) || (NULL != rd) || (0 != rd))
380 {
381 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
382 _("Expected no zone content but received data\n"));
383 GNUNET_break (0);
384 if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
385 GNUNET_SCHEDULER_cancel (endbadly_task);
386 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
387 return;
388 }
389
390
391 zi = NULL;
383 GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, 392 GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
384 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); 393 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
385 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); 394 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file);
386 privkey = GNUNET_CRYPTO_ecc_key_create_from_file(hostkey_file); 395 privkey = GNUNET_CRYPTO_ecc_key_create_from_file(hostkey_file);
387 GNUNET_free (hostkey_file); 396 GNUNET_free (hostkey_file);
388 GNUNET_assert (privkey != NULL); 397 GNUNET_assert (privkey != NULL);
389 GNUNET_CRYPTO_ecc_key_get_public(privkey, &pubkey);
390 GNUNET_CRYPTO_hash(&pubkey, sizeof (pubkey), &zone);
391 398
392 GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, 399 GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
393 "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"); 400 "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey");
@@ -395,38 +402,48 @@ run (void *cls,
395 privkey2 = GNUNET_CRYPTO_ecc_key_create_from_file(hostkey_file); 402 privkey2 = GNUNET_CRYPTO_ecc_key_create_from_file(hostkey_file);
396 GNUNET_free (hostkey_file); 403 GNUNET_free (hostkey_file);
397 GNUNET_assert (privkey2 != NULL); 404 GNUNET_assert (privkey2 != NULL);
398 GNUNET_CRYPTO_ecc_key_get_public(privkey2, &pubkey2);
399 GNUNET_CRYPTO_hash(&pubkey2, sizeof (pubkey), &zone2);
400
401 nsh = GNUNET_NAMESTORE_connect (cfg);
402 GNUNET_break (NULL != nsh);
403 405
404 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); 406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n");
405 407
406 GNUNET_asprintf(&s_name_1, "dummy1"); 408 GNUNET_asprintf(&s_name_1, "dummy1");
407 s_rd_1 = create_record(1); 409 s_rd_1 = create_record(1);
408 et.abs_value_us = s_rd_1[0].expiration_time; 410 GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1,
409 sig_1 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_1, s_rd_1, 1); 411 1, s_rd_1, &put_cont, NULL);
410 GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name_1,
411 1, s_rd_1, &put_cont, NULL);
412
413 412
414 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); 413 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n");
415 GNUNET_asprintf(&s_name_2, "dummy2"); 414 GNUNET_asprintf(&s_name_2, "dummy2");
416 s_rd_2 = create_record(1); 415 s_rd_2 = create_record(1);
417 416 GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_2,
418 et.abs_value_us = s_rd_2[0].expiration_time; 417 1, s_rd_2, &put_cont, NULL);
419 sig_2 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_2, s_rd_2, 1);
420 GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name_2,
421 1, s_rd_2, &put_cont, NULL);
422 418
423 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n"); 419 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n");
420
424 /* name in different zone */ 421 /* name in different zone */
425 GNUNET_asprintf(&s_name_3, "dummy3"); 422 GNUNET_asprintf(&s_name_3, "dummy3");
426 s_rd_3 = create_record(1); 423 s_rd_3 = create_record(1);
427 et.abs_value_us = s_rd_3[0].expiration_time; 424 GNUNET_NAMESTORE_records_store(nsh, privkey2, s_name_3,
428 sig_3 = GNUNET_NAMESTORE_create_signature(privkey2, et, s_name_3, s_rd_3, 1); 425 1, s_rd_3, &put_cont, NULL);
429 GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL); 426}
427
428
429static void
430run (void *cls,
431 const struct GNUNET_CONFIGURATION_Handle *cfg,
432 struct GNUNET_TESTING_Peer *peer)
433{
434 endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, &endbadly, NULL);
435 nsh = GNUNET_NAMESTORE_connect (cfg);
436 GNUNET_break (NULL != nsh);
437 /* first, iterate over empty namestore */
438 zi = GNUNET_NAMESTORE_zone_iteration_start(nsh,
439 NULL, &empty_zone_proc, nsh);
440 if (NULL == zi)
441 {
442 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n");
443 GNUNET_break (0);
444 GNUNET_SCHEDULER_cancel (endbadly_task);
445 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
446 }
430} 447}
431 448
432 449
@@ -444,5 +461,4 @@ main (int argc, char *argv[])
444 return res; 461 return res;
445} 462}
446 463
447
448/* end of test_namestore_api_zone_iteration_stop.c */ 464/* end of test_namestore_api_zone_iteration_stop.c */