add testcases to run on make check, fix dht a bit
authorNathan S. Evans <evans@in.tum.de>
Tue, 20 Jul 2010 15:13:06 +0000 (15:13 +0000)
committerNathan S. Evans <evans@in.tum.de>
Tue, 20 Jul 2010 15:13:06 +0000 (15:13 +0000)
src/dht/Makefile.am
src/dht/gnunet-service-dht.c
src/dht/test_dht_twopeer.c

index e2d80a308887719284ddc90812c8bb6816e0807f..64c6371a8776188fd4bf1b66a8e02db7335581de 100644 (file)
@@ -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
index eb577de47f02054d81c18cfa349d98feec61d756..6fe910ecdb661152362fae18c9641e631ead02f1 100644 (file)
@@ -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,
index c9ceca1f8922ce7d5b65d3c4797f036216f232bb..095bc7cb724ff2c28e195ccec592276b4892699f 100644 (file)
@@ -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);
 }