aboutsummaryrefslogtreecommitdiff
path: root/src/psycstore/test_psycstore.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/psycstore/test_psycstore.c')
-rw-r--r--src/psycstore/test_psycstore.c65
1 files changed, 51 insertions, 14 deletions
diff --git a/src/psycstore/test_psycstore.c b/src/psycstore/test_psycstore.c
index 3ef2439e3..125e64f58 100644
--- a/src/psycstore/test_psycstore.c
+++ b/src/psycstore/test_psycstore.c
@@ -25,6 +25,8 @@
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27 27
28#include <inttypes.h>
29
28#include "platform.h" 30#include "platform.h"
29#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
30#include "gnunet_common.h" 32#include "gnunet_common.h"
@@ -302,19 +304,22 @@ fragment_result (void *cls,
302 enum GNUNET_PSYCSTORE_MessageFlags flags) 304 enum GNUNET_PSYCSTORE_MessageFlags flags)
303{ 305{
304 struct FragmentClosure *fcls = cls; 306 struct FragmentClosure *fcls = cls;
307 GNUNET_assert (fcls->n < fcls->n_expected);
305 struct GNUNET_MULTICAST_MessageHeader *msg0 = fcls->msg[fcls->n]; 308 struct GNUNET_MULTICAST_MessageHeader *msg0 = fcls->msg[fcls->n];
306 uint64_t flags0 = fcls->flags[fcls->n++]; 309 uint64_t flags0 = fcls->flags[fcls->n++];
307 310
308 if (flags == flags0 && msg->header.size == msg0->header.size 311 if (flags == flags0 && msg->header.size == msg0->header.size
309 && 0 == memcmp (msg, msg0, ntohs (msg->header.size))) 312 && 0 == memcmp (msg, msg0, ntohs (msg->header.size)))
310 { 313 {
311 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " fragment %llu matches\n", 314 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " fragment %" PRIu64 " matches\n",
312 GNUNET_ntohll (msg->fragment_id)); 315 GNUNET_ntohll (msg->fragment_id));
313 return GNUNET_YES; 316 return GNUNET_YES;
314 } 317 }
315 else 318 else
316 { 319 {
317 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " fragment %llu differs\n", 320 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
321 " fragment differs: expected %" PRIu64 ", got %" PRIu64 "\n",
322 GNUNET_ntohll (msg0->fragment_id),
318 GNUNET_ntohll (msg->fragment_id)); 323 GNUNET_ntohll (msg->fragment_id));
319 GNUNET_assert (0); 324 GNUNET_assert (0);
320 return GNUNET_SYSERR; 325 return GNUNET_SYSERR;
@@ -323,13 +328,12 @@ fragment_result (void *cls,
323 328
324 329
325void 330void
326message_get_result (void *cls, int64_t result, const char *err_msg) 331message_get_latest_result (void *cls, int64_t result, const char *err_msg)
327{ 332{
328 struct FragmentClosure *fcls = cls; 333 struct FragmentClosure *fcls = cls;
329 op = NULL; 334 op = NULL;
330 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "message_get:\t%d\n", result); 335 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "message_get_latest:\t%d\n", result);
331 GNUNET_assert (result > 0 && fcls->n && fcls->n_expected); 336 GNUNET_assert (0 < result && fcls->n == fcls->n_expected);
332
333 337
334 modifiers[0] = (struct GNUNET_ENV_Modifier) { 338 modifiers[0] = (struct GNUNET_ENV_Modifier) {
335 .oper = '=', 339 .oper = '=',
@@ -351,29 +355,46 @@ message_get_result (void *cls, int64_t result, const char *err_msg)
351 355
352 356
353void 357void
358message_get_result (void *cls, int64_t result, const char *err_msg)
359{
360 struct FragmentClosure *fcls = cls;
361 op = NULL;
362 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "message_get:\t%d\n", result);
363 GNUNET_assert (0 < result && fcls->n == fcls->n_expected);
364
365 fcls->n = 0;
366 fcls->n_expected = 3;
367 op = GNUNET_PSYCSTORE_message_get_latest (h, &channel_pub_key, &slave_pub_key,
368 1, &fragment_result,
369 &message_get_latest_result, fcls);
370}
371
372
373void
354message_get_fragment_result (void *cls, int64_t result, const char *err_msg) 374message_get_fragment_result (void *cls, int64_t result, const char *err_msg)
355{ 375{
356 struct FragmentClosure *fcls = cls; 376 struct FragmentClosure *fcls = cls;
357 op = NULL; 377 op = NULL;
358 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "message_get_fragment:\t%d\n", result); 378 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "message_get_fragment:\t%d\n", result);
359 GNUNET_assert (result > 0 && fcls->n && fcls->n_expected); 379 GNUNET_assert (0 < result && fcls->n == fcls->n_expected);
360 380
361 fcls->n = 0; 381 fcls->n = 0;
362 fcls->n_expected = 3; 382 fcls->n_expected = 3;
383 uint64_t message_id = GNUNET_ntohll (fcls->msg[0]->message_id);
363 op = GNUNET_PSYCSTORE_message_get (h, &channel_pub_key, &slave_pub_key, 384 op = GNUNET_PSYCSTORE_message_get (h, &channel_pub_key, &slave_pub_key,
364 GNUNET_ntohll (fcls->msg[0]->message_id), 385 message_id, message_id,
365 &fragment_result, 386 &fragment_result,
366 &message_get_result, fcls); 387 &message_get_result, fcls);
367} 388}
368 389
369 390
370void 391void
371fragment_get_result (void *cls, int64_t result, const char *err_msg) 392fragment_get_latest_result (void *cls, int64_t result, const char *err_msg)
372{ 393{
373 struct FragmentClosure *fcls = cls; 394 struct FragmentClosure *fcls = cls;
374 op = NULL; 395 op = NULL;
375 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "fragment_get:\t%d\n", result); 396 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "fragment_get_latest:\t%d\n", result);
376 GNUNET_assert (result > 0 && fcls->n && fcls->n_expected); 397 GNUNET_assert (0 < result && fcls->n == fcls->n_expected);
377 398
378 fcls->n = 1; 399 fcls->n = 1;
379 fcls->n_expected = 2; 400 fcls->n_expected = 2;
@@ -381,9 +402,24 @@ fragment_get_result (void *cls, int64_t result, const char *err_msg)
381 GNUNET_ntohll (fcls->msg[1]->message_id), 402 GNUNET_ntohll (fcls->msg[1]->message_id),
382 GNUNET_ntohll (fcls->msg[1]->fragment_offset), 403 GNUNET_ntohll (fcls->msg[1]->fragment_offset),
383 &fragment_result, 404 &fragment_result,
384 &message_get_fragment_result, 405 &message_get_fragment_result, fcls);
385 fcls); 406}
407
386 408
409void
410fragment_get_result (void *cls, int64_t result, const char *err_msg)
411{
412 struct FragmentClosure *fcls = cls;
413 op = NULL;
414 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "fragment_get:\t%d\n", result);
415 GNUNET_assert (0 < result && fcls->n == fcls->n_expected);
416
417 fcls->n = 0;
418 fcls->n_expected = 3;
419 op = GNUNET_PSYCSTORE_fragment_get_latest (h, &channel_pub_key,
420 &slave_pub_key, fcls->n_expected,
421 &fragment_result,
422 &fragment_get_latest_result, fcls);
387} 423}
388 424
389 425
@@ -398,8 +434,9 @@ fragment_store_result (void *cls, int64_t result, const char *err_msg)
398 { /* last fragment */ 434 { /* last fragment */
399 fcls.n = 0; 435 fcls.n = 0;
400 fcls.n_expected = 1; 436 fcls.n_expected = 1;
437 uint64_t fragment_id = GNUNET_ntohll (fcls.msg[0]->fragment_id);
401 op = GNUNET_PSYCSTORE_fragment_get (h, &channel_pub_key, &slave_pub_key, 438 op = GNUNET_PSYCSTORE_fragment_get (h, &channel_pub_key, &slave_pub_key,
402 GNUNET_ntohll (fcls.msg[0]->fragment_id), 439 fragment_id, fragment_id,
403 &fragment_result, 440 &fragment_result,
404 &fragment_get_result, &fcls); 441 &fragment_get_result, &fcls);
405 } 442 }