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.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @file fs/test_fs_namespace_list_updateable.c
21 * @brief Test for fs_namespace_list_updateable.c
22 * @author Christian Grothoff
25 #include "gnunet_util_lib.h"
26 #include "gnunet_testing_lib.h"
27 #include "gnunet_fs_service.h"
30 static struct GNUNET_FS_Handle *fs;
34 static struct GNUNET_CRYPTO_EcdsaPrivateKey *ns;
36 static struct GNUNET_CONTAINER_MetaData *meta;
38 static struct GNUNET_FS_Uri *uri_this;
40 static struct GNUNET_FS_Uri *uri_next;
42 static struct GNUNET_FS_BlockOptions bo;
46 progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
56 GNUNET_FS_uri_destroy (uri_this);
58 GNUNET_FS_uri_destroy (uri_next);
62 GNUNET_CONTAINER_meta_data_destroy (meta);
67 check_next (void *cls, const char *last_id,
68 const struct GNUNET_FS_Uri *last_uri,
69 const struct GNUNET_CONTAINER_MetaData *last_meta,
72 GNUNET_break (0 == strcmp (last_id, "next"));
73 GNUNET_break (0 == strcmp (next_id, "future"));
79 check_this_next (void *cls, const char *last_id,
80 const struct GNUNET_FS_Uri *last_uri,
81 const struct GNUNET_CONTAINER_MetaData *last_meta,
84 GNUNET_break (0 == strcmp (last_id, "this"));
85 GNUNET_break (0 == strcmp (next_id, "next"));
88 GNUNET_FS_namespace_list_updateable (fs, ns, next_id, &check_next, NULL);
93 sks_cont_next (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
95 GNUNET_assert (NULL == emsg);
97 GNUNET_FS_namespace_list_updateable (fs, ns, NULL, &check_this_next, NULL);
102 check_this (void *cls, const char *last_id,
103 const struct GNUNET_FS_Uri *last_uri,
104 const struct GNUNET_CONTAINER_MetaData *last_meta,
107 GNUNET_break (0 == strcmp (last_id, "this"));
108 GNUNET_break (0 == strcmp (next_id, "next"));
114 sks_cont_this (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
116 GNUNET_assert (NULL == emsg);
118 GNUNET_FS_namespace_list_updateable (fs, ns, NULL, &check_this, NULL);
119 GNUNET_FS_publish_sks (fs, ns, "next", "future", meta, uri_next, &bo,
120 GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_next, NULL);
128 ns = GNUNET_CRYPTO_ecdsa_key_create ();
129 GNUNET_assert (NULL != ns);
130 bo.content_priority = 1;
131 bo.anonymity_level = 1;
132 bo.replication_level = 0;
134 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
135 meta = GNUNET_CONTAINER_meta_data_create ();
139 ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42",
143 ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.43",
145 GNUNET_FS_publish_sks (fs, ns, "this", "next", meta, uri_this, &bo,
146 GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_this, NULL);
152 const struct GNUNET_CONFIGURATION_Handle *cfg,
153 struct GNUNET_TESTING_Peer *peer)
155 fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL,
156 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
162 main (int argc, char *argv[])
164 if (0 != GNUNET_TESTING_peer_run ("test-fs-namespace-list-updateable",
165 "test_fs_namespace_data.conf",
173 /* end of test_fs_namespace_list_updateable.c */