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.c115
1 files changed, 57 insertions, 58 deletions
diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c
index 99c0967b8..9a28fcb1b 100644
--- a/src/fs/test_fs_namespace_list_updateable.c
+++ b/src/fs/test_fs_namespace_list_updateable.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file fs/test_fs_namespace_list_updateable.c 22 * @file fs/test_fs_namespace_list_updateable.c
@@ -45,129 +45,128 @@ static struct GNUNET_FS_BlockOptions bo;
45 45
46 46
47static void * 47static void *
48progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) 48progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *event)
49{ 49{
50 return NULL; 50 return NULL;
51} 51}
52 52
53 53
54static void 54static void
55do_shutdown () 55do_shutdown()
56{ 56{
57 if (uri_this != NULL) 57 if (uri_this != NULL)
58 GNUNET_FS_uri_destroy (uri_this); 58 GNUNET_FS_uri_destroy(uri_this);
59 if (uri_next != NULL) 59 if (uri_next != NULL)
60 GNUNET_FS_uri_destroy (uri_next); 60 GNUNET_FS_uri_destroy(uri_next);
61 if (ns != NULL) 61 if (ns != NULL)
62 GNUNET_free (ns); 62 GNUNET_free(ns);
63 if (meta != NULL) 63 if (meta != NULL)
64 GNUNET_CONTAINER_meta_data_destroy (meta); 64 GNUNET_CONTAINER_meta_data_destroy(meta);
65} 65}
66 66
67 67
68static void 68static void
69check_next (void *cls, const char *last_id, 69check_next(void *cls, const char *last_id,
70 const struct GNUNET_FS_Uri *last_uri, 70 const struct GNUNET_FS_Uri *last_uri,
71 const struct GNUNET_CONTAINER_MetaData *last_meta, 71 const struct GNUNET_CONTAINER_MetaData *last_meta,
72 const char *next_id) 72 const char *next_id)
73{ 73{
74 GNUNET_break (0 == strcmp (last_id, "next")); 74 GNUNET_break(0 == strcmp(last_id, "next"));
75 GNUNET_break (0 == strcmp (next_id, "future")); 75 GNUNET_break(0 == strcmp(next_id, "future"));
76 err -= 4; 76 err -= 4;
77} 77}
78 78
79 79
80static void 80static void
81check_this_next (void *cls, const char *last_id, 81check_this_next(void *cls, const char *last_id,
82 const struct GNUNET_FS_Uri *last_uri, 82 const struct GNUNET_FS_Uri *last_uri,
83 const struct GNUNET_CONTAINER_MetaData *last_meta, 83 const struct GNUNET_CONTAINER_MetaData *last_meta,
84 const char *next_id) 84 const char *next_id)
85{ 85{
86 GNUNET_break (0 == strcmp (last_id, "this")); 86 GNUNET_break(0 == strcmp(last_id, "this"));
87 GNUNET_break (0 == strcmp (next_id, "next")); 87 GNUNET_break(0 == strcmp(next_id, "next"));
88 err -= 2; 88 err -= 2;
89 err += 4; 89 err += 4;
90 GNUNET_FS_namespace_list_updateable (fs, ns, next_id, &check_next, NULL); 90 GNUNET_FS_namespace_list_updateable(fs, ns, next_id, &check_next, NULL);
91} 91}
92 92
93 93
94static void 94static void
95sks_cont_next (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) 95sks_cont_next(void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
96{ 96{
97 GNUNET_assert (NULL == emsg); 97 GNUNET_assert(NULL == emsg);
98 err += 2; 98 err += 2;
99 GNUNET_FS_namespace_list_updateable (fs, ns, NULL, &check_this_next, NULL); 99 GNUNET_FS_namespace_list_updateable(fs, ns, NULL, &check_this_next, NULL);
100} 100}
101 101
102 102
103static void 103static void
104check_this (void *cls, const char *last_id, 104check_this(void *cls, const char *last_id,
105 const struct GNUNET_FS_Uri *last_uri, 105 const struct GNUNET_FS_Uri *last_uri,
106 const struct GNUNET_CONTAINER_MetaData *last_meta, 106 const struct GNUNET_CONTAINER_MetaData *last_meta,
107 const char *next_id) 107 const char *next_id)
108{ 108{
109 GNUNET_break (0 == strcmp (last_id, "this")); 109 GNUNET_break(0 == strcmp(last_id, "this"));
110 GNUNET_break (0 == strcmp (next_id, "next")); 110 GNUNET_break(0 == strcmp(next_id, "next"));
111 err -= 1; 111 err -= 1;
112} 112}
113 113
114 114
115static void 115static void
116sks_cont_this (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) 116sks_cont_this(void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
117{ 117{
118 GNUNET_assert (NULL == emsg); 118 GNUNET_assert(NULL == emsg);
119 err = 1; 119 err = 1;
120 GNUNET_FS_namespace_list_updateable (fs, ns, NULL, &check_this, NULL); 120 GNUNET_FS_namespace_list_updateable(fs, ns, NULL, &check_this, NULL);
121 GNUNET_FS_publish_sks (fs, ns, "next", "future", meta, uri_next, &bo, 121 GNUNET_FS_publish_sks(fs, ns, "next", "future", meta, uri_next, &bo,
122 GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_next, NULL); 122 GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_next, NULL);
123
124} 123}
125 124
126 125
127static void 126static void
128testNamespace () 127testNamespace()
129{ 128{
130 ns = GNUNET_CRYPTO_ecdsa_key_create (); 129 ns = GNUNET_CRYPTO_ecdsa_key_create();
131 GNUNET_assert (NULL != ns); 130 GNUNET_assert(NULL != ns);
132 bo.content_priority = 1; 131 bo.content_priority = 1;
133 bo.anonymity_level = 1; 132 bo.anonymity_level = 1;
134 bo.replication_level = 0; 133 bo.replication_level = 0;
135 bo.expiration_time = 134 bo.expiration_time =
136 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); 135 GNUNET_TIME_relative_to_absolute(GNUNET_TIME_UNIT_MINUTES);
137 meta = GNUNET_CONTAINER_meta_data_create (); 136 meta = GNUNET_CONTAINER_meta_data_create();
138 137
139 uri_this = 138 uri_this =
140 GNUNET_FS_uri_parse 139 GNUNET_FS_uri_parse
141 ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42", 140 ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42",
142 NULL); 141 NULL);
143 uri_next = 142 uri_next =
144 GNUNET_FS_uri_parse 143 GNUNET_FS_uri_parse
145 ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.43", 144 ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.43",
146 NULL); 145 NULL);
147 GNUNET_FS_publish_sks (fs, ns, "this", "next", meta, uri_this, &bo, 146 GNUNET_FS_publish_sks(fs, ns, "this", "next", meta, uri_this, &bo,
148 GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_this, NULL); 147 GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_this, NULL);
149} 148}
150 149
151 150
152static void 151static void
153run (void *cls, 152run(void *cls,
154 const struct GNUNET_CONFIGURATION_Handle *cfg, 153 const struct GNUNET_CONFIGURATION_Handle *cfg,
155 struct GNUNET_TESTING_Peer *peer) 154 struct GNUNET_TESTING_Peer *peer)
156{ 155{
157 fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL, 156 fs = GNUNET_FS_start(cfg, "test-fs-namespace", &progress_cb, NULL,
158 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); 157 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
159 testNamespace (); 158 testNamespace();
160} 159}
161 160
162 161
163int 162int
164main (int argc, char *argv[]) 163main(int argc, char *argv[])
165{ 164{
166 if (0 != GNUNET_TESTING_peer_run ("test-fs-namespace-list-updateable", 165 if (0 != GNUNET_TESTING_peer_run("test-fs-namespace-list-updateable",
167 "test_fs_namespace_data.conf", 166 "test_fs_namespace_data.conf",
168 &run, NULL)) 167 &run, NULL))
169 return 1; 168 return 1;
170 do_shutdown (); 169 do_shutdown();
171 return err; 170 return err;
172} 171}
173 172