diff options
Diffstat (limited to 'src/fs/test_fs_namespace.c')
-rw-r--r-- | src/fs/test_fs_namespace.c | 53 |
1 files changed, 12 insertions, 41 deletions
diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c index c720cb919..c8371f0b5 100644 --- a/src/fs/test_fs_namespace.c +++ b/src/fs/test_fs_namespace.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2005, 2006, 2008, 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2005-2013 Christian Grothoff (and other contributing authors) |
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 |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -29,7 +29,7 @@ | |||
29 | #include "gnunet_fs_service.h" | 29 | #include "gnunet_fs_service.h" |
30 | 30 | ||
31 | 31 | ||
32 | static struct GNUNET_FS_PseudonymIdentifier nsid; | 32 | static struct GNUNET_CRYPTO_EccPublicKey nsid; |
33 | 33 | ||
34 | static struct GNUNET_FS_Uri *sks_expect_uri; | 34 | static struct GNUNET_FS_Uri *sks_expect_uri; |
35 | 35 | ||
@@ -68,15 +68,10 @@ abort_ksk_search_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
68 | static void | 68 | static void |
69 | abort_sks_search_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 69 | abort_sks_search_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
70 | { | 70 | { |
71 | struct GNUNET_FS_Namespace *ns; | ||
72 | |||
73 | if (sks_search == NULL) | 71 | if (sks_search == NULL) |
74 | return; | 72 | return; |
75 | GNUNET_FS_search_stop (sks_search); | 73 | GNUNET_FS_search_stop (sks_search); |
76 | sks_search = NULL; | 74 | sks_search = NULL; |
77 | ns = GNUNET_FS_namespace_create (fs, "testNamespace"); | ||
78 | GNUNET_assert (NULL != ns); | ||
79 | GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (ns, GNUNET_YES)); | ||
80 | if (ksk_search == NULL) | 75 | if (ksk_search == NULL) |
81 | { | 76 | { |
82 | GNUNET_FS_stop (fs); | 77 | GNUNET_FS_stop (fs); |
@@ -242,7 +237,7 @@ static void | |||
242 | adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) | 237 | adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) |
243 | { | 238 | { |
244 | struct GNUNET_CONTAINER_MetaData *meta; | 239 | struct GNUNET_CONTAINER_MetaData *meta; |
245 | struct GNUNET_FS_Namespace *ns; | 240 | struct GNUNET_CRYPTO_EccPrivateKey *ns; |
246 | struct GNUNET_FS_BlockOptions bo; | 241 | struct GNUNET_FS_BlockOptions bo; |
247 | 242 | ||
248 | if (NULL != emsg) | 243 | if (NULL != emsg) |
@@ -252,57 +247,32 @@ adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) | |||
252 | GNUNET_FS_stop (fs); | 247 | GNUNET_FS_stop (fs); |
253 | return; | 248 | return; |
254 | } | 249 | } |
255 | ns = GNUNET_FS_namespace_create (fs, "testNamespace"); | 250 | ns = GNUNET_CRYPTO_ecc_key_create (); |
256 | GNUNET_assert (NULL != ns); | ||
257 | meta = GNUNET_CONTAINER_meta_data_create (); | 251 | meta = GNUNET_CONTAINER_meta_data_create (); |
258 | GNUNET_assert (NULL == emsg); | ||
259 | sks_expect_uri = GNUNET_FS_uri_dup (uri); | 252 | sks_expect_uri = GNUNET_FS_uri_dup (uri); |
260 | bo.content_priority = 1; | 253 | bo.content_priority = 1; |
261 | bo.anonymity_level = 1; | 254 | bo.anonymity_level = 1; |
262 | bo.replication_level = 0; | 255 | bo.replication_level = 0; |
263 | bo.expiration_time = | 256 | bo.expiration_time = |
264 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); | 257 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); |
258 | GNUNET_CRYPTO_ecc_key_get_public (ns, &nsid); | ||
265 | GNUNET_FS_publish_sks (fs, ns, "this", "next", meta, uri, | 259 | GNUNET_FS_publish_sks (fs, ns, "this", "next", meta, uri, |
266 | &bo, GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont, NULL); | 260 | &bo, GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont, NULL); |
267 | GNUNET_CONTAINER_meta_data_destroy (meta); | 261 | GNUNET_CONTAINER_meta_data_destroy (meta); |
268 | GNUNET_FS_namespace_delete (ns, GNUNET_NO); | 262 | GNUNET_CRYPTO_ecc_key_free (ns); |
269 | } | ||
270 | |||
271 | |||
272 | static void | ||
273 | ns_iterator (void *cls, const char *name, const struct GNUNET_FS_PseudonymIdentifier *id) | ||
274 | { | ||
275 | int *ok = cls; | ||
276 | |||
277 | if (0 != strcmp (name, "testNamespace")) | ||
278 | return; | ||
279 | *ok = GNUNET_YES; | ||
280 | nsid = *id; | ||
281 | } | 263 | } |
282 | 264 | ||
283 | 265 | ||
284 | static void | 266 | static void |
285 | testNamespace () | 267 | testNamespace () |
286 | { | 268 | { |
287 | struct GNUNET_FS_Namespace *ns; | 269 | struct GNUNET_CRYPTO_EccPrivateKey *ns; |
288 | struct GNUNET_FS_BlockOptions bo; | 270 | struct GNUNET_FS_BlockOptions bo; |
289 | struct GNUNET_CONTAINER_MetaData *meta; | 271 | struct GNUNET_CONTAINER_MetaData *meta; |
290 | struct GNUNET_FS_Uri *ksk_uri; | 272 | struct GNUNET_FS_Uri *ksk_uri; |
291 | struct GNUNET_FS_Uri *sks_uri; | 273 | struct GNUNET_FS_Uri *sks_uri; |
292 | int ok; | ||
293 | 274 | ||
294 | ns = GNUNET_FS_namespace_create (fs, "testNamespace"); | 275 | ns = GNUNET_CRYPTO_ecc_key_create (); |
295 | GNUNET_assert (NULL != ns); | ||
296 | ok = GNUNET_NO; | ||
297 | GNUNET_FS_namespace_list (fs, &ns_iterator, &ok); | ||
298 | if (GNUNET_NO == ok) | ||
299 | { | ||
300 | FPRINTF (stderr, "%s", "namespace_list failed to find namespace!\n"); | ||
301 | GNUNET_FS_namespace_delete (ns, GNUNET_YES); | ||
302 | GNUNET_FS_stop (fs); | ||
303 | err = 1; | ||
304 | return; | ||
305 | } | ||
306 | meta = GNUNET_CONTAINER_meta_data_create (); | 276 | meta = GNUNET_CONTAINER_meta_data_create (); |
307 | ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/testnsa", NULL); | 277 | ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/testnsa", NULL); |
308 | bo.content_priority = 1; | 278 | bo.content_priority = 1; |
@@ -310,17 +280,18 @@ testNamespace () | |||
310 | bo.replication_level = 0; | 280 | bo.replication_level = 0; |
311 | bo.expiration_time = | 281 | bo.expiration_time = |
312 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); | 282 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); |
313 | sks_uri = GNUNET_FS_uri_sks_create (ns, "root", NULL); | 283 | sks_uri = GNUNET_FS_uri_sks_create (&nsid, "root"); |
314 | GNUNET_FS_publish_ksk (fs, | 284 | GNUNET_FS_publish_ksk (fs, |
315 | ksk_uri, meta, sks_uri, &bo, GNUNET_FS_PUBLISH_OPTION_NONE, | 285 | ksk_uri, meta, sks_uri, |
286 | &bo, GNUNET_FS_PUBLISH_OPTION_NONE, | ||
316 | &adv_cont, NULL); | 287 | &adv_cont, NULL); |
317 | GNUNET_FS_uri_destroy (sks_uri); | 288 | GNUNET_FS_uri_destroy (sks_uri); |
318 | kill_task = | 289 | kill_task = |
319 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &do_timeout, | 290 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &do_timeout, |
320 | NULL); | 291 | NULL); |
321 | GNUNET_FS_uri_destroy (ksk_uri); | 292 | GNUNET_FS_uri_destroy (ksk_uri); |
322 | GNUNET_FS_namespace_delete (ns, GNUNET_NO); | ||
323 | GNUNET_CONTAINER_meta_data_destroy (meta); | 293 | GNUNET_CONTAINER_meta_data_destroy (meta); |
294 | GNUNET_CRYPTO_ecc_key_free (ns); | ||
324 | } | 295 | } |
325 | 296 | ||
326 | 297 | ||