From a27eb5beb5872854d2f7ff540a28019eaa83da70 Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Tue, 20 Jul 2010 15:13:06 +0000 Subject: [PATCH] add testcases to run on make check, fix dht a bit --- src/dht/Makefile.am | 5 ++++- src/dht/gnunet-service-dht.c | 15 +++++++++------ 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 = \ test_dht_multipeer \ test_dhtlog -TESTS = test_dht_api $(check_SCRIPTS) +TESTS = test_dht_api $(check_SCRIPTS) \ + test_dhtlog \ + test_dht_twopeer \ + test_dht_twopeer_put_get test_dht_api_SOURCES = \ 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, struct DHT_MessageContext *message_context) { struct GNUNET_MessageHeader *find_peer_result; + struct DHT_MessageContext *new_msg_ctx; size_t hello_size; size_t tsize; @@ -1414,12 +1415,13 @@ handle_dht_find_peer (void *cls, "`%s': Sending hello size %d to client.\n", "DHT", hello_size); #endif - if (message_context->bloom != NULL) - GNUNET_CONTAINER_bloomfilter_clear(message_context->bloom); - message_context->hop_count = 0; - message_context->peer = &my_identity; - route_result_message(cls, find_peer_result, message_context); + new_msg_ctx = GNUNET_malloc(sizeof(struct DHT_MessageContext)); + memcpy(new_msg_ctx, message_context, sizeof(struct DHT_MessageContext)); + new_msg_ctx->peer = &my_identity; + new_msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); + new_msg_ctx->hop_count = 0; + route_result_message(cls, find_peer_result, new_msg_ctx); //send_reply_to_client(message_context->client, find_peer_result, message_context->unique_id); GNUNET_free(find_peer_result); } @@ -2397,7 +2399,8 @@ void handle_core_connect (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s:%s Receives core connect message for peer %s distance %d!\n", my_short_id, "dht", GNUNET_i2s(peer), distance); #endif - + if (datacache != NULL) + GNUNET_DATACACHE_put(datacache, &peer->hashPubKey, sizeof(struct GNUNET_PeerIdentity), (const char *)peer, 0, GNUNET_TIME_absolute_get_forever()); ret = try_add_peer(peer, find_current_bucket(&peer->hashPubKey), 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, struct PeerGetContext *get_context = cls; if (0 != memcmp(&get_context->peer->hashPubKey, key, sizeof (GNUNET_HashCode))) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Key returned is not the same key as was searched for!\n"); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Key returned is not the same key as was searched for!\n"); GNUNET_SCHEDULER_cancel(sched, die_task); GNUNET_SCHEDULER_add_now(sched, &end_badly, "key mismatch in get response!\n"); return; @@ -182,7 +182,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) { struct PeerGetContext *get_context = cls; - 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); + 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); } -- 2.25.1