diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-09-11 08:00:45 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-09-11 08:00:45 +0000 |
commit | f3c214f61e5654b742b3ea1ea3f49f67d4289301 (patch) | |
tree | b5d0684b56c1bd976d8f85e1b7cbd64c8c029e85 | |
parent | 345b0a071a510ed7841be6a3a1093234ea252799 (diff) | |
download | gnunet-f3c214f61e5654b742b3ea1ea3f49f67d4289301.tar.gz gnunet-f3c214f61e5654b742b3ea1ea3f49f67d4289301.zip |
updated zone iteration test
-rw-r--r-- | src/namestore/Makefile.am | 5 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_zone_iteration.c | 264 |
2 files changed, 128 insertions, 141 deletions
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index 6a3ce7da9..837bb5a39 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am | |||
@@ -43,14 +43,15 @@ if HAVE_TESTING | |||
43 | TESTING_TESTS = \ | 43 | TESTING_TESTS = \ |
44 | test_namestore_api_store \ | 44 | test_namestore_api_store \ |
45 | test_namestore_api_remove \ | 45 | test_namestore_api_remove \ |
46 | test_namestore_api_lookup | 46 | test_namestore_api_zone_iteration |
47 | # test_namestore_api_lookup | ||
47 | #test_namestore_api_lookup_specific_type | 48 | #test_namestore_api_lookup_specific_type |
48 | #test_namestore_api_create | 49 | #test_namestore_api_create |
49 | #test_namestore_api_create_update | 50 | #test_namestore_api_create_update |
50 | #test_namestore_api_remove_not_existing_record | 51 | #test_namestore_api_remove_not_existing_record |
51 | #test_namestore_api_zone_to_name | 52 | #test_namestore_api_zone_to_name |
52 | #test_namestore_api_monitoring | 53 | #test_namestore_api_monitoring |
53 | #test_namestore_api_zone_iteration | 54 | |
54 | #test_namestore_api_zone_iteration_specific_zone | 55 | #test_namestore_api_zone_iteration_specific_zone |
55 | #test_namestore_api_zone_iteration_stop | 56 | #test_namestore_api_zone_iteration_stop |
56 | endif | 57 | endif |
diff --git a/src/namestore/test_namestore_api_zone_iteration.c b/src/namestore/test_namestore_api_zone_iteration.c index 94515510a..c03ea7cb8 100644 --- a/src/namestore/test_namestore_api_zone_iteration.c +++ b/src/namestore/test_namestore_api_zone_iteration.c | |||
@@ -35,40 +35,24 @@ static struct GNUNET_NAMESTORE_Handle * nsh; | |||
35 | 35 | ||
36 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 36 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
37 | 37 | ||
38 | static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task; | ||
39 | |||
40 | static struct GNUNET_CRYPTO_EccPrivateKey * privkey; | 38 | static struct GNUNET_CRYPTO_EccPrivateKey * privkey; |
41 | 39 | ||
42 | static struct GNUNET_CRYPTO_EccPublicKey pubkey; | ||
43 | |||
44 | static struct GNUNET_HashCode zone; | ||
45 | |||
46 | static struct GNUNET_CRYPTO_EccPrivateKey * privkey2; | 40 | static struct GNUNET_CRYPTO_EccPrivateKey * privkey2; |
47 | 41 | ||
48 | static struct GNUNET_CRYPTO_EccPublicKey pubkey2; | ||
49 | |||
50 | static struct GNUNET_HashCode zone2; | ||
51 | |||
52 | static struct GNUNET_NAMESTORE_ZoneIterator *zi; | 42 | static struct GNUNET_NAMESTORE_ZoneIterator *zi; |
53 | 43 | ||
54 | static int res; | 44 | static int res; |
55 | 45 | ||
56 | static int returned_records; | 46 | static int returned_records; |
57 | 47 | ||
58 | static struct GNUNET_CRYPTO_EccSignature *sig_1; | ||
59 | |||
60 | static char * s_name_1; | 48 | static char * s_name_1; |
61 | 49 | ||
62 | static struct GNUNET_NAMESTORE_RecordData *s_rd_1; | 50 | static struct GNUNET_NAMESTORE_RecordData *s_rd_1; |
63 | 51 | ||
64 | static struct GNUNET_CRYPTO_EccSignature *sig_2; | ||
65 | |||
66 | static char * s_name_2; | 52 | static char * s_name_2; |
67 | 53 | ||
68 | static struct GNUNET_NAMESTORE_RecordData *s_rd_2; | 54 | static struct GNUNET_NAMESTORE_RecordData *s_rd_2; |
69 | 55 | ||
70 | static struct GNUNET_CRYPTO_EccSignature *sig_3; | ||
71 | |||
72 | static char * s_name_3; | 56 | static char * s_name_3; |
73 | 57 | ||
74 | static struct GNUNET_NAMESTORE_RecordData *s_rd_3; | 58 | static struct GNUNET_NAMESTORE_RecordData *s_rd_3; |
@@ -83,19 +67,16 @@ static struct GNUNET_NAMESTORE_RecordData *s_rd_3; | |||
83 | static void | 67 | static void |
84 | endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 68 | endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
85 | { | 69 | { |
86 | if (stopiteration_task != GNUNET_SCHEDULER_NO_TASK) | 70 | if (NULL != zi) |
87 | { | 71 | { |
88 | GNUNET_SCHEDULER_cancel (stopiteration_task); | 72 | GNUNET_NAMESTORE_zone_iteration_stop (zi); |
89 | stopiteration_task = GNUNET_SCHEDULER_NO_TASK; | 73 | zi = NULL; |
90 | } | 74 | } |
91 | 75 | ||
92 | if (nsh != NULL) | 76 | if (nsh != NULL) |
93 | GNUNET_NAMESTORE_disconnect (nsh); | 77 | GNUNET_NAMESTORE_disconnect (nsh); |
94 | nsh = NULL; | 78 | nsh = NULL; |
95 | 79 | ||
96 | GNUNET_free_non_null(sig_1); | ||
97 | GNUNET_free_non_null(sig_2); | ||
98 | GNUNET_free_non_null(sig_3); | ||
99 | GNUNET_free_non_null(s_name_1); | 80 | GNUNET_free_non_null(s_name_1); |
100 | GNUNET_free_non_null(s_name_2); | 81 | GNUNET_free_non_null(s_name_2); |
101 | GNUNET_free_non_null(s_name_3); | 82 | GNUNET_free_non_null(s_name_3); |
@@ -130,11 +111,11 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
130 | static void | 111 | static void |
131 | end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 112 | end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
132 | { | 113 | { |
133 | if (stopiteration_task != GNUNET_SCHEDULER_NO_TASK) | 114 | if (NULL != zi) |
134 | { | 115 | { |
135 | GNUNET_SCHEDULER_cancel (stopiteration_task); | 116 | GNUNET_NAMESTORE_zone_iteration_stop (zi); |
136 | stopiteration_task = GNUNET_SCHEDULER_NO_TASK; | 117 | zi = NULL; |
137 | } | 118 | } |
138 | 119 | ||
139 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 120 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) |
140 | { | 121 | { |
@@ -150,9 +131,6 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
150 | GNUNET_free (privkey2); | 131 | GNUNET_free (privkey2); |
151 | privkey2 = NULL; | 132 | privkey2 = NULL; |
152 | 133 | ||
153 | GNUNET_free (sig_1); | ||
154 | GNUNET_free (sig_2); | ||
155 | GNUNET_free (sig_3); | ||
156 | GNUNET_free (s_name_1); | 134 | GNUNET_free (s_name_1); |
157 | GNUNET_free (s_name_2); | 135 | GNUNET_free (s_name_2); |
158 | GNUNET_free (s_name_3); | 136 | GNUNET_free (s_name_3); |
@@ -179,116 +157,122 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
179 | 157 | ||
180 | static void | 158 | static void |
181 | zone_proc (void *cls, | 159 | zone_proc (void *cls, |
182 | const struct GNUNET_CRYPTO_EccPublicKey *zone_key, | 160 | const struct GNUNET_CRYPTO_EccPrivateKey *zone, |
183 | struct GNUNET_TIME_Absolute expire, | 161 | const char *label, |
184 | const char *name, | 162 | unsigned int rd_count, |
185 | unsigned int rd_count, | 163 | const struct GNUNET_NAMESTORE_RecordData *rd) |
186 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
187 | const struct GNUNET_CRYPTO_EccSignature *signature) | ||
188 | { | 164 | { |
189 | int failed = GNUNET_NO; | 165 | int failed = GNUNET_NO; |
190 | if ((zone_key == NULL) && (name == NULL)) | 166 | if ((zone == NULL) && (label == NULL)) |
191 | { | 167 | { |
192 | GNUNET_break (3 == returned_records); | 168 | GNUNET_break (3 == returned_records); |
193 | if (3 == returned_records) | 169 | if (3 == returned_records) |
194 | res = 0; | 170 | { |
171 | res = 0; /* Last iteraterator callback, we are done */ | ||
172 | zi = NULL; | ||
173 | } | ||
195 | else | 174 | else |
196 | res = 1; | 175 | res = 1; |
197 | 176 | ||
198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 177 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
199 | "Received last result, iteration done after receing %u results\n", | 178 | "Received last result, iteration done after receing %u results\n", |
200 | returned_records ); | 179 | returned_records ); |
201 | GNUNET_SCHEDULER_add_now (&end, NULL); | 180 | GNUNET_SCHEDULER_add_now (&end, NULL); |
181 | return; | ||
202 | } | 182 | } |
203 | else | 183 | else |
204 | { | 184 | { |
205 | /* verify signature returned from name store */ | 185 | if (0 == memcmp (zone, privkey, sizeof (struct GNUNET_CRYPTO_EccPrivateKey))) |
206 | if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (zone_key, expire, name, rd_count, rd, signature)) | 186 | { |
207 | { | 187 | if (0 == strcmp (label, s_name_1)) |
208 | struct GNUNET_HashCode zone_key_hash; | ||
209 | GNUNET_CRYPTO_hash (zone_key, sizeof (struct GNUNET_CRYPTO_EccPublicKey), &zone_key_hash); | ||
210 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
211 | "Verifying signature for `%s' in zone `%s' with %u records and expiration %s failed\n", | ||
212 | name, GNUNET_h2s(&zone_key_hash), rd_count, | ||
213 | GNUNET_STRINGS_absolute_time_to_string (expire)); | ||
214 | |||
215 | failed = GNUNET_YES; | ||
216 | GNUNET_break (0); | ||
217 | } | ||
218 | |||
219 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Comparing results name %s \n", name); | ||
220 | if (0 == strcmp (name, s_name_1)) | ||
221 | { | ||
222 | if (rd_count == 1) | ||
223 | { | 188 | { |
224 | if (GNUNET_YES != GNUNET_NAMESTORE_records_cmp(rd, s_rd_1)) | 189 | if (rd_count == 1) |
190 | { | ||
191 | if (GNUNET_YES != GNUNET_NAMESTORE_records_cmp(rd, s_rd_1)) | ||
192 | { | ||
193 | failed = GNUNET_YES; | ||
194 | GNUNET_break (0); | ||
195 | } | ||
196 | } | ||
197 | else | ||
225 | { | 198 | { |
226 | failed = GNUNET_YES; | 199 | failed = GNUNET_YES; |
227 | GNUNET_break (0); | 200 | GNUNET_break (0); |
228 | } | 201 | } |
229 | } | 202 | } |
230 | else | 203 | else if (0 == strcmp (label, s_name_2)) |
231 | { | ||
232 | failed = GNUNET_YES; | ||
233 | GNUNET_break (0); | ||
234 | } | ||
235 | } | ||
236 | else if (0 == strcmp (name, s_name_2)) | ||
237 | { | ||
238 | if (rd_count == 1) | ||
239 | { | 204 | { |
240 | if (GNUNET_YES != GNUNET_NAMESTORE_records_cmp(rd, s_rd_2)) | 205 | if (rd_count == 1) |
206 | { | ||
207 | if (GNUNET_YES != GNUNET_NAMESTORE_records_cmp(rd, s_rd_2)) | ||
208 | { | ||
209 | failed = GNUNET_YES; | ||
210 | GNUNET_break (0); | ||
211 | } | ||
212 | } | ||
213 | else | ||
241 | { | 214 | { |
215 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
216 | "Received invalid record count\n"); | ||
242 | failed = GNUNET_YES; | 217 | failed = GNUNET_YES; |
243 | GNUNET_break (0); | 218 | GNUNET_break (0); |
244 | } | 219 | } |
245 | } | 220 | } |
246 | else | 221 | else |
247 | { | 222 | { |
223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
224 | "Comparing result failed: got name `%s' for first zone\n", label); | ||
248 | failed = GNUNET_YES; | 225 | failed = GNUNET_YES; |
249 | GNUNET_break (0); | 226 | GNUNET_break (0); |
250 | } | 227 | } |
251 | } | 228 | } |
252 | else if (0 == strcmp (name, s_name_3)) | 229 | else if (0 == memcmp (zone, privkey2, sizeof (struct GNUNET_CRYPTO_EccPrivateKey))) |
253 | { | 230 | { |
254 | if (rd_count == 1) | 231 | if (0 == strcmp (label, s_name_3)) |
255 | { | 232 | { |
256 | if (GNUNET_YES != GNUNET_NAMESTORE_records_cmp(rd, s_rd_3)) | 233 | if (rd_count == 1) |
234 | { | ||
235 | if (GNUNET_YES != GNUNET_NAMESTORE_records_cmp(rd, s_rd_3)) | ||
236 | { | ||
237 | failed = GNUNET_YES; | ||
238 | GNUNET_break (0); | ||
239 | } | ||
240 | } | ||
241 | else | ||
257 | { | 242 | { |
243 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
244 | "Received invalid record count\n"); | ||
258 | failed = GNUNET_YES; | 245 | failed = GNUNET_YES; |
259 | GNUNET_break (0); | 246 | GNUNET_break (0); |
260 | } | 247 | } |
261 | } | 248 | } |
262 | else | 249 | else |
263 | { | 250 | { |
251 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
252 | "Comparing result failed: got name `%s' for first zone\n", label); | ||
264 | failed = GNUNET_YES; | 253 | failed = GNUNET_YES; |
265 | GNUNET_break (0); | 254 | GNUNET_break (0); |
266 | } | 255 | } |
267 | if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(zone_key, expire, name, rd_count, rd, signature)) | 256 | } |
268 | { | 257 | else |
269 | failed = GNUNET_YES; | 258 | { |
270 | GNUNET_break (0); | 259 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Received invalid zone\n"); |
271 | } | 260 | failed = GNUNET_YES; |
272 | } | ||
273 | else | ||
274 | { | ||
275 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Comparing result failed: got name `%s'\n", name); | ||
276 | res = 1; | ||
277 | GNUNET_break (0); | 261 | GNUNET_break (0); |
278 | GNUNET_SCHEDULER_add_now (&end, NULL); | 262 | } |
279 | } | 263 | } |
280 | 264 | ||
281 | if (failed == GNUNET_NO) | 265 | if (failed == GNUNET_NO) |
282 | { | 266 | { |
283 | returned_records ++; | 267 | returned_records ++; |
284 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Telling namestore to send the next result\n"); | 268 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
285 | GNUNET_NAMESTORE_zone_iterator_next (zi); | 269 | "Telling namestore to send the next result\n"); |
286 | } | 270 | GNUNET_NAMESTORE_zone_iterator_next (zi); |
287 | else | 271 | } |
288 | { | 272 | else |
289 | GNUNET_break (0); | 273 | { |
290 | GNUNET_SCHEDULER_add_now (&end, NULL); | 274 | GNUNET_break (0); |
291 | } | 275 | GNUNET_SCHEDULER_add_now (&end, NULL); |
292 | } | 276 | } |
293 | } | 277 | } |
294 | 278 | ||
@@ -305,10 +289,13 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
305 | } | 289 | } |
306 | else | 290 | else |
307 | { | 291 | { |
308 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records\n"); | 292 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records: `%s'\n", |
293 | emsg); | ||
309 | GNUNET_break (0); | 294 | GNUNET_break (0); |
310 | GNUNET_SCHEDULER_cancel (endbadly_task); | 295 | if (GNUNET_SCHEDULER_NO_TASK != endbadly_task) |
296 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
311 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 297 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
298 | return; | ||
312 | } | 299 | } |
313 | 300 | ||
314 | if (c == 3) | 301 | if (c == 3) |
@@ -318,16 +305,16 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n"); | 305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n"); |
319 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, | 306 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, |
320 | NULL, | 307 | NULL, |
321 | GNUNET_NAMESTORE_RF_NONE, | ||
322 | GNUNET_NAMESTORE_RF_NONE, | ||
323 | &zone_proc, | 308 | &zone_proc, |
324 | &zone); | 309 | NULL); |
325 | if (zi == NULL) | 310 | if (zi == NULL) |
326 | { | 311 | { |
327 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); | 312 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); |
328 | GNUNET_break (0); | 313 | GNUNET_break (0); |
329 | GNUNET_SCHEDULER_cancel (endbadly_task); | 314 | if (GNUNET_SCHEDULER_NO_TASK != endbadly_task) |
315 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
330 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 316 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
317 | return; | ||
331 | } | 318 | } |
332 | } | 319 | } |
333 | } | 320 | } |
@@ -359,19 +346,36 @@ create_record (unsigned int count) | |||
359 | */ | 346 | */ |
360 | static void | 347 | static void |
361 | empty_zone_proc (void *cls, | 348 | empty_zone_proc (void *cls, |
362 | const struct GNUNET_CRYPTO_EccPublicKey *zone_key, | 349 | const struct GNUNET_CRYPTO_EccPrivateKey *zone, |
363 | struct GNUNET_TIME_Absolute expire, | 350 | const char *label, |
364 | const char *name, | ||
365 | unsigned int rd_count, | 351 | unsigned int rd_count, |
366 | const struct GNUNET_NAMESTORE_RecordData *rd, | 352 | const struct GNUNET_NAMESTORE_RecordData *rd) |
367 | const struct GNUNET_CRYPTO_EccSignature *signature) | ||
368 | { | 353 | { |
369 | char *hostkey_file; | 354 | char *hostkey_file; |
370 | struct GNUNET_TIME_Absolute et; | ||
371 | 355 | ||
372 | GNUNET_assert (nsh == cls); | 356 | GNUNET_assert (nsh == cls); |
373 | GNUNET_assert (NULL == name); | 357 | if (NULL != zone) |
374 | GNUNET_assert (NULL == zone_key); | 358 | { |
359 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
360 | _("Expected empty zone but received zone private key\n")); | ||
361 | GNUNET_break (0); | ||
362 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | ||
363 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
364 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | ||
365 | return; | ||
366 | } | ||
367 | if ((NULL != label) || (NULL != rd) || (0 != rd)) | ||
368 | { | ||
369 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
370 | _("Expected no zone content but received data\n")); | ||
371 | GNUNET_break (0); | ||
372 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | ||
373 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
374 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | ||
375 | return; | ||
376 | } | ||
377 | |||
378 | |||
375 | zi = NULL; | 379 | zi = NULL; |
376 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 380 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
377 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 381 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); |
@@ -379,48 +383,34 @@ empty_zone_proc (void *cls, | |||
379 | privkey = GNUNET_CRYPTO_ecc_key_create_from_file(hostkey_file); | 383 | privkey = GNUNET_CRYPTO_ecc_key_create_from_file(hostkey_file); |
380 | GNUNET_free (hostkey_file); | 384 | GNUNET_free (hostkey_file); |
381 | GNUNET_assert (privkey != NULL); | 385 | GNUNET_assert (privkey != NULL); |
382 | GNUNET_CRYPTO_ecc_key_get_public(privkey, &pubkey); | ||
383 | GNUNET_CRYPTO_hash(&pubkey, sizeof (pubkey), &zone); | ||
384 | |||
385 | 386 | ||
386 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 387 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
387 | "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"); | 388 | "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"); |
388 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 389 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); |
389 | privkey2 = GNUNET_CRYPTO_ecc_key_create_from_file(hostkey_file); | 390 | privkey2 = GNUNET_CRYPTO_ecc_key_create_from_file(hostkey_file); |
390 | GNUNET_free (hostkey_file); | 391 | GNUNET_free (hostkey_file); |
391 | |||
392 | GNUNET_assert (privkey2 != NULL); | 392 | GNUNET_assert (privkey2 != NULL); |
393 | GNUNET_CRYPTO_ecc_key_get_public(privkey2, &pubkey2); | ||
394 | GNUNET_CRYPTO_hash(&pubkey2, sizeof (pubkey), &zone2); | ||
395 | 393 | ||
396 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); | 394 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); |
397 | 395 | ||
398 | GNUNET_asprintf(&s_name_1, "dummy1"); | 396 | GNUNET_asprintf(&s_name_1, "dummy1"); |
399 | s_rd_1 = create_record(1); | 397 | s_rd_1 = create_record(1); |
400 | et.abs_value_us = s_rd_1->expiration_time; | 398 | GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, |
401 | sig_1 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_1, s_rd_1, 1); | 399 | 1, s_rd_1, &put_cont, NULL); |
402 | GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name_1, | ||
403 | 1, s_rd_1, | ||
404 | &put_cont, NULL); | ||
405 | |||
406 | 400 | ||
407 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); | 401 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); |
408 | GNUNET_asprintf(&s_name_2, "dummy2"); | 402 | GNUNET_asprintf(&s_name_2, "dummy2"); |
409 | s_rd_2 = create_record(1); | 403 | s_rd_2 = create_record(1); |
410 | 404 | GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_2, | |
411 | et.abs_value_us = s_rd_2->expiration_time; | 405 | 1, s_rd_2, &put_cont, NULL); |
412 | sig_2 = GNUNET_NAMESTORE_create_signature(privkey, et, s_name_2, s_rd_2, 1); | ||
413 | GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name_2, | ||
414 | 1, s_rd_2, | ||
415 | &put_cont, NULL); | ||
416 | 406 | ||
417 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n"); | 407 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n"); |
408 | |||
418 | /* name in different zone */ | 409 | /* name in different zone */ |
419 | GNUNET_asprintf(&s_name_3, "dummy3"); | 410 | GNUNET_asprintf(&s_name_3, "dummy3"); |
420 | s_rd_3 = create_record(1); | 411 | s_rd_3 = create_record(1); |
421 | et.abs_value_us = s_rd_3->expiration_time; | 412 | GNUNET_NAMESTORE_records_store(nsh, privkey2, s_name_3, |
422 | sig_3 = GNUNET_NAMESTORE_create_signature(privkey2, et, s_name_3, s_rd_3, 1); | 413 | 1, s_rd_3, &put_cont, NULL); |
423 | GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL); | ||
424 | } | 414 | } |
425 | 415 | ||
426 | 416 | ||
@@ -434,11 +424,7 @@ run (void *cls, | |||
434 | GNUNET_break (NULL != nsh); | 424 | GNUNET_break (NULL != nsh); |
435 | /* first, iterate over empty namestore */ | 425 | /* first, iterate over empty namestore */ |
436 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, | 426 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, |
437 | NULL, | 427 | NULL, &empty_zone_proc, nsh); |
438 | GNUNET_NAMESTORE_RF_NONE, | ||
439 | GNUNET_NAMESTORE_RF_NONE, | ||
440 | &empty_zone_proc, | ||
441 | nsh); | ||
442 | if (NULL == zi) | 428 | if (NULL == zi) |
443 | { | 429 | { |
444 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); | 430 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); |