aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_multipeer.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-30 20:55:21 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-30 20:55:21 +0000
commit8254665a4a3f254d4947cf9de6902121f234a29f (patch)
treeb036bb58215ef18bcc061f8a7ef8cead036771c9 /src/dht/test_dht_multipeer.c
parent5ce71ebb74e0e819d6a4d612314cc5942c24cdac (diff)
downloadgnunet-8254665a4a3f254d4947cf9de6902121f234a29f.tar.gz
gnunet-8254665a4a3f254d4947cf9de6902121f234a29f.zip
fixing bloomfilter code, fixing testcase
Diffstat (limited to 'src/dht/test_dht_multipeer.c')
-rw-r--r--src/dht/test_dht_multipeer.c61
1 files changed, 39 insertions, 22 deletions
diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c
index 82d9aa55d..76c10701d 100644
--- a/src/dht/test_dht_multipeer.c
+++ b/src/dht/test_dht_multipeer.c
@@ -34,10 +34,10 @@
34#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 30) 34#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 30)
35 35
36/* Timeout for waiting for replies to get requests */ 36/* Timeout for waiting for replies to get requests */
37#define GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) 37#define GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 300)
38 38
39/* */ 39/* */
40#define START_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) 40#define START_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)
41 41
42/* Timeout for waiting for gets to complete */ 42/* Timeout for waiting for gets to complete */
43#define GET_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 50) 43#define GET_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 50)
@@ -50,11 +50,11 @@
50 50
51#define TEST_DATA_SIZE 8 51#define TEST_DATA_SIZE 8
52 52
53#define MAX_OUTSTANDING_PUTS 10 53#define MAX_OUTSTANDING_PUTS 100
54 54
55#define MAX_OUTSTANDING_GETS 10 55#define MAX_OUTSTANDING_GETS 100
56 56
57#define PATH_TRACKING GNUNET_YES 57#define PATH_TRACKING GNUNET_NO
58 58
59 59
60 60
@@ -348,9 +348,6 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
348 GNUNET_DHT_disconnect (test_get->dht_handle); 348 GNUNET_DHT_disconnect (test_get->dht_handle);
349 test_get->dht_handle = NULL; 349 test_get->dht_handle = NULL;
350 350
351 fprintf (stderr,
352 "%llu gets succeeded, %llu gets failed!\n",
353 gets_completed, gets_failed);
354 GNUNET_CONTAINER_DLL_remove (all_gets_head, 351 GNUNET_CONTAINER_DLL_remove (all_gets_head,
355 all_gets_tail, 352 all_gets_tail,
356 test_get); 353 test_get);
@@ -358,6 +355,9 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
358 355
359 if ((gets_failed > 0) && (outstanding_gets == 0)) /* Had some failures */ 356 if ((gets_failed > 0) && (outstanding_gets == 0)) /* Had some failures */
360 { 357 {
358 fprintf (stderr,
359 "%llu gets succeeded, %llu gets failed!\n",
360 gets_completed, gets_failed);
361 GNUNET_SCHEDULER_cancel (die_task); 361 GNUNET_SCHEDULER_cancel (die_task);
362 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "not all gets succeeded"); 362 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "not all gets succeeded");
363 return; 363 return;
@@ -394,7 +394,6 @@ get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
394 struct TestGetContext *test_get = cls; 394 struct TestGetContext *test_get = cls;
395 GNUNET_HashCode search_key; /* Key stored under */ 395 GNUNET_HashCode search_key; /* Key stored under */
396 char original_data[TEST_DATA_SIZE]; /* Made up data to store */ 396 char original_data[TEST_DATA_SIZE]; /* Made up data to store */
397 unsigned int i;
398 397
399 memset (original_data, test_get->uid, sizeof (original_data)); 398 memset (original_data, test_get->uid, sizeof (original_data));
400 GNUNET_CRYPTO_hash (original_data, TEST_DATA_SIZE, &search_key); 399 GNUNET_CRYPTO_hash (original_data, TEST_DATA_SIZE, &search_key);
@@ -404,6 +403,8 @@ get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
404#if PATH_TRACKING 403#if PATH_TRACKING
405 if (put_path != NULL) 404 if (put_path != NULL)
406 { 405 {
406 unsigned int i;
407
407 fprintf (stderr, "PUT (%u) Path: ", 408 fprintf (stderr, "PUT (%u) Path: ",
408 test_get->uid); 409 test_get->uid);
409 for (i = 0; i<put_path_length; i++) 410 for (i = 0; i<put_path_length; i++)
@@ -412,6 +413,8 @@ get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
412 } 413 }
413 if (get_path != NULL) 414 if (get_path != NULL)
414 { 415 {
416 unsigned int i;
417
415 fprintf (stderr, "GET (%u) Path: ", 418 fprintf (stderr, "GET (%u) Path: ",
416 test_get->uid); 419 test_get->uid);
417 for (i = 0; i < get_path_length; i++) 420 for (i = 0; i < get_path_length; i++)
@@ -485,29 +488,20 @@ put_disconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
485 488
486 489
487/** 490/**
488 * Called when the PUT request has been transmitted to the DHT service. 491 * Schedule the GET requests
489 * Schedule the GET request for some time in the future.
490 */ 492 */
491static void 493static void
492put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 494start_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
493{ 495{
494 struct TestPutContext *test_put = cls;
495 unsigned long long i; 496 unsigned long long i;
496 unsigned long long j; 497 unsigned long long j;
497 struct TestGetContext *test_get; 498 struct TestGetContext *test_get;
498 499
499 outstanding_puts--; 500#if VERBOSE
500 puts_completed++;
501 GNUNET_SCHEDULER_cancel (test_put->task);
502 test_put->task =
503 GNUNET_SCHEDULER_add_now (&put_disconnect_task, test_put);
504 if (puts_completed != num_peers * num_peers)
505 return;
506
507 GNUNET_assert (outstanding_puts == 0);
508 fprintf (stderr, 501 fprintf (stderr,
509 "Issuing %llu GETs\n", 502 "Issuing %llu GETs\n",
510 num_peers * num_peers); 503 num_peers * num_peers);
504#endif
511 for (i = 0; i < num_peers; i++) 505 for (i = 0; i < num_peers; i++)
512 for (j = 0; j < num_peers; j++) 506 for (j = 0; j < num_peers; j++)
513 { 507 {
@@ -524,6 +518,29 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
524 518
525 519
526/** 520/**
521 * Called when the PUT request has been transmitted to the DHT service.
522 */
523static void
524put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
525{
526 struct TestPutContext *test_put = cls;
527
528 outstanding_puts--;
529 puts_completed++;
530 GNUNET_SCHEDULER_cancel (test_put->task);
531 test_put->task =
532 GNUNET_SCHEDULER_add_now (&put_disconnect_task, test_put);
533 if (puts_completed != num_peers * num_peers)
534 return;
535
536 GNUNET_assert (outstanding_puts == 0);
537 GNUNET_SCHEDULER_add_delayed (START_DELAY,
538 &start_gets,
539 NULL);
540}
541
542
543/**
527 * Set up some data, and call API PUT function 544 * Set up some data, and call API PUT function
528 */ 545 */
529static void 546static void