aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_multipeer.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-02-02 11:54:21 +0000
committerNathan S. Evans <evans@in.tum.de>2011-02-02 11:54:21 +0000
commit0aa66524bd2ef85668ba8de14792eb39480b59ba (patch)
treec84691a6fad3cbdbcc963e6194ba2b49971963a3 /src/dht/test_dht_multipeer.c
parent3b3eb36e3a01c7046fe4c9a3c4bb7834d83442d6 (diff)
downloadgnunet-0aa66524bd2ef85668ba8de14792eb39480b59ba.tar.gz
gnunet-0aa66524bd2ef85668ba8de14792eb39480b59ba.zip
path tracking commit, hopefully a fix for dht_api connect bug, needs tested
Diffstat (limited to 'src/dht/test_dht_multipeer.c')
-rw-r--r--src/dht/test_dht_multipeer.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c
index 24618230a..e4d1a7d20 100644
--- a/src/dht/test_dht_multipeer.c
+++ b/src/dht/test_dht_multipeer.c
@@ -53,6 +53,8 @@
53 53
54#define MAX_OUTSTANDING_GETS 10 54#define MAX_OUTSTANDING_GETS 10
55 55
56#define PATH_TRACKING GNUNET_YES
57
56/* Structs */ 58/* Structs */
57 59
58struct TestPutContext 60struct TestPutContext
@@ -206,6 +208,8 @@ static unsigned int total_connections;
206 */ 208 */
207static unsigned int failed_connections; 209static unsigned int failed_connections;
208 210
211enum GNUNET_DHT_RouteOption route_option;
212
209/* Task handle to use to schedule test failure */ 213/* Task handle to use to schedule test failure */
210GNUNET_SCHEDULER_TaskIdentifier die_task; 214GNUNET_SCHEDULER_TaskIdentifier die_task;
211 215
@@ -224,7 +228,6 @@ static double connect_topology_option_modifier = 0.0;
224/* Global return value (0 for success, anything else for failure) */ 228/* Global return value (0 for success, anything else for failure) */
225static int ok; 229static int ok;
226 230
227
228/** 231/**
229 * Check whether peers successfully shut down. 232 * Check whether peers successfully shut down.
230 */ 233 */
@@ -395,13 +398,30 @@ void get_result_iterator (void *cls,
395 struct TestGetContext *test_get = cls; 398 struct TestGetContext *test_get = cls;
396 GNUNET_HashCode search_key; /* Key stored under */ 399 GNUNET_HashCode search_key; /* Key stored under */
397 char original_data[TEST_DATA_SIZE]; /* Made up data to store */ 400 char original_data[TEST_DATA_SIZE]; /* Made up data to store */
398 401 unsigned int i;
399 memset(original_data, test_get->uid, sizeof(original_data)); 402 memset(original_data, test_get->uid, sizeof(original_data));
400 GNUNET_CRYPTO_hash(original_data, TEST_DATA_SIZE, &search_key); 403 GNUNET_CRYPTO_hash(original_data, TEST_DATA_SIZE, &search_key);
401 404
402 if (test_get->succeeded == GNUNET_YES) 405 if (test_get->succeeded == GNUNET_YES)
403 return; /* Get has already been successful, probably ending now */ 406 return; /* Get has already been successful, probably ending now */
404 407
408#if PATH_TRACKING
409 if (put_path != NULL)
410 {
411 fprintf(stderr, "PUT Path: ");
412 for (i = 0; put_path[i] != NULL; i++)
413 fprintf(stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s(put_path[i]));
414 fprintf(stderr, "\n");
415 }
416 if (get_path != NULL)
417 {
418 fprintf(stderr, "GET Path: ");
419 for (i = 0; get_path[i] != NULL; i++)
420 fprintf(stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s(get_path[i]));
421 fprintf(stderr, "\n");
422 }
423#endif
424
405 if ((0 != memcmp(&search_key, key, sizeof (GNUNET_HashCode))) || (0 != memcmp(original_data, data, sizeof(original_data)))) 425 if ((0 != memcmp(&search_key, key, sizeof (GNUNET_HashCode))) || (0 != memcmp(original_data, data, sizeof(original_data))))
406 { 426 {
407 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Key or data is not the same as was inserted!\n"); 427 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Key or data is not the same as was inserted!\n");
@@ -448,7 +468,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
448 GNUNET_BLOCK_TYPE_TEST, 468 GNUNET_BLOCK_TYPE_TEST,
449 &key, 469 &key,
450 DEFAULT_GET_REPLICATION, 470 DEFAULT_GET_REPLICATION,
451 GNUNET_DHT_RO_NONE, 471 route_option,
452 NULL, 0, 472 NULL, 0,
453 NULL, 0, 473 NULL, 0,
454 &get_result_iterator, 474 &get_result_iterator,
@@ -517,7 +537,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
517 GNUNET_DHT_put(test_put->dht_handle, 537 GNUNET_DHT_put(test_put->dht_handle,
518 &key, 538 &key,
519 DEFAULT_PUT_REPLICATION, 539 DEFAULT_PUT_REPLICATION,
520 GNUNET_DHT_RO_NONE, 540 route_option,
521 GNUNET_BLOCK_TYPE_TEST, 541 GNUNET_BLOCK_TYPE_TEST,
522 sizeof(data), data, 542 sizeof(data), data,
523 GNUNET_TIME_UNIT_FOREVER_ABS, 543 GNUNET_TIME_UNIT_FOREVER_ABS,
@@ -758,6 +778,12 @@ run (void *cls,
758 char * connect_topology_option_str; 778 char * connect_topology_option_str;
759 char * connect_topology_option_modifier_string; 779 char * connect_topology_option_modifier_string;
760 780
781#if PATH_TRACKING
782 route_option = GNUNET_DHT_RO_RECORD_ROUTE;
783#else
784 route_option = GNUNET_DHT_RO_NONE;
785#endif
786
761 /* Get path from configuration file */ 787 /* Get path from configuration file */
762 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory)) 788 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory))
763 { 789 {