aboutsummaryrefslogtreecommitdiff
path: root/src/fs/test_fs_namespace_list_updateable.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/test_fs_namespace_list_updateable.c')
-rw-r--r--src/fs/test_fs_namespace_list_updateable.c175
1 files changed, 0 insertions, 175 deletions
diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c
deleted file mode 100644
index 2132220fb..000000000
--- a/src/fs/test_fs_namespace_list_updateable.c
+++ /dev/null
@@ -1,175 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2005-2013 GNUnet e.V.
4
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.
9
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.
14
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/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file fs/test_fs_namespace_list_updateable.c
23 * @brief Test for fs_namespace_list_updateable.c
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testing_lib.h"
29#include "gnunet_fs_service.h"
30
31
32static struct GNUNET_FS_Handle *fs;
33
34static int err;
35
36static struct GNUNET_CRYPTO_EcdsaPrivateKey ns;
37
38static struct GNUNET_CONTAINER_MetaData *meta;
39
40static struct GNUNET_FS_Uri *uri_this;
41
42static struct GNUNET_FS_Uri *uri_next;
43
44static struct GNUNET_FS_BlockOptions bo;
45
46
47static void *
48progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
49{
50 return NULL;
51}
52
53
54static void
55do_shutdown ()
56{
57 if (uri_this != NULL)
58 GNUNET_FS_uri_destroy (uri_this);
59 if (uri_next != NULL)
60 GNUNET_FS_uri_destroy (uri_next);
61 if (meta != NULL)
62 GNUNET_CONTAINER_meta_data_destroy (meta);
63}
64
65
66static void
67check_next (void *cls, const char *last_id,
68 const struct GNUNET_FS_Uri *last_uri,
69 const struct GNUNET_CONTAINER_MetaData *last_meta,
70 const char *next_id)
71{
72 GNUNET_break (0 == strcmp (last_id, "next"));
73 GNUNET_break (0 == strcmp (next_id, "future"));
74 err -= 4;
75}
76
77
78static void
79check_this_next (void *cls, const char *last_id,
80 const struct GNUNET_FS_Uri *last_uri,
81 const struct GNUNET_CONTAINER_MetaData *last_meta,
82 const char *next_id)
83{
84 GNUNET_break (0 == strcmp (last_id, "this"));
85 GNUNET_break (0 == strcmp (next_id, "next"));
86 err -= 2;
87 err += 4;
88 GNUNET_FS_namespace_list_updateable (fs, &ns, next_id, &check_next, NULL);
89}
90
91
92static void
93sks_cont_next (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
94{
95 GNUNET_assert (NULL == emsg);
96 err += 2;
97 GNUNET_FS_namespace_list_updateable (fs, &ns, NULL, &check_this_next, NULL);
98}
99
100
101static void
102check_this (void *cls, const char *last_id,
103 const struct GNUNET_FS_Uri *last_uri,
104 const struct GNUNET_CONTAINER_MetaData *last_meta,
105 const char *next_id)
106{
107 GNUNET_break (0 == strcmp (last_id, "this"));
108 GNUNET_break (0 == strcmp (next_id, "next"));
109 err -= 1;
110}
111
112
113static void
114sks_cont_this (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
115{
116 GNUNET_assert (NULL == emsg);
117 err = 1;
118 GNUNET_FS_namespace_list_updateable (fs, &ns, NULL, &check_this, NULL);
119 GNUNET_FS_publish_sks (fs,
120 &ns, "next", "future", meta, uri_next, &bo,
121 GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_next, NULL);
122}
123
124
125static void
126testNamespace (void)
127{
128 GNUNET_CRYPTO_ecdsa_key_create (&ns);
129 bo.content_priority = 1;
130 bo.anonymity_level = 1;
131 bo.replication_level = 0;
132 bo.expiration_time =
133 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
134 meta = GNUNET_CONTAINER_meta_data_create ();
135
136 uri_this =
137 GNUNET_FS_uri_parse
138 (
139 "gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42",
140 NULL);
141 uri_next =
142 GNUNET_FS_uri_parse
143 (
144 "gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.43",
145 NULL);
146 GNUNET_FS_publish_sks (fs,
147 &ns, "this", "next", meta, uri_this, &bo,
148 GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_this, NULL);
149}
150
151
152static void
153run (void *cls,
154 const struct GNUNET_CONFIGURATION_Handle *cfg,
155 struct GNUNET_TESTING_Peer *peer)
156{
157 fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL,
158 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
159 testNamespace ();
160}
161
162
163int
164main (int argc, char *argv[])
165{
166 if (0 != GNUNET_TESTING_peer_run ("test-fs-namespace-list-updateable",
167 "test_fs_namespace_data.conf",
168 &run, NULL))
169 return 1;
170 do_shutdown ();
171 return err;
172}
173
174
175/* end of test_fs_namespace_list_updateable.c */