2 This file is part of GNUnet.
3 Copyright (C) 2005-2013 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
17 * @file fs/test_fs_namespace_list_updateable.c
18 * @brief Test for fs_namespace_list_updateable.c
19 * @author Christian Grothoff
22 #include "gnunet_util_lib.h"
23 #include "gnunet_testing_lib.h"
24 #include "gnunet_fs_service.h"
27 static struct GNUNET_FS_Handle *fs;
31 static struct GNUNET_CRYPTO_EcdsaPrivateKey *ns;
33 static struct GNUNET_CONTAINER_MetaData *meta;
35 static struct GNUNET_FS_Uri *uri_this;
37 static struct GNUNET_FS_Uri *uri_next;
39 static struct GNUNET_FS_BlockOptions bo;
43 progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
53 GNUNET_FS_uri_destroy (uri_this);
55 GNUNET_FS_uri_destroy (uri_next);
59 GNUNET_CONTAINER_meta_data_destroy (meta);
64 check_next (void *cls, const char *last_id,
65 const struct GNUNET_FS_Uri *last_uri,
66 const struct GNUNET_CONTAINER_MetaData *last_meta,
69 GNUNET_break (0 == strcmp (last_id, "next"));
70 GNUNET_break (0 == strcmp (next_id, "future"));
76 check_this_next (void *cls, const char *last_id,
77 const struct GNUNET_FS_Uri *last_uri,
78 const struct GNUNET_CONTAINER_MetaData *last_meta,
81 GNUNET_break (0 == strcmp (last_id, "this"));
82 GNUNET_break (0 == strcmp (next_id, "next"));
85 GNUNET_FS_namespace_list_updateable (fs, ns, next_id, &check_next, NULL);
90 sks_cont_next (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
92 GNUNET_assert (NULL == emsg);
94 GNUNET_FS_namespace_list_updateable (fs, ns, NULL, &check_this_next, NULL);
99 check_this (void *cls, const char *last_id,
100 const struct GNUNET_FS_Uri *last_uri,
101 const struct GNUNET_CONTAINER_MetaData *last_meta,
104 GNUNET_break (0 == strcmp (last_id, "this"));
105 GNUNET_break (0 == strcmp (next_id, "next"));
111 sks_cont_this (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
113 GNUNET_assert (NULL == emsg);
115 GNUNET_FS_namespace_list_updateable (fs, ns, NULL, &check_this, NULL);
116 GNUNET_FS_publish_sks (fs, ns, "next", "future", meta, uri_next, &bo,
117 GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_next, NULL);
125 ns = GNUNET_CRYPTO_ecdsa_key_create ();
126 GNUNET_assert (NULL != ns);
127 bo.content_priority = 1;
128 bo.anonymity_level = 1;
129 bo.replication_level = 0;
131 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
132 meta = GNUNET_CONTAINER_meta_data_create ();
136 ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42",
140 ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.43",
142 GNUNET_FS_publish_sks (fs, ns, "this", "next", meta, uri_this, &bo,
143 GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_this, NULL);
149 const struct GNUNET_CONFIGURATION_Handle *cfg,
150 struct GNUNET_TESTING_Peer *peer)
152 fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL,
153 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
159 main (int argc, char *argv[])
161 if (0 != GNUNET_TESTING_peer_run ("test-fs-namespace-list-updateable",
162 "test_fs_namespace_data.conf",
170 /* end of test_fs_namespace_list_updateable.c */