diff options
Diffstat (limited to 'src/namestore/test_namestore_api_zone_iteration_nick.c')
-rw-r--r-- | src/namestore/test_namestore_api_zone_iteration_nick.c | 497 |
1 files changed, 250 insertions, 247 deletions
diff --git a/src/namestore/test_namestore_api_zone_iteration_nick.c b/src/namestore/test_namestore_api_zone_iteration_nick.c index 739e71c05..35eab2735 100644 --- a/src/namestore/test_namestore_api_zone_iteration_nick.c +++ b/src/namestore/test_namestore_api_zone_iteration_nick.c | |||
@@ -32,14 +32,14 @@ | |||
32 | #define ZONE_NICK_1 "nick1" | 32 | #define ZONE_NICK_1 "nick1" |
33 | #define ZONE_NICK_2 "nick2" | 33 | #define ZONE_NICK_2 "nick2" |
34 | 34 | ||
35 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 100) | 35 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100) |
36 | 36 | ||
37 | 37 | ||
38 | static struct GNUNET_NAMESTORE_Handle * nsh; | 38 | static struct GNUNET_NAMESTORE_Handle *nsh; |
39 | 39 | ||
40 | static struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey; | 40 | static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; |
41 | 41 | ||
42 | static struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey2; | 42 | static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey2; |
43 | 43 | ||
44 | static struct GNUNET_NAMESTORE_ZoneIterator *zi; | 44 | static struct GNUNET_NAMESTORE_ZoneIterator *zi; |
45 | 45 | ||
@@ -47,15 +47,15 @@ static int res; | |||
47 | 47 | ||
48 | static int returned_records; | 48 | static int returned_records; |
49 | 49 | ||
50 | static char * s_name_1; | 50 | static char *s_name_1; |
51 | 51 | ||
52 | static struct GNUNET_GNSRECORD_Data *s_rd_1; | 52 | static struct GNUNET_GNSRECORD_Data *s_rd_1; |
53 | 53 | ||
54 | static char * s_name_2; | 54 | static char *s_name_2; |
55 | 55 | ||
56 | static struct GNUNET_GNSRECORD_Data *s_rd_2; | 56 | static struct GNUNET_GNSRECORD_Data *s_rd_2; |
57 | 57 | ||
58 | static char * s_name_3; | 58 | static char *s_name_3; |
59 | 59 | ||
60 | static struct GNUNET_GNSRECORD_Data *s_rd_3; | 60 | static struct GNUNET_GNSRECORD_Data *s_rd_3; |
61 | 61 | ||
@@ -69,266 +69,269 @@ static struct GNUNET_NAMESTORE_QueueEntry *nsqe; | |||
69 | * @param tc scheduler context | 69 | * @param tc scheduler context |
70 | */ | 70 | */ |
71 | static void | 71 | static void |
72 | end(void *cls) | 72 | end (void *cls) |
73 | { | 73 | { |
74 | if (NULL != zi) | 74 | if (NULL != zi) |
75 | { | 75 | { |
76 | GNUNET_NAMESTORE_zone_iteration_stop(zi); | 76 | GNUNET_NAMESTORE_zone_iteration_stop (zi); |
77 | zi = NULL; | 77 | zi = NULL; |
78 | } | 78 | } |
79 | if (nsh != NULL) | 79 | if (nsh != NULL) |
80 | { | 80 | { |
81 | GNUNET_NAMESTORE_disconnect(nsh); | 81 | GNUNET_NAMESTORE_disconnect (nsh); |
82 | nsh = NULL; | 82 | nsh = NULL; |
83 | } | 83 | } |
84 | GNUNET_free_non_null(s_name_1); | 84 | GNUNET_free_non_null (s_name_1); |
85 | GNUNET_free_non_null(s_name_2); | 85 | GNUNET_free_non_null (s_name_2); |
86 | GNUNET_free_non_null(s_name_3); | 86 | GNUNET_free_non_null (s_name_3); |
87 | 87 | ||
88 | if (s_rd_1 != NULL) | 88 | if (s_rd_1 != NULL) |
89 | { | 89 | { |
90 | GNUNET_free((void *)s_rd_1->data); | 90 | GNUNET_free ((void *) s_rd_1->data); |
91 | GNUNET_free(s_rd_1); | 91 | GNUNET_free (s_rd_1); |
92 | } | 92 | } |
93 | if (s_rd_2 != NULL) | 93 | if (s_rd_2 != NULL) |
94 | { | 94 | { |
95 | GNUNET_free((void *)s_rd_2->data); | 95 | GNUNET_free ((void *) s_rd_2->data); |
96 | GNUNET_free(s_rd_2); | 96 | GNUNET_free (s_rd_2); |
97 | } | 97 | } |
98 | if (s_rd_3 != NULL) | 98 | if (s_rd_3 != NULL) |
99 | { | 99 | { |
100 | GNUNET_free((void *)s_rd_3->data); | 100 | GNUNET_free ((void *) s_rd_3->data); |
101 | GNUNET_free(s_rd_3); | 101 | GNUNET_free (s_rd_3); |
102 | } | 102 | } |
103 | 103 | ||
104 | if (privkey != NULL) | 104 | if (privkey != NULL) |
105 | { | 105 | { |
106 | GNUNET_free(privkey); | 106 | GNUNET_free (privkey); |
107 | privkey = NULL; | 107 | privkey = NULL; |
108 | } | 108 | } |
109 | if (privkey2 != NULL) | 109 | if (privkey2 != NULL) |
110 | { | 110 | { |
111 | GNUNET_free(privkey2); | 111 | GNUNET_free (privkey2); |
112 | privkey2 = NULL; | 112 | privkey2 = NULL; |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | static int | 117 | static int |
118 | check_zone_1(const char *label, unsigned int rd_count, | 118 | check_zone_1 (const char *label, unsigned int rd_count, |
119 | const struct GNUNET_GNSRECORD_Data *rd) | 119 | const struct GNUNET_GNSRECORD_Data *rd) |
120 | { | 120 | { |
121 | for (unsigned int c = 0; c < rd_count; c++) | 121 | for (unsigned int c = 0; c < rd_count; c++) |
122 | { | ||
123 | if ((rd[c].record_type == GNUNET_GNSRECORD_TYPE_NICK) && | ||
124 | (0 != strcmp (rd[c].data, ZONE_NICK_1))) | ||
122 | { | 125 | { |
123 | if ((rd[c].record_type == GNUNET_GNSRECORD_TYPE_NICK) && | 126 | GNUNET_break (0); |
124 | (0 != strcmp(rd[c].data, ZONE_NICK_1))) | 127 | return GNUNET_YES; |
125 | { | ||
126 | GNUNET_break(0); | ||
127 | return GNUNET_YES; | ||
128 | } | ||
129 | } | 128 | } |
129 | } | ||
130 | return GNUNET_NO; | 130 | return GNUNET_NO; |
131 | } | 131 | } |
132 | 132 | ||
133 | 133 | ||
134 | static int | 134 | static int |
135 | check_zone_2(const char *label, | 135 | check_zone_2 (const char *label, |
136 | unsigned int rd_count, | 136 | unsigned int rd_count, |
137 | const struct GNUNET_GNSRECORD_Data *rd) | 137 | const struct GNUNET_GNSRECORD_Data *rd) |
138 | { | 138 | { |
139 | for (unsigned int c = 0; c < rd_count; c++) | 139 | for (unsigned int c = 0; c < rd_count; c++) |
140 | { | ||
141 | if ((rd[c].record_type == GNUNET_GNSRECORD_TYPE_NICK) && | ||
142 | (0 != strcmp (rd[c].data, ZONE_NICK_2))) | ||
140 | { | 143 | { |
141 | if ((rd[c].record_type == GNUNET_GNSRECORD_TYPE_NICK) && | 144 | GNUNET_break (0); |
142 | (0 != strcmp(rd[c].data, ZONE_NICK_2))) | 145 | return GNUNET_YES; |
143 | { | ||
144 | GNUNET_break(0); | ||
145 | return GNUNET_YES; | ||
146 | } | ||
147 | } | 146 | } |
147 | } | ||
148 | return GNUNET_NO; | 148 | return GNUNET_NO; |
149 | } | 149 | } |
150 | 150 | ||
151 | 151 | ||
152 | static void | 152 | static void |
153 | zone_proc_end(void *cls) | 153 | zone_proc_end (void *cls) |
154 | { | 154 | { |
155 | zi = NULL; | 155 | zi = NULL; |
156 | res = 0; | 156 | res = 0; |
157 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
158 | "Received last result, iteration done after receing %u results\n", | 158 | "Received last result, iteration done after receing %u results\n", |
159 | returned_records); | 159 | returned_records); |
160 | GNUNET_SCHEDULER_shutdown(); | 160 | GNUNET_SCHEDULER_shutdown (); |
161 | } | 161 | } |
162 | 162 | ||
163 | 163 | ||
164 | static void | 164 | static void |
165 | zone_proc(void *cls, | 165 | zone_proc (void *cls, |
166 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 166 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
167 | const char *label, | 167 | const char *label, |
168 | unsigned int rd_count, | 168 | unsigned int rd_count, |
169 | const struct GNUNET_GNSRECORD_Data *rd) | 169 | const struct GNUNET_GNSRECORD_Data *rd) |
170 | { | 170 | { |
171 | int failed = GNUNET_NO; | 171 | int failed = GNUNET_NO; |
172 | 172 | ||
173 | GNUNET_assert(NULL != zone); | 173 | GNUNET_assert (NULL != zone); |
174 | if (0 == GNUNET_memcmp(zone, privkey)) | 174 | if (0 == GNUNET_memcmp (zone, privkey)) |
175 | { | 175 | { |
176 | failed = check_zone_1(label, rd_count, rd); | 176 | failed = check_zone_1 (label, rd_count, rd); |
177 | if (GNUNET_YES == failed) | 177 | if (GNUNET_YES == failed) |
178 | GNUNET_break(0); | 178 | GNUNET_break (0); |
179 | } | 179 | } |
180 | else if (0 == GNUNET_memcmp(zone, privkey2)) | 180 | else if (0 == GNUNET_memcmp (zone, privkey2)) |
181 | { | 181 | { |
182 | failed = check_zone_2(label, rd_count, rd); | 182 | failed = check_zone_2 (label, rd_count, rd); |
183 | if (GNUNET_YES == failed) | 183 | if (GNUNET_YES == failed) |
184 | GNUNET_break(0); | 184 | GNUNET_break (0); |
185 | } | 185 | } |
186 | else | 186 | else |
187 | { | 187 | { |
188 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 188 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
189 | "Received invalid zone\n"); | 189 | "Received invalid zone\n"); |
190 | failed = GNUNET_YES; | 190 | failed = GNUNET_YES; |
191 | GNUNET_break(0); | 191 | GNUNET_break (0); |
192 | } | 192 | } |
193 | 193 | ||
194 | if (failed == GNUNET_NO) | 194 | if (failed == GNUNET_NO) |
195 | { | 195 | { |
196 | returned_records++; | 196 | returned_records++; |
197 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
198 | "Telling namestore to send the next result\n"); | 198 | "Telling namestore to send the next result\n"); |
199 | GNUNET_NAMESTORE_zone_iterator_next(zi, | 199 | GNUNET_NAMESTORE_zone_iterator_next (zi, |
200 | 1); | 200 | 1); |
201 | } | 201 | } |
202 | else | 202 | else |
203 | { | 203 | { |
204 | GNUNET_break(0); | 204 | GNUNET_break (0); |
205 | res = 1; | 205 | res = 1; |
206 | GNUNET_SCHEDULER_shutdown(); | 206 | GNUNET_SCHEDULER_shutdown (); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | 210 | ||
211 | static void | 211 | static void |
212 | fail_cb(void *cls) | 212 | fail_cb (void *cls) |
213 | { | 213 | { |
214 | GNUNET_assert(0); | 214 | GNUNET_assert (0); |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | static void | 218 | static void |
219 | put_cont(void *cls, | 219 | put_cont (void *cls, |
220 | int32_t success, | 220 | int32_t success, |
221 | const char *emsg) | 221 | const char *emsg) |
222 | { | 222 | { |
223 | static int c = 0; | 223 | static int c = 0; |
224 | 224 | ||
225 | if (success == GNUNET_OK) | 225 | if (success == GNUNET_OK) |
226 | { | 226 | { |
227 | c++; | 227 | c++; |
228 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Created record %u \n", c); | 228 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record %u \n", c); |
229 | } | 229 | } |
230 | else | 230 | else |
231 | { | 231 | { |
232 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to created records: `%s'\n", | 232 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records: `%s'\n", |
233 | emsg); | 233 | emsg); |
234 | GNUNET_break(0); | 234 | GNUNET_break (0); |
235 | GNUNET_SCHEDULER_shutdown(); | 235 | GNUNET_SCHEDULER_shutdown (); |
236 | return; | 236 | return; |
237 | } | 237 | } |
238 | 238 | ||
239 | if (c == 3) | 239 | if (c == 3) |
240 | { | ||
241 | res = 1; | ||
242 | returned_records = 0; | ||
243 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
244 | "All records created, starting iteration over all zones \n"); | ||
245 | zi = GNUNET_NAMESTORE_zone_iteration_start (nsh, | ||
246 | NULL, | ||
247 | &fail_cb, | ||
248 | NULL, | ||
249 | &zone_proc, | ||
250 | NULL, | ||
251 | &zone_proc_end, | ||
252 | NULL); | ||
253 | if (zi == NULL) | ||
240 | { | 254 | { |
241 | res = 1; | 255 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); |
242 | returned_records = 0; | 256 | GNUNET_break (0); |
243 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n"); | 257 | GNUNET_SCHEDULER_shutdown (); |
244 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, | 258 | return; |
245 | NULL, | ||
246 | &fail_cb, | ||
247 | NULL, | ||
248 | &zone_proc, | ||
249 | NULL, | ||
250 | &zone_proc_end, | ||
251 | NULL); | ||
252 | if (zi == NULL) | ||
253 | { | ||
254 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); | ||
255 | GNUNET_break(0); | ||
256 | GNUNET_SCHEDULER_shutdown(); | ||
257 | return; | ||
258 | } | ||
259 | } | 259 | } |
260 | } | ||
260 | } | 261 | } |
261 | 262 | ||
262 | 263 | ||
263 | static struct GNUNET_GNSRECORD_Data * | 264 | static struct GNUNET_GNSRECORD_Data * |
264 | create_record(unsigned int count) | 265 | create_record (unsigned int count) |
265 | { | 266 | { |
266 | struct GNUNET_GNSRECORD_Data * rd; | 267 | struct GNUNET_GNSRECORD_Data *rd; |
267 | 268 | ||
268 | rd = GNUNET_new_array(count, | 269 | rd = GNUNET_new_array (count, |
269 | struct GNUNET_GNSRECORD_Data); | 270 | struct GNUNET_GNSRECORD_Data); |
270 | for (unsigned int c = 0; c < count; c++) | 271 | for (unsigned int c = 0; c < count; c++) |
271 | { | 272 | { |
272 | rd[c].expiration_time = GNUNET_TIME_relative_to_absolute(GNUNET_TIME_UNIT_HOURS).abs_value_us; | 273 | rd[c].expiration_time = GNUNET_TIME_relative_to_absolute ( |
273 | rd[c].record_type = TEST_RECORD_TYPE; | 274 | GNUNET_TIME_UNIT_HOURS).abs_value_us; |
274 | rd[c].data_size = 50; | 275 | rd[c].record_type = TEST_RECORD_TYPE; |
275 | rd[c].data = GNUNET_malloc(50); | 276 | rd[c].data_size = 50; |
276 | rd[c].flags = 0; | 277 | rd[c].data = GNUNET_malloc (50); |
277 | memset((char *)rd[c].data, 'a', 50); | 278 | rd[c].flags = 0; |
278 | } | 279 | memset ((char *) rd[c].data, 'a', 50); |
280 | } | ||
279 | return rd; | 281 | return rd; |
280 | } | 282 | } |
281 | 283 | ||
282 | 284 | ||
283 | static void | 285 | static void |
284 | nick_2_cont(void *cls, | 286 | nick_2_cont (void *cls, |
285 | int32_t success, | 287 | int32_t success, |
286 | const char *emsg) | 288 | const char *emsg) |
287 | { | 289 | { |
288 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 290 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
289 | "Nick added : %s\n", | 291 | "Nick added : %s\n", |
290 | (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); | 292 | (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); |
291 | 293 | ||
292 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); | 294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); |
293 | 295 | ||
294 | GNUNET_asprintf(&s_name_1, "dummy1"); | 296 | GNUNET_asprintf (&s_name_1, "dummy1"); |
295 | s_rd_1 = create_record(1); | 297 | s_rd_1 = create_record (1); |
296 | GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, | 298 | GNUNET_NAMESTORE_records_store (nsh, privkey, s_name_1, |
297 | 1, s_rd_1, | 299 | 1, s_rd_1, |
298 | &put_cont, NULL); | 300 | &put_cont, NULL); |
299 | 301 | ||
300 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 302 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
301 | "Created record 2 \n"); | 303 | "Created record 2 \n"); |
302 | GNUNET_asprintf(&s_name_2, "dummy2"); | 304 | GNUNET_asprintf (&s_name_2, "dummy2"); |
303 | s_rd_2 = create_record(1); | 305 | s_rd_2 = create_record (1); |
304 | GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_2, | 306 | GNUNET_NAMESTORE_records_store (nsh, privkey, s_name_2, |
305 | 1, s_rd_2, &put_cont, NULL); | 307 | 1, s_rd_2, &put_cont, NULL); |
306 | 308 | ||
307 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 309 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
308 | "Created record 3\n"); | 310 | "Created record 3\n"); |
309 | 311 | ||
310 | /* name in different zone */ | 312 | /* name in different zone */ |
311 | GNUNET_asprintf(&s_name_3, "dummy3"); | 313 | GNUNET_asprintf (&s_name_3, "dummy3"); |
312 | s_rd_3 = create_record(1); | 314 | s_rd_3 = create_record (1); |
313 | GNUNET_NAMESTORE_records_store(nsh, privkey2, s_name_3, | 315 | GNUNET_NAMESTORE_records_store (nsh, privkey2, s_name_3, |
314 | 1, s_rd_3, | 316 | 1, s_rd_3, |
315 | &put_cont, NULL); | 317 | &put_cont, NULL); |
316 | } | 318 | } |
317 | 319 | ||
318 | 320 | ||
319 | static void | 321 | static void |
320 | nick_1_cont(void *cls, int32_t success, const char *emsg) | 322 | nick_1_cont (void *cls, int32_t success, const char *emsg) |
321 | { | 323 | { |
322 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 324 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
323 | "Nick 1 added : %s\n", | 325 | "Nick 1 added : %s\n", |
324 | (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); | 326 | (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); |
325 | 327 | ||
326 | nsqe = GNUNET_NAMESTORE_set_nick(nsh, privkey2, ZONE_NICK_2, &nick_2_cont, &privkey2); | 328 | nsqe = GNUNET_NAMESTORE_set_nick (nsh, privkey2, ZONE_NICK_2, &nick_2_cont, |
329 | &privkey2); | ||
327 | if (NULL == nsqe) | 330 | if (NULL == nsqe) |
328 | { | 331 | { |
329 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 332 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
330 | _("Namestore cannot store no block\n")); | 333 | _ ("Namestore cannot store no block\n")); |
331 | } | 334 | } |
332 | } | 335 | } |
333 | 336 | ||
334 | 337 | ||
@@ -338,82 +341,82 @@ nick_1_cont(void *cls, int32_t success, const char *emsg) | |||
338 | * start the actual tests by filling the zone. | 341 | * start the actual tests by filling the zone. |
339 | */ | 342 | */ |
340 | static void | 343 | static void |
341 | empty_zone_proc(void *cls, | 344 | empty_zone_proc (void *cls, |
342 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 345 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
343 | const char *label, | 346 | const char *label, |
344 | unsigned int rd_count, | 347 | unsigned int rd_count, |
345 | const struct GNUNET_GNSRECORD_Data *rd) | 348 | const struct GNUNET_GNSRECORD_Data *rd) |
346 | { | 349 | { |
347 | GNUNET_assert(nsh == cls); | 350 | GNUNET_assert (nsh == cls); |
348 | 351 | ||
349 | if (NULL != zone) | 352 | if (NULL != zone) |
350 | { | 353 | { |
351 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 354 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
352 | _("Expected empty zone but received zone private key\n")); | 355 | _ ("Expected empty zone but received zone private key\n")); |
353 | GNUNET_break(0); | 356 | GNUNET_break (0); |
354 | GNUNET_SCHEDULER_shutdown(); | 357 | GNUNET_SCHEDULER_shutdown (); |
355 | return; | 358 | return; |
356 | } | 359 | } |
357 | if ((NULL != label) || (NULL != rd) || (0 != rd_count)) | 360 | if ((NULL != label) || (NULL != rd) || (0 != rd_count)) |
358 | { | 361 | { |
359 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 362 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
360 | _("Expected no zone content but received data\n")); | 363 | _ ("Expected no zone content but received data\n")); |
361 | GNUNET_break(0); | 364 | GNUNET_break (0); |
362 | GNUNET_SCHEDULER_shutdown(); | 365 | GNUNET_SCHEDULER_shutdown (); |
363 | return; | 366 | return; |
364 | } | 367 | } |
365 | GNUNET_assert(0); | 368 | GNUNET_assert (0); |
366 | } | 369 | } |
367 | 370 | ||
368 | 371 | ||
369 | static void | 372 | static void |
370 | empty_zone_end(void *cls) | 373 | empty_zone_end (void *cls) |
371 | { | 374 | { |
372 | GNUNET_assert(nsh == cls); | 375 | GNUNET_assert (nsh == cls); |
373 | zi = NULL; | 376 | zi = NULL; |
374 | privkey = GNUNET_CRYPTO_ecdsa_key_create(); | 377 | privkey = GNUNET_CRYPTO_ecdsa_key_create (); |
375 | GNUNET_assert(privkey != NULL); | 378 | GNUNET_assert (privkey != NULL); |
376 | privkey2 = GNUNET_CRYPTO_ecdsa_key_create(); | 379 | privkey2 = GNUNET_CRYPTO_ecdsa_key_create (); |
377 | GNUNET_assert(privkey2 != NULL); | 380 | GNUNET_assert (privkey2 != NULL); |
378 | 381 | ||
379 | nsqe = GNUNET_NAMESTORE_set_nick(nsh, | 382 | nsqe = GNUNET_NAMESTORE_set_nick (nsh, |
380 | privkey, | 383 | privkey, |
381 | ZONE_NICK_1, | 384 | ZONE_NICK_1, |
382 | &nick_1_cont, | 385 | &nick_1_cont, |
383 | &privkey); | 386 | &privkey); |
384 | if (NULL == nsqe) | 387 | if (NULL == nsqe) |
385 | { | 388 | { |
386 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 389 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
387 | _("Namestore cannot store no block\n")); | 390 | _ ("Namestore cannot store no block\n")); |
388 | } | 391 | } |
389 | } | 392 | } |
390 | 393 | ||
391 | 394 | ||
392 | static void | 395 | static void |
393 | run(void *cls, | 396 | run (void *cls, |
394 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 397 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
395 | struct GNUNET_TESTING_Peer *peer) | 398 | struct GNUNET_TESTING_Peer *peer) |
396 | { | 399 | { |
397 | nsh = GNUNET_NAMESTORE_connect(cfg); | 400 | nsh = GNUNET_NAMESTORE_connect (cfg); |
398 | GNUNET_break(NULL != nsh); | 401 | GNUNET_break (NULL != nsh); |
399 | GNUNET_SCHEDULER_add_shutdown(&end, | 402 | GNUNET_SCHEDULER_add_shutdown (&end, |
400 | NULL); | 403 | NULL); |
401 | /* first, iterate over empty namestore */ | 404 | /* first, iterate over empty namestore */ |
402 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, | 405 | zi = GNUNET_NAMESTORE_zone_iteration_start (nsh, |
403 | NULL, | 406 | NULL, |
404 | &fail_cb, | 407 | &fail_cb, |
405 | NULL, | 408 | NULL, |
406 | &empty_zone_proc, | 409 | &empty_zone_proc, |
407 | nsh, | 410 | nsh, |
408 | &empty_zone_end, | 411 | &empty_zone_end, |
409 | nsh); | 412 | nsh); |
410 | if (NULL == zi) | 413 | if (NULL == zi) |
411 | { | 414 | { |
412 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 415 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
413 | "Failed to create zone iterator\n"); | 416 | "Failed to create zone iterator\n"); |
414 | GNUNET_break(0); | 417 | GNUNET_break (0); |
415 | GNUNET_SCHEDULER_shutdown(); | 418 | GNUNET_SCHEDULER_shutdown (); |
416 | } | 419 | } |
417 | } | 420 | } |
418 | 421 | ||
419 | 422 | ||
@@ -421,24 +424,24 @@ run(void *cls, | |||
421 | 424 | ||
422 | 425 | ||
423 | int | 426 | int |
424 | main(int argc, char *argv[]) | 427 | main (int argc, char *argv[]) |
425 | { | 428 | { |
426 | const char *plugin_name; | 429 | const char *plugin_name; |
427 | char *cfg_name; | 430 | char *cfg_name; |
428 | 431 | ||
429 | SETUP_CFG(plugin_name, cfg_name); | 432 | SETUP_CFG (plugin_name, cfg_name); |
430 | res = 1; | 433 | res = 1; |
431 | if (0 != | 434 | if (0 != |
432 | GNUNET_TESTING_peer_run("test-namestore-api-zone-iteration-nick", | 435 | GNUNET_TESTING_peer_run ("test-namestore-api-zone-iteration-nick", |
433 | cfg_name, | 436 | cfg_name, |
434 | &run, | 437 | &run, |
435 | NULL)) | 438 | NULL)) |
436 | { | 439 | { |
437 | res = 1; | 440 | res = 1; |
438 | } | 441 | } |
439 | GNUNET_DISK_purge_cfg_dir(cfg_name, | 442 | GNUNET_DISK_purge_cfg_dir (cfg_name, |
440 | "GNUNET_TEST_HOME"); | 443 | "GNUNET_TEST_HOME"); |
441 | GNUNET_free(cfg_name); | 444 | GNUNET_free (cfg_name); |
442 | return res; | 445 | return res; |
443 | } | 446 | } |
444 | 447 | ||