diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-07-20 15:13:06 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-07-20 15:13:06 +0000 |
commit | a27eb5beb5872854d2f7ff540a28019eaa83da70 (patch) | |
tree | 261583c14adb7c927bcafb4531a92e4275002d67 /src/dht | |
parent | 27ee160b9c2bfd30a192db7f86585da8bc34e1cd (diff) | |
download | gnunet-a27eb5beb5872854d2f7ff540a28019eaa83da70.tar.gz gnunet-a27eb5beb5872854d2f7ff540a28019eaa83da70.zip |
add testcases to run on make check, fix dht a bit
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/Makefile.am | 5 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht.c | 15 | ||||
-rw-r--r-- | src/dht/test_dht_twopeer.c | 4 |
3 files changed, 15 insertions, 9 deletions
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am index e2d80a308..64c6371a8 100644 --- a/src/dht/Makefile.am +++ b/src/dht/Makefile.am | |||
@@ -118,7 +118,10 @@ check_PROGRAMS = \ | |||
118 | test_dht_multipeer \ | 118 | test_dht_multipeer \ |
119 | test_dhtlog | 119 | test_dhtlog |
120 | 120 | ||
121 | TESTS = test_dht_api $(check_SCRIPTS) | 121 | TESTS = test_dht_api $(check_SCRIPTS) \ |
122 | test_dhtlog \ | ||
123 | test_dht_twopeer \ | ||
124 | test_dht_twopeer_put_get | ||
122 | 125 | ||
123 | test_dht_api_SOURCES = \ | 126 | test_dht_api_SOURCES = \ |
124 | test_dht_api.c | 127 | test_dht_api.c |
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index eb577de47..6fe910ecd 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -1377,6 +1377,7 @@ handle_dht_find_peer (void *cls, | |||
1377 | struct DHT_MessageContext *message_context) | 1377 | struct DHT_MessageContext *message_context) |
1378 | { | 1378 | { |
1379 | struct GNUNET_MessageHeader *find_peer_result; | 1379 | struct GNUNET_MessageHeader *find_peer_result; |
1380 | struct DHT_MessageContext *new_msg_ctx; | ||
1380 | size_t hello_size; | 1381 | size_t hello_size; |
1381 | size_t tsize; | 1382 | size_t tsize; |
1382 | 1383 | ||
@@ -1414,12 +1415,13 @@ handle_dht_find_peer (void *cls, | |||
1414 | "`%s': Sending hello size %d to client.\n", | 1415 | "`%s': Sending hello size %d to client.\n", |
1415 | "DHT", hello_size); | 1416 | "DHT", hello_size); |
1416 | #endif | 1417 | #endif |
1417 | if (message_context->bloom != NULL) | ||
1418 | GNUNET_CONTAINER_bloomfilter_clear(message_context->bloom); | ||
1419 | 1418 | ||
1420 | message_context->hop_count = 0; | 1419 | new_msg_ctx = GNUNET_malloc(sizeof(struct DHT_MessageContext)); |
1421 | message_context->peer = &my_identity; | 1420 | memcpy(new_msg_ctx, message_context, sizeof(struct DHT_MessageContext)); |
1422 | route_result_message(cls, find_peer_result, message_context); | 1421 | new_msg_ctx->peer = &my_identity; |
1422 | new_msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | ||
1423 | new_msg_ctx->hop_count = 0; | ||
1424 | route_result_message(cls, find_peer_result, new_msg_ctx); | ||
1423 | //send_reply_to_client(message_context->client, find_peer_result, message_context->unique_id); | 1425 | //send_reply_to_client(message_context->client, find_peer_result, message_context->unique_id); |
1424 | GNUNET_free(find_peer_result); | 1426 | GNUNET_free(find_peer_result); |
1425 | } | 1427 | } |
@@ -2397,7 +2399,8 @@ void handle_core_connect (void *cls, | |||
2397 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2399 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2398 | "%s:%s Receives core connect message for peer %s distance %d!\n", my_short_id, "dht", GNUNET_i2s(peer), distance); | 2400 | "%s:%s Receives core connect message for peer %s distance %d!\n", my_short_id, "dht", GNUNET_i2s(peer), distance); |
2399 | #endif | 2401 | #endif |
2400 | 2402 | if (datacache != NULL) | |
2403 | GNUNET_DATACACHE_put(datacache, &peer->hashPubKey, sizeof(struct GNUNET_PeerIdentity), (const char *)peer, 0, GNUNET_TIME_absolute_get_forever()); | ||
2401 | ret = try_add_peer(peer, | 2404 | ret = try_add_peer(peer, |
2402 | find_current_bucket(&peer->hashPubKey), | 2405 | find_current_bucket(&peer->hashPubKey), |
2403 | latency, | 2406 | latency, |
diff --git a/src/dht/test_dht_twopeer.c b/src/dht/test_dht_twopeer.c index c9ceca1f8..095bc7cb7 100644 --- a/src/dht/test_dht_twopeer.c +++ b/src/dht/test_dht_twopeer.c | |||
@@ -154,7 +154,7 @@ void get_result_iterator (void *cls, | |||
154 | struct PeerGetContext *get_context = cls; | 154 | struct PeerGetContext *get_context = cls; |
155 | if (0 != memcmp(&get_context->peer->hashPubKey, key, sizeof (GNUNET_HashCode))) | 155 | if (0 != memcmp(&get_context->peer->hashPubKey, key, sizeof (GNUNET_HashCode))) |
156 | { | 156 | { |
157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Key returned is not the same key as was searched for!\n"); | 157 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Key returned is not the same key as was searched for!\n"); |
158 | GNUNET_SCHEDULER_cancel(sched, die_task); | 158 | GNUNET_SCHEDULER_cancel(sched, die_task); |
159 | GNUNET_SCHEDULER_add_now(sched, &end_badly, "key mismatch in get response!\n"); | 159 | GNUNET_SCHEDULER_add_now(sched, &end_badly, "key mismatch in get response!\n"); |
160 | return; | 160 | return; |
@@ -182,7 +182,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
182 | { | 182 | { |
183 | struct PeerGetContext *get_context = cls; | 183 | struct PeerGetContext *get_context = cls; |
184 | 184 | ||
185 | get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, GNUNET_TIME_relative_get_forever(), 130, &get_context->peer->hashPubKey, &get_result_iterator, get_context, NULL, NULL); | 185 | get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, GNUNET_TIME_relative_get_forever(), 0, &get_context->peer->hashPubKey, &get_result_iterator, get_context, NULL, NULL); |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||