gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r20786 - in gnunet/src/gns: . testdb testkeys


From: gnunet
Subject: [GNUnet-SVN] r20786 - in gnunet/src/gns: . testdb testkeys
Date: Tue, 27 Mar 2012 16:04:52 +0200

Author: schanzen
Date: 2012-03-27 16:04:52 +0200 (Tue, 27 Mar 2012)
New Revision: 20786

Added:
   gnunet/src/gns/test_gns_defaults.conf
   gnunet/src/gns/test_gns_dht_alice.conf
   gnunet/src/gns/test_gns_dht_bob.conf
   gnunet/src/gns/test_gns_dht_dave.conf
   gnunet/src/gns/test_gns_dht_threepeer.c
   gnunet/src/gns/testdb/
   gnunet/src/gns/testdb/sqlite-alice.db
   gnunet/src/gns/testdb/sqlite-alice.db.bak
   gnunet/src/gns/testdb/sqlite-bob.db
   gnunet/src/gns/testdb/sqlite-dave.db
   gnunet/src/gns/testkeys/
   
gnunet/src/gns/testkeys/KAILNI4SSH8M6QR6S8QRSGBBLMA8377HL6F60TEMO7S7TT1OR8CG.zkey
   
gnunet/src/gns/testkeys/KRPVFMVBFKEGUS6KL8SFPEUMORFPP9ERE6AC98KO9NADBMPF7TOG.zkey
   
gnunet/src/gns/testkeys/N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey
Removed:
   gnunet/src/gns/test_gns_twopeer.c
Modified:
   gnunet/src/gns/Makefile.am
   gnunet/src/gns/gnunet-service-gns_interceptor.c
   gnunet/src/gns/gnunet-service-gns_resolver.c
   gnunet/src/gns/gnunet-service-gns_resolver.h
   gnunet/src/gns/plugin_block_gns.c
Log:
-lots of fixes, new dht test


Modified: gnunet/src/gns/Makefile.am
===================================================================
--- gnunet/src/gns/Makefile.am  2012-03-27 14:00:09 UTC (rev 20785)
+++ gnunet/src/gns/Makefile.am  2012-03-27 14:04:52 UTC (rev 20786)
@@ -39,7 +39,8 @@
   test_gns_simple_zkey_lookup \
   test_gns_dht_delegated_lookup \
   test_gns_pseu_shorten \
-  test_gns_max_queries
+  test_gns_max_queries \
+  test_gns_dht_threepeer
 
 
 #  test_gns_simple_lookup
@@ -50,16 +51,18 @@
 plugin_LTLIBRARIES = \
   libgnunet_plugin_block_gns.la
 
-#test_gns_twopeer_SOURCES = \
-#  test_gns_twopeer.c
-#test_gns_twopeer_LDADD = \
-#  $(top_builddir)/src/util/libgnunetutil.la \
-#  $(top_builddir)/src/namestore/libgnunetnamestore.la \
-#  $(top_builddir)/src/testing/libgnunettesting.la
-#test_gns_twopeer_DEPENDENCIES = \
-#  $(top_builddir)/src/util/libgnunetutil.la \
-#  $(top_builddir)/src/namestore/libgnunetnamestore.la \
-#  $(top_builddir)/src/testing/libgnunettesting.la
+test_gns_dht_threepeer_SOURCES = \
+  test_gns_dht_threepeer.c
+test_gns_dht_threepeer_LDADD = \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/namestore/libgnunetnamestore.la \
+  $(top_builddir)/src/gns/libgnunetgns.la \
+  $(top_builddir)/src/testing/libgnunettesting.la
+test_gns_dht_threepeer_DEPENDENCIES = \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/namestore/libgnunetnamestore.la \
+  $(top_builddir)/src/gns/libgnunetgns.la \
+  $(top_builddir)/src/testing/libgnunettesting.la
 
 test_gns_simple_lookup_SOURCES = \
   test_gns_simple_lookup.c

Modified: gnunet/src/gns/gnunet-service-gns_interceptor.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_interceptor.c     2012-03-27 14:00:09 UTC 
(rev 20785)
+++ gnunet/src/gns/gnunet-service-gns_interceptor.c     2012-03-27 14:04:52 UTC 
(rev 20786)
@@ -67,6 +67,11 @@
 static struct GNUNET_CRYPTO_RsaPrivateKey *our_key;
 
 /**
+ * Default timeout
+ */
+static struct GNUNET_TIME_Relative default_lookup_timeout;
+
+/**
  * Reply to dns request with the result from our lookup.
  *
  * @param cls the closure to the request (an InterceptLookupHandle)
@@ -240,7 +245,7 @@
   /* Start resolution in our zone */
   gns_resolver_lookup_record(our_zone, q->type, q->name,
                              our_key,
-                             GNUNET_GNS_DEFAULT_LOOKUP_TIMEOUT,
+                             default_lookup_timeout,
                              &reply_to_dns, ilh);
 }
 
@@ -341,6 +346,8 @@
                      struct GNUNET_CRYPTO_RsaPrivateKey *key,
                      const struct GNUNET_CONFIGURATION_Handle *c)
 {
+  unsigned long long default_lookup_timeout_secs = 0;
+
   GNUNET_log(GNUNET_ERROR_TYPE_INFO,
              "DNS hijacking enabled... connecting to service.\n");
 
@@ -353,6 +360,17 @@
                                   GNUNET_DNS_FLAG_PRE_RESOLUTION,
                                   &handle_dns_request, /* rh */
                                   NULL); /* Closure */
+
+  if (GNUNET_OK ==
+      GNUNET_CONFIGURATION_get_value_number(c, "gns",
+                                            "DEFAULT_LOOKUP_TIMEOUT",
+                                            &default_lookup_timeout_secs))
+  {
+    default_lookup_timeout = GNUNET_TIME_relative_multiply(
+                                                  GNUNET_TIME_UNIT_SECONDS,
+                                                  default_lookup_timeout_secs);
+  }
+
   if (NULL == dns_handle)
   {
     GNUNET_log(GNUNET_ERROR_TYPE_ERROR,

Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c        2012-03-27 14:00:09 UTC 
(rev 20785)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c        2012-03-27 14:04:52 UTC 
(rev 20786)
@@ -69,6 +69,8 @@
  */
 static struct GNUNET_CRYPTO_ShortHashCode local_zone;
 
+static unsigned long long rid = 0;
+
 /**
  * Namestore calls this function if we have record for this name.
  * (or with rd_count=0 to indicate no matches)
@@ -470,8 +472,8 @@
   ResolverCleanupContinuation cont = cls;
   
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_CLEANUP: Terminating background lookup for %s\n",
-             rh->name);
+             "GNS_CLEANUP-%d: Terminating background lookup for %s\n",
+             rh->id, rh->name);
   GNUNET_DHT_get_stop(rh->get_handle);
   rh->get_handle = NULL;
   rh->proc(rh->proc_cls, rh, 0, NULL);
@@ -601,8 +603,8 @@
   char new_name[MAX_DNS_NAME_LENGTH];
 
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_REC: dht lookup for query %s timed out.\n",
-             rh->name);
+             "GNS_PHASE_REC-%d: dht lookup for query %s (%ds)timed out.\n",
+             rh->id, rh->name, rh->timeout.rel_value);
   /**
    * Start resolution in bg
    */
@@ -612,8 +614,8 @@
                   rh->name, GNUNET_GNS_TLD);
 
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_REC: Starting background lookup for %s type %d\n",
-             new_name, rlh->record_type);
+             "GNS_PHASE_REC-%d: Starting background lookup for %s type %d\n",
+             rh->id, new_name, rlh->record_type);
 
   gns_resolver_lookup_record(rh->authority,
                              rlh->record_type,
@@ -664,16 +666,17 @@
   char* rd_data = (char*)data;
   int i;
   int rd_size;
-  
+
+  rh = (struct ResolverHandle *)cls;
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_REC: got dht result (size=%d)\n", size);
+             "GNS_PHASE_REC-%d: got dht result (size=%d)\n", rh->id, size);
   
   if (data == NULL)
     return;
 
   //FIXME maybe check expiration here, check block type
   
-  rh = (struct ResolverHandle *)cls;
+  
   rlh = (struct RecordLookupHandle *) rh->proc_cls;
   nrb = (struct GNSNameRecordBlock*)data;
   
@@ -707,21 +710,25 @@
                                                                num_records,
                                                                rd))
     {
-      GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Error deserializing data!\n");
+      GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+                 "GNS_PHASE_REC-%d: Error deserializing data!\n", rh->id);
       return;
     }
 
     for (i=0; i<num_records; i++)
     {
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-               "GNS_PHASE_REC: Got name: %s (wanted %s)\n", name, rh->name);
+               "GNS_PHASE_REC-%d: Got name: %s (wanted %s)\n",
+               rh->id, name, rh->name);
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-               "GNS_PHASE_REC: Got type: %d\n",
-               rd[i].record_type);
+               "GNS_PHASE_REC-%d: Got type: %d\n",
+               rh->id, rd[i].record_type);
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-               "GNS_PHASE_REC: Got data length: %d\n", rd[i].data_size);
+               "GNS_PHASE_REC-%d: Got data length: %d\n",
+               rh->id, rd[i].data_size);
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-               "GNS_PHASE_REC: Got flag %d\n", rd[i].flags);
+               "GNS_PHASE_REC-%d: Got flag %d\n",
+               rh->id, rd[i].flags);
     
      if ((strcmp(name, rh->name) == 0) &&
          (rd[i].record_type == rlh->record_type))
@@ -782,8 +789,8 @@
   GNUNET_CRYPTO_hash_to_enc (&lookup_key, &lookup_key_string);
   
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_REC: starting dht lookup for %s with key: %s\n",
-             rh->name, (char*)&lookup_key_string);
+             "GNS_PHASE_REC-%d: starting dht lookup for %s with key: %s\n",
+             rh->id, rh->name, (char*)&lookup_key_string);
 
   //rh->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   rh->dht_heap_node = NULL;
@@ -797,7 +804,7 @@
     {
 
     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-               "GNS_PHASE_REC: Adjusting timeout\n");
+               "GNS_PHASE_REC-%d: Adjusting timeout\n", rh->id);
     /*
      * Set timeout for authority lookup phase to 1/2
      */
@@ -823,8 +830,8 @@
       rh_heap_root->dht_heap_node = NULL;
       
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-           "GNS_PHASE_REC: Replacing oldest background query for %s\n",
-                 rh_heap_root->name);
+           "GNS_PHASE_REC-%d: Replacing oldest background query for %s\n",
+                 rh->id, rh_heap_root->name);
       rh_heap_root->proc(rh_heap_root->proc_cls,
                          rh_heap_root,
                          0,
@@ -904,12 +911,12 @@
      * Lookup terminated and no results
      */
     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-         "GNS_PHASE_REC: Namestore lookup for %s terminated without results\n",
-         name);
+      "GNS_PHASE_REC-%d: Namestore lookup for %s terminated without results\n",
+         rh->id, name);
 
     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-               "GNS_PHASE_REC: Record %s unknown in namestore\n",
-               rh->name);
+               "GNS_PHASE_REC-%d: Record %s unknown in namestore\n",
+               rh->id, rh->name);
     /**
      * Our zone and no result? Cannot resolve TT
      */
@@ -921,8 +928,8 @@
   {
     
     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-              "GNS_PHASE_REC: Processing additional result %s from 
namestore\n",
-              name);
+           "GNS_PHASE_REC-%d: Processing additional result %s from 
namestore\n",
+              rh->id, name);
     int i;
     for (i=0; i<rd_count;i++)
     {
@@ -934,7 +941,8 @@
           == 0)
       {
         GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                   "GNS_PHASE_REC: This record is expired. Skipping\n");
+                   "GNS_PHASE_REC-%d: This record is expired. Skipping\n",
+                   rh->id);
         continue;
       }
       
@@ -948,14 +956,14 @@
     if (rh->answered == 0)
     {
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 
-                 "GNS_PHASE_REC: No answers found. This is odd!\n");
+                 "GNS_PHASE_REC-%d: No answers found. This is odd!\n", rh->id);
       rh->proc(rh->proc_cls, rh, 0, NULL);
       return;
     }
     
     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-               "GNS_PHASE_REC: Found %d answer(s) to query in %d records!\n",
-               rh->answered, rd_count);
+               "GNS_PHASE_REC-%d: Found %d answer(s) to query in %d 
records!\n",
+               rh->id, rh->answered, rd_count);
 
     rh->proc(rh->proc_cls, rh, rd_count, rd);
   }
@@ -1012,8 +1020,8 @@
   char new_name[MAX_DNS_NAME_LENGTH];
 
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_DELEGATE_DHT: dht lookup for query %s timed out.\n",
-             rh->authority_name);
+         "GNS_PHASE_DELEGATE_DHT-%d: dht lookup for query %s (%ds)timed 
out.\n",
+         rh->id, rh->authority_name, rh->timeout.rel_value);
 
   rh->status |= TIMED_OUT;
 
@@ -1044,8 +1052,8 @@
   strcpy(rh->name, new_name);
 
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-           "GNS_PHASE_DELEGATE_DHT: Starting background query for %s type 
%d\n",
-             rh->name, rlh->record_type);
+        "GNS_PHASE_DELEGATE_DHT-%d: Starting background query for %s type 
%d\n",
+        rh->id, rh->name, rlh->record_type);
 
   gns_resolver_lookup_record(rh->authority,
                              rlh->record_type,
@@ -1115,16 +1123,15 @@
   int rd_size;
   struct GNUNET_CRYPTO_ShortHashCode zone, name_hash;
   GNUNET_HashCode zone_hash_double, name_hash_double;
+
+  rh = (struct ResolverHandle *)cls;
   
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_DELEGATE_DHT: Got DHT result\n");
+             "GNS_PHASE_DELEGATE_DHT-%d: Got DHT result\n", rh->id);
 
   if (data == NULL)
     return;
   
-  //FIXME check expiration?
-  
-  rh = (struct ResolverHandle *)cls;
   nrb = (struct GNSNameRecordBlock*)data;
   
   /* stop dht lookup and timeout task */
@@ -1152,33 +1159,36 @@
                                                                rd))
     {
       GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
-                 "GNS_PHASE_DELEGATE_DHT: Error deserializing data!\n");
+                 "GNS_PHASE_DELEGATE_DHT-%d: Error deserializing data!\n",
+                 rh->id);
       return;
     }
 
     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-               "GNS_PHASE_DELEGATE_DHT: Got name: %s (wanted %s)\n",
-               name, rh->authority_name);
+               "GNS_PHASE_DELEGATE_DHT-%d: Got name: %s (wanted %s)\n",
+               rh->id, name, rh->authority_name);
     for (i=0; i<num_records; i++)
     {
     
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                "GNS_PHASE_DELEGATE_DHT: Got name: %s (wanted %s)\n",
-                name, rh->authority_name);
+                "GNS_PHASE_DELEGATE_DHT-%d: Got name: %s (wanted %s)\n",
+                rh->id, name, rh->authority_name);
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                 "GNS_PHASE_DELEGATE_DHT: Got type: %d (wanted %d)\n",
-                 rd[i].record_type, GNUNET_GNS_RECORD_PKEY);
+                 "GNS_PHASE_DELEGATE_DHT-%d: Got type: %d (wanted %d)\n",
+                 rh->id, rd[i].record_type, GNUNET_GNS_RECORD_PKEY);
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                 "GNS_PHASE_DELEGATE_DHT: Got data length: %d\n",
-                 rd[i].data_size);
+                 "GNS_PHASE_DELEGATE_DHT-%d: Got data length: %d\n",
+                 rh->id, rd[i].data_size);
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                 "GNS_PHASE_DELEGATE_DHT: Got flag %d\n", rd[i].flags);
+                 "GNS_PHASE_DELEGATE_DHT-%d: Got flag %d\n",
+                 rh->id, rd[i].flags);
 
       if ((strcmp(name, rh->authority_name) == 0) &&
           (rd[i].record_type == GNUNET_GNS_RECORD_PKEY))
       {
         GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                   "GNS_PHASE_DELEGATE_DHT: Authority found in DHT\n");
+                   "GNS_PHASE_DELEGATE_DHT-%d: Authority found in DHT\n",
+                   rh->id);
         rh->answered = 1;
         memcpy(&rh->authority, rd[i].data, sizeof(struct 
GNUNET_CRYPTO_ShortHashCode));
         struct AuthorityChain *auth =
@@ -1229,8 +1239,8 @@
      * FIXME in this case. should we ask namestore again?
      */
     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-         "GNS_PHASE_DELEGATE_DHT: Answer from DHT for %s. Yet to resolve: 
%s\n",
-               rh->authority_name, rh->name);
+      "GNS_PHASE_DELEGATE_DHT-%d: Answer from DHT for %s. Yet to resolve: 
%s\n",
+      rh->id, rh->authority_name, rh->name);
     if (strcmp(rh->name, "") == 0)
     {
       rh->proc(rh->proc_cls, rh, 0, NULL);
@@ -1248,8 +1258,8 @@
    * promote back
    */
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_DELEGATE_DHT: Adding %s back to %s\n",
-             rh->authority_name, rh->name);
+             "GNS_PHASE_DELEGATE_DHT-%d: Adding %s back to %s\n",
+             rh->id, rh->authority_name, rh->name);
   if (strcmp(rh->name, "") == 0)
     strcpy(rh->name, rh->authority_name);
   else
@@ -1257,9 +1267,10 @@
                   rh->name, rh->authority_name); //FIXME ret
   
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_DELEGATE_DHT: %s restored\n", rh->name);
+             "GNS_PHASE_DELEGATE_DHT-%d: %s restored\n", rh->id, rh->name);
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_DELEGATE_DHT: DHT authority lookup found no match!\n");
+           "GNS_PHASE_DELEGATE_DHT-%d: DHT authority lookup found no match!\n",
+           rh->id);
   rh->proc(rh->proc_cls, rh, 0, NULL);
 }
 
@@ -1416,8 +1427,8 @@
   if (rd_count == 0)
   {
     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-               "GNS_PHASE_REC: No records for %s found in DHT. Aborting\n",
-               rh->name);
+               "GNS_PHASE_REC-%d: No records for %s found in DHT. Aborting\n",
+               rh->id, rh->name);
     /* give up, cannot resolve */
     finish_lookup(rh, rlh, 0, NULL);
     free_resolver_handle(rh);
@@ -1426,7 +1437,7 @@
 
   /* results found yay */
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_REC: Record resolved from DHT!");
+             "GNS_PHASE_REC-%d: Record resolved from DHT!", rh->id);
 
   finish_lookup(rh, rlh, rd_count, rd);
   free_resolver_handle(rh);
@@ -1452,7 +1463,8 @@
   if (rd_count == 0)
   {
     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-               "GNS_PHASE_REC: NS returned no records. (status: %d)!\n",
+               "GNS_PHASE_REC-%d: NS returned no records. (status: %d)!\n",
+               rh->id,
                rh->status);
     
     /**
@@ -1482,7 +1494,7 @@
 
   /* results found yay */
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_REC: Record resolved from namestore!");
+             "GNS_PHASE_REC-%d: Record resolved from namestore!", rh->id);
 
   finish_lookup(rh, rlh, rd_count, rd);
 
@@ -1568,7 +1580,7 @@
   offset = strlen(name)-strlen(tld);
   if (strcmp(name+offset, tld) != 0)
   {
-    GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
                "%s is not in .%s TLD\n", name, tld);
     return GNUNET_NO;
   }
@@ -1597,14 +1609,16 @@
     if ((rlh->record_type == GNUNET_GNS_RECORD_PKEY))
     {
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                 "GNS_PHASE_DELEGATE_DHT: Resolved queried PKEY via DHT.\n");
+                 "GNS_PHASE_DELEGATE_DHT-%d: Resolved queried PKEY via DHT.\n",
+                 rh->id);
       finish_lookup(rh, rlh, rd_count, rd);
       free_resolver_handle(rh);
       return;
     }
     /* We resolved full name for delegation. resolving record */
     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-      "GNS_PHASE_DELEGATE_DHT: Resolved full name for delegation via DHT.\n");
+     "GNS_PHASE_DELEGATE_DHT-%d: Resolved full name for delegation via DHT.\n",
+     rh->id);
     strcpy(rh->name, "+\0");
     rh->proc = &handle_record_ns;
     resolve_record_ns(rh);
@@ -1617,16 +1631,17 @@
   if (is_canonical(rh->name))
   {
     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-               "GNS_PHASE_DELEGATE_DHT: Resolving canonical record %s in ns\n",
-               rh->name);
+             "GNS_PHASE_DELEGATE_DHT-%d: Resolving canonical record %s in 
ns\n",
+             rh->id,
+             rh->name);
     rh->proc = &handle_record_ns;
     resolve_record_ns(rh);
     return;
   }
   /* give up, cannot resolve */
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-    "GNS_PHASE_DELEGATE_DHT: Cannot fully resolve delegation for %s via 
DHT!\n",
-             rh->name);
+ "GNS_PHASE_DELEGATE_DHT-%d: Cannot fully resolve delegation for %s via 
DHT!\n",
+ rh->id, rh->name);
   finish_lookup(rh, rlh, 0, NULL);
   free_resolver_handle(rh);
 }
@@ -1677,8 +1692,8 @@
       rh_heap_root->dht_heap_node = NULL;
       
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-           "GNS_PHASE_DELEGATE_DHT: Replacing oldest background query for 
%s\n",
-                 rh_heap_root->authority_name);
+        "GNS_PHASE_DELEGATE_DHT-%d: Replacing oldest background query for 
%s\n",
+        rh->id, rh_heap_root->authority_name);
       
       rh_heap_root->proc(rh_heap_root->proc_cls,
                          rh_heap_root,
@@ -1729,14 +1744,16 @@
     {
       GNUNET_assert(rd_count == 1);
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                 "GNS_PHASE_DELEGATE_NS: Resolved queried PKEY in NS.\n");
+                 "GNS_PHASE_DELEGATE_NS-%d: Resolved queried PKEY in NS.\n",
+                 rh->id);
       finish_lookup(rh, rlh, rd_count, rd);
       free_resolver_handle(rh);
       return;
     }
     /* We resolved full name for delegation. resolving record */
     GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-               "GNS_PHASE_DELEGATE_NS: Resolved full name for delegation.\n");
+              "GNS_PHASE_DELEGATE_NS-%d: Resolved full name for delegation.\n",
+              rh->id);
     strcpy(rh->name, "+\0");
     rh->proc = &handle_record_ns;
     resolve_record_ns(rh);
@@ -1756,7 +1773,8 @@
     if (is_canonical(rh->name))
     {
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                 "GNS_PHASE_DELEGATE_NS: Resolving canonical record %s\n",
+                 "GNS_PHASE_DELEGATE_NS-%d: Resolving canonical record %s\n",
+                 rh->id,
                  rh->name);
       rh->proc = &handle_record_ns;
       resolve_record_ns(rh);
@@ -1765,8 +1783,9 @@
     {
       /* give up, cannot resolve */
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_DELEGATE_NS: Cannot fully resolve delegation for 
%s!\n",
-                rh->name);
+          "GNS_PHASE_DELEGATE_NS-%d: Cannot fully resolve delegation for 
%s!\n",
+          rh->id,
+          rh->name);
       finish_lookup(rh, rlh, rd_count, rd);
       //rlh->proc(rlh->proc_cls, 0, NULL);
     }
@@ -1774,8 +1793,8 @@
   }
   
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-         "GNS_PHASE_DELEGATE_NS: Trying to resolve delegation for %s via 
DHT\n",
-            rh->name);
+      "GNS_PHASE_DELEGATE_NS-%d: Trying to resolve delegation for %s via 
DHT\n",
+      rh->id, rh->name);
   rh->proc = &handle_delegation_dht;
   resolve_delegation_dht(rh);
 }
@@ -1809,12 +1828,12 @@
   struct GNUNET_TIME_Relative remaining_time;
   struct GNUNET_CRYPTO_ShortHashCode zone;
   char new_name[MAX_DNS_NAME_LENGTH];
-  
+ 
+  rh = (struct ResolverHandle *)cls; 
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_DELEGATE_NS: Got %d records from authority lookup\n",
-             rd_count);
+             "GNS_PHASE_DELEGATE_NS-%d: Got %d records from authority 
lookup\n",
+             rh->id, rd_count);
 
-  rh = (struct ResolverHandle *)cls;
   GNUNET_CRYPTO_short_hash(key,
                      sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
                      &zone);
@@ -1850,16 +1869,16 @@
     {
       /* simply promote back */
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                 "GNS_PHASE_DELEGATE_NS: Promoting %s back to name\n",
-                 rh->authority_name);
+                 "GNS_PHASE_DELEGATE_NS-%d: Promoting %s back to name\n",
+                 rh->id, rh->authority_name);
       strcpy(rh->name, rh->authority_name);
     }
     else
     {
       /* add back to existing name */
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                 "GNS_PHASE_DELEGATE_NS: Adding %s back to %s\n",
-                 rh->authority_name, rh->name);
+                 "GNS_PHASE_DELEGATE_NS-%d: Adding %s back to %s\n",
+                 rh->id, rh->authority_name, rh->name);
       //memset(new_name, 0, strlen(rh->name) + strlen(rh->authority_name) + 2);
       GNUNET_snprintf(new_name, MAX_DNS_NAME_LENGTH, "%s.%s",
                       rh->name, rh->authority_name);
@@ -1868,7 +1887,7 @@
       //strcpy(new_name+strlen(new_name), rh->authority_name);
       strcpy(rh->name, new_name);
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                 "GNS_PHASE_DELEGATE_NS: %s restored\n", rh->name);
+                 "GNS_PHASE_DELEGATE_NS-%d: %s restored\n", rh->id, rh->name);
     }
     rh->proc(rh->proc_cls, rh, 0, NULL);
     return;
@@ -1890,11 +1909,13 @@
          == 0)
     {
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                 "GNS_PHASE_DELEGATE_NS: This pkey is expired.\n");
+                 "GNS_PHASE_DELEGATE_NS-%d: This pkey is expired.\n",
+                 rh->id);
       if (remaining_time.rel_value == 0)
       {
         GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-                   "GNS_PHASE_DELEGATE_NS: This dht entry is expired.\n");
+                   "GNS_PHASE_DELEGATE_NS-%d: This dht entry is expired.\n",
+                   rh->id);
         rh->authority_chain_head->fresh = 0;
         rh->proc(rh->proc_cls, rh, 0, NULL);
         return;
@@ -1937,7 +1958,7 @@
    * no answers found
    */
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-    "GNS_PHASE_DELEGATE_NS: Authority lookup and no PKEY...\n");
+    "GNS_PHASE_DELEGATE_NS-%d: Authority lookup and no PKEY...\n", rh->id);
   rh->proc(rh->proc_cls, rh, 0, NULL);
 }
 
@@ -1951,7 +1972,8 @@
 resolve_delegation_ns(struct ResolverHandle *rh)
 {
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "GNS_PHASE_DELEGATE_NS: Resolving delegation for %s\n", rh->name);
+             "GNS_PHASE_DELEGATE_NS-%d: Resolving delegation for %s\n",
+             rh->id, rh->name);
   pop_tld(rh->name, rh->authority_name);
   GNUNET_NAMESTORE_lookup_record(namestore_handle,
                                  &rh->authority,
@@ -2007,6 +2029,7 @@
   rh = GNUNET_malloc(sizeof (struct ResolverHandle));
 
   rh->authority = zone;
+  rh->id = rid++;
   rh->proc_cls = rlh;
   rh->priv_key = key;
   rh->timeout = timeout;
@@ -2016,6 +2039,8 @@
     /*
      * Set timeout for authority lookup phase to 1/2
      */
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Timeout for lookup set to %ds\n", rh->timeout.rel_value);
     rh->timeout_task = GNUNET_SCHEDULER_add_delayed(
                                 GNUNET_TIME_relative_divide(timeout, 2),
                                                 &handle_lookup_timeout,
@@ -2299,6 +2324,7 @@
   {
     rh_bg = GNUNET_malloc(sizeof(struct ResolverHandle));
     memcpy(rh_bg, rh, sizeof(struct ResolverHandle));
+    rh_bg->id = rid++;
   }
 
   /* backtrack authorities for names */
@@ -2448,9 +2474,11 @@
   
   rh = GNUNET_malloc(sizeof (struct ResolverHandle));
   rh->authority = zone;
+  rh->id = rid++;
   rh->priv_key = key;
   rh->proc = &handle_delegation_ns_shorten;
   rh->proc_cls = nsh;
+  rh->id = rid++;
   
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Checking for TLD...\n");
@@ -2615,6 +2643,7 @@
   nah = GNUNET_malloc(sizeof (struct GetNameAuthorityHandle));
   rh = GNUNET_malloc(sizeof (struct ResolverHandle));
   rh->authority = zone;
+  rh->id = rid++;
   
   if (strcmp(GNUNET_GNS_TLD, name) == 0)
   {

Modified: gnunet/src/gns/gnunet-service-gns_resolver.h
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.h        2012-03-27 14:00:09 UTC 
(rev 20785)
+++ gnunet/src/gns/gnunet-service-gns_resolver.h        2012-03-27 14:04:52 UTC 
(rev 20786)
@@ -160,6 +160,11 @@
    */
   struct GNUNET_CONTAINER_HeapNode *dht_heap_node;
 
+  /**
+   * Id for resolution process
+   */
+  unsigned long long id;
+
 };
 
 

Modified: gnunet/src/gns/plugin_block_gns.c
===================================================================
--- gnunet/src/gns/plugin_block_gns.c   2012-03-27 14:00:09 UTC (rev 20785)
+++ gnunet/src/gns/plugin_block_gns.c   2012-03-27 14:04:52 UTC (rev 20786)
@@ -77,7 +77,7 @@
   uint32_t record_xquery;
   unsigned int record_match;
   
-  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "RB SIZE %d\n", reply_block_size);
+  //GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "RB SIZE %d\n", reply_block_size);
 
   if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
     return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
@@ -113,9 +113,9 @@
   GNUNET_CRYPTO_hash_to_enc (&query_key, &xor_exp);
   GNUNET_CRYPTO_hash_to_enc (query, &xor_got);
 
-  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "BLOCK_TEST for %s got %s expected %s\n",
-             name, (char*) &xor_got, (char*) &xor_exp);
+  //GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+  //           "BLOCK_TEST for %s got %s expected %s\n",
+  //           name, (char*) &xor_got, (char*) &xor_exp);
 
   /* Check query key against public key */
   if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key))
@@ -184,7 +184,6 @@
     GNUNET_BLOCK_mingle_hash(&chash, bf_mutator, &mhash);
     if (NULL != *bf)
     {
-      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Check BF\n");
       if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test(*bf, &mhash))
         return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
     }

Added: gnunet/src/gns/test_gns_defaults.conf
===================================================================
--- gnunet/src/gns/test_gns_defaults.conf                               (rev 0)
+++ gnunet/src/gns/test_gns_defaults.conf       2012-03-27 14:04:52 UTC (rev 
20786)
@@ -0,0 +1,75 @@
+[PATHS]
+SERVICEHOME = /tmp/test-gnunet-testing/
+DEFAULTCONFIG = test_testing_defaults.conf
+
+[resolver]
+PORT = 2564
+
+[transport]
+PORT = 2565
+PLUGINS = tcp
+
+[arm]
+PORT = 2566
+DEFAULTSERVICES = 
+
+[statistics]
+PORT = 2567
+
+[transport-tcp]
+PORT = 2568
+BINDTO = 127.0.0.1
+
+[peerinfo]
+PORT = 2569
+
+[core]
+PORT = 2570
+
+[testing]
+NUM_PEERS = 5
+WEAKRANDOM = YES
+F2F = YES
+HOSTKEYSFILE = ../../contrib/testing_hostkeys.dat
+
+[dht]
+AUTOSTART = NO
+
+[nat]
+DISABLEV6 = YES
+ENABLE_UPNP = NO
+BEHIND_NAT = NO
+ALLOW_NAT = NO
+INTERNAL_ADDRESS = 127.0.0.1
+EXTERNAL_ADDRESS = 127.0.0.1
+USE_LOCALADDR = NO
+
+[dns]
+AUTOSTART = NO
+
+[nse]
+AUTOSTART = NO
+
+[mesh]
+AUTOSTART = NO
+
+[datastore]
+AUTOSTART = NO
+
+[fs]
+AUTOSTART = NO
+
+[dv]
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
+
+[vpn]
+AUTOSTART = NO
+
+[gns]
+AUTOSTART = NO
+
+[namestore]
+AUTOSTART = NO
\ No newline at end of file

Added: gnunet/src/gns/test_gns_dht_alice.conf
===================================================================
--- gnunet/src/gns/test_gns_dht_alice.conf                              (rev 0)
+++ gnunet/src/gns/test_gns_dht_alice.conf      2012-03-27 14:04:52 UTC (rev 
20786)
@@ -0,0 +1,92 @@
address@hidden@ test_gns_defaults.conf
+[PATHS]
+SERVICEHOME = /tmp/test-gnunet-gns-alice/
+DEFAULTCONFIG = test_gns_dht_alice.conf
+
+[transport-tcp]
+PORT = 32568
+
+[dht]
+UNIXPATH = /tmp/gnunet-alice-service-dht.sock
+DEBUG = NO
+AUTOSTART = YES
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+HOSTNAME = localhost
+PORT = 2101
+BINARY = gnunet-service-dht
+
+[block]
+plugins = dht test gns
+
+[dhtcache]
+QUOTA = 1 MB
+DATABASE = sqlite
+
+[arm]
+PORT = 12566
+DEFAULTSERVICES = core namstore gns
+UNIXPATH = /tmp/gnunet-alice-service-arm.sock
+
+[statistics]
+PORT = 12567
+UNIXPATH = /tmp/gnunet-alice-service-statistics.sock
+
+[resolver]
+PORT = 12564
+UNIXPATH = /tmp/gnunet-alice-service-resolver.sock
+
+[peerinfo]
+PORT = 12569
+UNIXPATH = /tmp/gnunet-alice-service-peerinfo.sock
+
+[transport]
+PORT = 12565
+UNIXPATH = /tmp/gnunet-alice-service-transport.sock
+
+[core]
+PORT = 12570
+UNIXPATH = /tmp/gnunet-alice-service-core.sock
+
+[ats]
+PORT = 12571
+UNIXPATH = /tmp/gnunet-alice-service-ats.sock
+
+[dns]
+UNIXPATH = /tmp/gnunet-alice-service-dns.sock
+PORT = 12369
+AUTOSTART = YES
+DNS_EXIT = 8.8.8.8
+
+[gns]
+PORT = 12370
+#PREFIX = valgrind -v --leak-check=full --track-origins=yes.
+AUTOSTART = YES
+BINARY = gnunet-service-gns
+ZONEKEY =  testkeys/KAILNI4SSH8M6QR6S8QRSGBBLMA8377HL6F60TEMO7S7TT1OR8CG.zkey
+HIJACK_DNS = YES
+UNIXPATH = /tmp/gnunet-service-gns-alice.sock
+HOME = $SERVICEHOME
+CONFIG = $DEFAULTCONFIG
+AUTO_IMPORT_PKEY = NO
+MAX_PARALLEL_BACKGROUND_QUERIES = 10
+DEFAULT_LOOKUP_TIMEOUT = 60
+
+[namestore]
+PORT = 12371
+AUTOSTART = YES
+UNIXPATH = /tmp/gnunet-service-namestore-alice.sock
+UNIX_MATCH_UID = YES
+UNIX_MATCH_GID = YES
+HOSTNAME = localhost
+HOME = $SERVICEHOME
+CONFIG = $DEFAULTCONFIG
+BINARY = gnunet-service-namestore
+ACCEPT_FROM = 127.0.0.1;
+ACCEPT_FROM6 = ::1;
+DATABASE = sqlite
+ZONEFILE_DIRECTORY = testkeys/
+
+[namestore-sqlite]
+FILENAME = testdb/sqlite-alice.db
+

Added: gnunet/src/gns/test_gns_dht_bob.conf
===================================================================
--- gnunet/src/gns/test_gns_dht_bob.conf                                (rev 0)
+++ gnunet/src/gns/test_gns_dht_bob.conf        2012-03-27 14:04:52 UTC (rev 
20786)
@@ -0,0 +1,92 @@
address@hidden@ test_gns_defaults.conf
+[PATHS]
+SERVICEHOME = /tmp/test-gnunet-gns-bob/
+DEFAULTCONFIG = test_gns_dht_bob.conf
+
+[transport-tcp]
+PORT = 22568
+
+[dht]
+UNIXPATH = /tmp/gnunet-bob-service-dht.sock
+DEBUG = NO
+AUTOSTART = YES
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+HOSTNAME = localhost
+PORT = 2102
+BINARY = gnunet-service-dht
+
+[block]
+plugins = dht test gns
+
+[dhtcache]
+QUOTA = 1 MB
+DATABASE = sqlite
+
+[arm]
+PORT = 22566
+DEFAULTSERVICES = core namestore gns
+UNIXPATH = /tmp/gnunet-bob-service-arm.sock
+
+[statistics]
+PORT = 22567
+UNIXPATH = /tmp/gnunet-bob-service-statistics.sock
+
+[resolver]
+PORT = 22564
+UNIXPATH = /tmp/gnunet-bob-service-resolver.sock
+
+[peerinfo]
+PORT = 22569
+UNIXPATH = /tmp/gnunet-bob-service-peerinfo.sock
+
+[transport]
+PORT = 22565
+UNIXPATH = /tmp/gnunet-bob-service-transport.sock
+
+[core]
+PORT = 22570
+UNIXPATH = /tmp/gnunet-bob-service-core.sock
+
+[ats]
+PORT = 22571
+UNIXPATH = /tmp/gnunet-bob-service-ats.sock
+
+[dns]
+UNIXPATH = /tmp/gnunet-bob-service-dns.sock
+PORT = 22369
+AUTOSTART = YES
+DNS_EXIT = 8.8.8.8
+
+[gns]
+PORT = 22370
+#PREFIX = valgrind -v --leak-check=full --track-origins=yes.
+AUTOSTART = YES
+BINARY = gnunet-service-gns
+ZONEKEY =  testkeys/KRPVFMVBFKEGUS6KL8SFPEUMORFPP9ERE6AC98KO9NADBMPF7TOG.zkey
+HIJACK_DNS = NO
+UNIXPATH = /tmp/gnunet-service-gns-bob.sock
+HOME = $SERVICEHOME
+CONFIG = $DEFAULTCONFIG
+AUTO_IMPORT_PKEY = NO
+MAX_PARALLEL_BACKGROUND_QUERIES = 10
+DEFAULT_LOOKUP_TIMEOUT = 5
+
+[namestore]
+PORT = 22371
+AUTOSTART = YES
+UNIXPATH = /tmp/gnunet-service-namestore-bob.sock
+UNIX_MATCH_UID = YES
+UNIX_MATCH_GID = YES
+HOSTNAME = localhost
+HOME = $SERVICEHOME
+CONFIG = $DEFAULTCONFIG
+BINARY = gnunet-service-namestore
+ACCEPT_FROM = 127.0.0.1;
+ACCEPT_FROM6 = ::1;
+DATABASE = sqlite
+ZONEFILE_DIRECTORY = testkeys/
+
+[namestore-sqlite]
+FILENAME = testdb/sqlite-bob.db
+

Added: gnunet/src/gns/test_gns_dht_dave.conf
===================================================================
--- gnunet/src/gns/test_gns_dht_dave.conf                               (rev 0)
+++ gnunet/src/gns/test_gns_dht_dave.conf       2012-03-27 14:04:52 UTC (rev 
20786)
@@ -0,0 +1,92 @@
address@hidden@ test_gns_defaults.conf
+[PATHS]
+SERVICEHOME = /tmp/test-gnunet-gns-dave/
+DEFAULTCONFIG = test_gns_dht_dave.conf
+
+[transport-tcp]
+PORT = 32568
+
+[dht]
+UNIXPATH = /tmp/gnunet-service-dht-dave.sock
+DEBUG = NO
+AUTOSTART = YES
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+HOSTNAME = localhost
+PORT = 2103
+BINARY = gnunet-service-dht
+
+[block]
+plugins = dht test gns
+
+[dhtcache]
+QUOTA = 1 MB
+DATABASE = sqlite
+
+[arm]
+PORT = 32566
+DEFAULTSERVICES = core namestore gns
+UNIXPATH = /tmp/gnunet-dave-service-arm.sock
+
+[statistics]
+PORT = 32567
+UNIXPATH = /tmp/gnunet-dave-service-statistics.sock
+
+[resolver]
+PORT = 32564
+UNIXPATH = /tmp/gnunet-dave-service-resolver.sock
+
+[peerinfo]
+PORT = 32569
+UNIXPATH = /tmp/gnunet-dave-service-peerinfo.sock
+
+[transport]
+PORT = 32565
+UNIXPATH = /tmp/gnunet-dave-service-transport.sock
+
+[core]
+PORT = 32570
+UNIXPATH = /tmp/gnunet-dave-service-core.sock
+
+[ats]
+PORT = 32571
+UNIXPATH = /tmp/gnunet-dave-service-ats.sock
+
+[dns]
+UNIXPATH = /tmp/gnunet-service-dns-dave.sock
+PORT = 32369
+AUTOSTART = YES
+DNS_EXIT = 8.8.8.8
+
+[gns]
+PORT = 32370
+#PREFIX = valgrind -v --leak-check=full --track-origins=yes.
+AUTOSTART = YES
+BINARY = gnunet-service-gns
+ZONEKEY =  testkeys/N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey
+HIJACK_DNS = NO
+UNIXPATH = /tmp/gnunet-service-gns-dave.sock
+HOME = $SERVICEHOME
+CONFIG = $DEFAULTCONFIG
+AUTO_IMPORT_PKEY = NO
+MAX_PARALLEL_BACKGROUND_QUERIES = 10
+DEFAULT_LOOKUP_TIMEOUT = 5
+
+[namestore]
+PORT = 32371
+AUTOSTART = YES
+UNIXPATH = /tmp/gnunet-service-namestore-dave.sock
+UNIX_MATCH_UID = YES
+UNIX_MATCH_GID = YES
+HOSTNAME = localhost
+HOME = $SERVICEHOME
+CONFIG = $DEFAULTCONFIG
+BINARY = gnunet-service-namestore
+ACCEPT_FROM = 127.0.0.1;
+ACCEPT_FROM6 = ::1;
+DATABASE = sqlite
+ZONEFILE_DIRECTORY = testkeys/
+
+[namestore-sqlite]
+FILENAME = testdb/sqlite-dave.db
+

Copied: gnunet/src/gns/test_gns_dht_threepeer.c (from rev 20774, 
gnunet/src/gns/test_gns_twopeer.c)
===================================================================
--- gnunet/src/gns/test_gns_dht_threepeer.c                             (rev 0)
+++ gnunet/src/gns/test_gns_dht_threepeer.c     2012-03-27 14:04:52 UTC (rev 
20786)
@@ -0,0 +1,463 @@
+/*
+     This file is part of GNUnet.
+     (C) 2009 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file gns/test_gns_dht_threepeer.c
+ * @brief tests dht lookup over 3 peers
+ *
+ * topology:
+ * alice <----> bob <-----> dave
+ *
+ * alice queries for www.buddy.bob.gnunet
+ *
+ */
+#include "platform.h"
+#include "gnunet_disk_lib.h"
+#include "gnunet_testing_lib.h"
+#include "gnunet_core_service.h"
+#include "gnunet_dht_service.h"
+#include "block_dns.h"
+#include "gnunet_signatures.h"
+#include "gnunet_namestore_service.h"
+#include "gnunet_dnsparser_lib.h"
+#include "gnunet_gns_service.h"
+
+/* DEFINES */
+#define VERBOSE GNUNET_YES
+
+/* Timeout for entire testcase */
+#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 80)
+
+/* If number of peers not in config file, use this number */
+#define DEFAULT_NUM_PEERS 2
+
+#define TEST_DOMAIN "www.buddy.bob.gnunet"
+#define TEST_IP "1.1.1.1"
+
+/* Globals */
+
+/**
+ * Directory to store temp data in, defined in config file
+ */
+static char *test_directory;
+
+/**
+ * Variable used to store the number of connections we should wait for.
+ */
+static unsigned int expected_connections;
+
+/**
+ * Variable used to keep track of how many peers aren't yet started.
+ */
+static unsigned long long peers_left;
+
+struct GNUNET_TESTING_Daemon *d1;
+struct GNUNET_TESTING_Daemon *d2;
+struct GNUNET_TESTING_Daemon *d3;
+
+
+/**
+ * Total number of peers to run, set based on config file.
+ */
+static unsigned long long num_peers;
+
+/**
+ * Global used to count how many connections we have currently
+ * been notified about (how many times has topology_callback been called
+ * with success?)
+ */
+static unsigned int total_connections;
+
+/**
+ * Global used to count how many failed connections we have
+ * been notified about (how many times has topology_callback
+ * been called with failure?)
+ */
+static unsigned int failed_connections;
+
+/* Task handle to use to schedule test failure */
+GNUNET_SCHEDULER_TaskIdentifier die_task;
+
+GNUNET_SCHEDULER_TaskIdentifier bob_task;
+
+/* Global return value (0 for success, anything else for failure) */
+static int ok;
+
+int bob_online, alice_online, dave_online;
+
+struct GNUNET_CONFIGURATION_Handle *cfg_alice;
+struct GNUNET_CONFIGURATION_Handle *cfg_bob;
+struct GNUNET_CONFIGURATION_Handle *cfg_dave;
+
+/**
+ * Check whether peers successfully shut down.
+ */
+void
+shutdown_callback (void *cls, const char *emsg)
+{
+  if (emsg != NULL)
+  {
+    if (ok == 0)
+      ok = 2;
+  }
+}
+
+/**
+ * Function scheduled to be run on the successful completion of this
+ * testcase.  Specifically, called when our get request completes.
+ */
+static void
+finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  ok = 0;
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down alice!\n");
+  GNUNET_TESTING_daemon_stop (d1, TIMEOUT, &shutdown_callback, NULL,
+                              GNUNET_YES, GNUNET_NO);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down bob!\n");
+  GNUNET_TESTING_daemon_stop (d2, TIMEOUT, &shutdown_callback, NULL,
+                              GNUNET_YES, GNUNET_NO);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down dave\n");
+  GNUNET_TESTING_daemon_stop (d3, TIMEOUT, &shutdown_callback, NULL,
+                              GNUNET_YES, GNUNET_NO);
+  GNUNET_DISK_file_copy ("testdb/sqlite-alice.db.bak",
+                         "testdb/sqlite-alice.db.bak");
+  GNUNET_SCHEDULER_cancel(die_task);
+}
+
+/**
+ * Continuation for the GNUNET_DHT_get_stop call, so that we don't shut
+ * down the peers without freeing memory associated with GET request.
+ */
+static void
+end_badly_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  if (d1 != NULL)
+    GNUNET_TESTING_daemon_stop (d1, TIMEOUT, &shutdown_callback, NULL,
+                                GNUNET_YES, GNUNET_NO);
+  if (d2 != NULL)
+    GNUNET_TESTING_daemon_stop (d2, TIMEOUT, &shutdown_callback, NULL,
+                                GNUNET_YES, GNUNET_NO);
+;
+  if (d3 != NULL)
+    GNUNET_TESTING_daemon_stop (d3, TIMEOUT, &shutdown_callback, NULL,
+                                GNUNET_YES, GNUNET_NO);
+}
+
+/**
+ * Check if the get_handle is being used, if so stop the request.  Either
+ * way, schedule the end_badly_cont function which actually shuts down the
+ * test.
+ */
+static void
+end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Failing test with error: `%s'!\n",
+              (char *) cls);
+  GNUNET_SCHEDULER_add_now (&end_badly_cont, NULL);
+  ok = 1;
+}
+
+static void
+commence_testing(void)
+{
+  struct hostent *he;
+  struct in_addr a;
+  char* addr;
+
+  he = gethostbyname (TEST_DOMAIN);
+
+  if (he)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_INFO, "name: %s\n", he->h_name);
+    while (*he->h_addr_list)
+    {
+      bcopy(*he->h_addr_list++, (char *) &a, sizeof(a));
+      addr = inet_ntoa(a);
+      GNUNET_log(GNUNET_ERROR_TYPE_INFO, "address: %s\n", addr);
+      if (strcmp(addr, TEST_IP) == 0)
+        ok = 0;
+    }
+  }
+  else
+    ok = 1;
+  //do lookup here
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+                                (GNUNET_TIME_UNIT_SECONDS, 30),
+                                 &finish_testing, NULL);
+}
+
+
+/**
+ * This function is called whenever a connection attempt is finished between 
two of
+ * the started peers (started with GNUNET_TESTING_daemons_start).  The total
+ * number of times this function is called should equal the number returned
+ * from the GNUNET_TESTING_connect_topology call.
+ *
+ * The emsg variable is NULL on success (peers connected), and non-NULL on
+ * failure (peers failed to connect).
+ */
+void
+notify_connect (void *cls, const struct GNUNET_PeerIdentity *first,
+                   const struct GNUNET_PeerIdentity *second, uint32_t distance,
+                   const struct GNUNET_CONFIGURATION_Handle *first_cfg,
+                   const struct GNUNET_CONFIGURATION_Handle *second_cfg,
+                   struct GNUNET_TESTING_Daemon *first_daemon,
+                   struct GNUNET_TESTING_Daemon *second_daemon,
+                   const char *emsg)
+{
+  if (emsg == NULL)
+  {
+    total_connections++;
+#if VERBOSE
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "connected peer %s to peer %s, distance %u\n",
+                first_daemon->shortname, second_daemon->shortname, distance);
+#endif
+  }
+#if VERBOSE
+  else
+  {
+    failed_connections++;
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Failed to connect peer %s to peer %s with error :\n%s\n",
+                first_daemon->shortname, second_daemon->shortname, emsg);
+  }
+#endif
+
+  if (total_connections == expected_connections)
+  {
+#if VERBOSE
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Created %d total connections, which is our target number!  
Starting next phase of testing.\n",
+                total_connections);
+#endif
+    GNUNET_SCHEDULER_cancel (die_task);
+    die_task =
+        GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from connect");
+    commence_testing();
+    
+  }
+  else if (total_connections + failed_connections == expected_connections)
+  {
+    GNUNET_SCHEDULER_cancel (die_task);
+    die_task =
+        GNUNET_SCHEDULER_add_now (&end_badly,
+                                  "from topology_callback (too many failed 
connections)");
+  }
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connecting peers dave, bob\n");
+    GNUNET_TESTING_daemons_connect (d3, d2, TIMEOUT, 5, 1,
+                                         &notify_connect, NULL);
+  }
+}
+
+/**
+ * Set up some data, and call API PUT function
+ */
+static void
+connect_ab (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connecting peers alice, bob\n");
+  GNUNET_TESTING_daemons_connect (d1, d2, TIMEOUT, 5, 1,
+                                         &notify_connect, NULL);
+}
+
+
+static void
+dave_started (void *cls, const struct GNUNET_PeerIdentity *id,
+                        const struct GNUNET_CONFIGURATION_Handle *cfg,
+                        struct GNUNET_TESTING_Daemon *d, const char *emsg)
+{
+  if (emsg != NULL)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Failed to start daemon with error: `%s'\n", emsg);
+    return;
+  }
+  GNUNET_assert (id != NULL);
+  
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+                                (GNUNET_TIME_UNIT_SECONDS, 2),
+                                &connect_ab, NULL);
+}
+
+
+
+static void
+bob_started (void *cls, const struct GNUNET_PeerIdentity *id,
+                        const struct GNUNET_CONFIGURATION_Handle *cfg,
+                        struct GNUNET_TESTING_Daemon *d, const char *emsg)
+{
+  if (emsg != NULL)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Failed to start daemon with error: `%s'\n", emsg);
+    return;
+  }
+  GNUNET_assert (id != NULL);
+  
+  //Start bob
+  d3 = GNUNET_TESTING_daemon_start(cfg_dave, TIMEOUT, GNUNET_NO, NULL, NULL, 0,
+                                   NULL, NULL, NULL, &dave_started, NULL);
+
+}
+
+
+
+/**
+ * Callback which is called whenever a peer is started (as a result of the
+ * GNUNET_TESTING_daemons_start call.
+ *
+ * @param cls closure argument given to GNUNET_TESTING_daemons_start
+ * @param id the GNUNET_PeerIdentity of the started peer
+ * @param cfg the configuration for this specific peer (needed to connect
+ *            to the DHT)
+ * @param d the handle to the daemon started
+ * @param emsg NULL if peer started, non-NULL on error
+ */
+static void
+alice_started (void *cls, const struct GNUNET_PeerIdentity *id,
+                        const struct GNUNET_CONFIGURATION_Handle *cfg,
+                        struct GNUNET_TESTING_Daemon *d, const char *emsg)
+{
+  if (emsg != NULL)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Failed to start daemon with error: `%s'\n", emsg);
+    return;
+  }
+  GNUNET_assert (id != NULL);
+  
+  //Start bob
+  d2 = GNUNET_TESTING_daemon_start(cfg_bob, TIMEOUT, GNUNET_NO, NULL, NULL, 0,
+                                   NULL, NULL, NULL, &bob_started, NULL);
+  
+}
+
+static void
+run (void *cls, char *const *args, const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+
+  /* Get path from configuration file */
+  if (GNUNET_YES !=
+      GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome",
+                                             &test_directory))
+  {
+    ok = 404;
+    return;
+  }
+
+  /* Get number of peers to start from configuration (should be two) */
+  if (GNUNET_SYSERR ==
+      GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
+                                             &num_peers))
+    num_peers = DEFAULT_NUM_PEERS;
+
+  /* Set peers_left so we know when all peers started */
+  peers_left = num_peers;
+  
+  /**
+   * Modify some config options for peers
+   */
+  cfg_alice = GNUNET_CONFIGURATION_create();
+  GNUNET_CONFIGURATION_load (cfg_alice, "test_gns_dht_alice.conf");
+
+  cfg_bob = GNUNET_CONFIGURATION_create();
+  GNUNET_CONFIGURATION_load (cfg_bob, "test_gns_dht_bob.conf");
+  
+  cfg_dave = GNUNET_CONFIGURATION_create();
+  GNUNET_CONFIGURATION_load (cfg_dave, "test_gns_dht_dave.conf");
+
+  GNUNET_CONFIGURATION_load (cfg_alice, "test_gns_dht_alice.conf");
+  GNUNET_CONFIGURATION_load (cfg_bob, "test_gns_dht_bob.conf");
+  GNUNET_CONFIGURATION_load (cfg_dave, "test_gns_dht_dave.conf");
+
+  /* Set up a task to end testing if peer start fails */
+  die_task =
+      GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
+                                    "didn't start all daemons in reasonable 
amount of time!!!");
+  
+  alice_online = 0;
+  bob_online = 0;
+  dave_online = 0;
+  expected_connections = 2;
+  
+  /* Start alice */
+  d1 = GNUNET_TESTING_daemon_start(cfg_alice, TIMEOUT, GNUNET_NO, NULL, NULL, 
0,
+                                   NULL, NULL, NULL, &alice_started, NULL);
+  
+  
+
+
+}
+
+static int
+check ()
+{
+  int ret;
+
+  /* Arguments for GNUNET_PROGRAM_run */
+  char *const argv[] = { "test-gns-twopeer",    /* Name to give running binary 
*/
+    "-c",
+    "test_gns_twopeer.conf",       /* Config file to use */
+#if VERBOSE
+    "-L", "DEBUG",
+#endif
+    NULL
+  };
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_OPTION_END
+  };
+  /* Run the run function as a new program */
+  ret =
+      GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
+                          "test-gns-twopeer", "nohelp", options, &run,
+                          &ok);
+  if (ret != GNUNET_OK)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "`test-gns-twopeer': Failed with error code %d\n", ret);
+  }
+  return ok;
+}
+
+int
+main (int argc, char *argv[])
+{
+  int ret;
+
+  GNUNET_log_setup ("test-gns-twopeer",
+#if VERBOSE
+                    "DEBUG",
+#else
+                    "WARNING",
+#endif
+                    NULL);
+  ret = check ();
+  /**
+   * Need to remove base directory, subdirectories taken care
+   * of by the testing framework.
+   */
+  return ret;
+}
+
+/* end of test_gns_twopeer.c */

Deleted: gnunet/src/gns/test_gns_twopeer.c
===================================================================
--- gnunet/src/gns/test_gns_twopeer.c   2012-03-27 14:00:09 UTC (rev 20785)
+++ gnunet/src/gns/test_gns_twopeer.c   2012-03-27 14:04:52 UTC (rev 20786)
@@ -1,539 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2009 Christian Grothoff (and other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
-/**
- * @file gns/test_gns_twopeer.c
- * @brief base testcase for testing DHT service with
- *        two running peers.
- *
- * This testcase starts peers using the GNUNET_TESTING_daemons_start
- * function call.  On peer start, connects to the peers DHT service
- * by calling GNUNET_DHT_connected.  Once notified about all peers
- * being started (by the peers_started_callback function), calls
- * GNUNET_TESTING_connect_topology, which connects the peers in a
- * "straight line" topology.  On notification that all peers have
- * been properly connected, calls the do_get function which initiates
- * a GNUNET_DHT_get from the *second* peer. Once the GNUNET_DHT_get
- * function starts, runs the do_put function to insert data at the first peer.
- *   If the GET is successful, schedules finish_testing
- * to stop the test and shut down peers.  If GET is unsuccessful
- * after GET_TIMEOUT seconds, prints an error message and shuts down
- * the peers.
- */
-#include "platform.h"
-#include "gnunet_testing_lib.h"
-#include "gnunet_core_service.h"
-#include "gnunet_dht_service.h"
-#include "block_dns.h"
-#include "gnunet_signatures.h"
-#include "gnunet_namestore_service.h"
-#include "gnunet_dnsparser_lib.h"
-#include "gnunet_gns_service.h"
-
-/* DEFINES */
-#define VERBOSE GNUNET_YES
-
-/* Timeout for entire testcase */
-#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 80)
-
-/* If number of peers not in config file, use this number */
-#define DEFAULT_NUM_PEERS 2
-
-/* Globals */
-
-/**
- * Directory to store temp data in, defined in config file
- */
-static char *test_directory;
-
-/**
- * Variable used to store the number of connections we should wait for.
- */
-static unsigned int expected_connections;
-
-/**
- * Variable used to keep track of how many peers aren't yet started.
- */
-static unsigned long long peers_left;
-
-struct GNUNET_TESTING_Daemon *d1;
-struct GNUNET_TESTING_Daemon *d2;
-
-
-/**
- * Total number of peers to run, set based on config file.
- */
-static unsigned long long num_peers;
-
-/**
- * Global used to count how many connections we have currently
- * been notified about (how many times has topology_callback been called
- * with success?)
- */
-static unsigned int total_connections;
-
-/**
- * Global used to count how many failed connections we have
- * been notified about (how many times has topology_callback
- * been called with failure?)
- */
-static unsigned int failed_connections;
-
-/* Task handle to use to schedule test failure */
-GNUNET_SCHEDULER_TaskIdentifier die_task;
-
-GNUNET_SCHEDULER_TaskIdentifier bob_task;
-
-/* Global return value (0 for success, anything else for failure) */
-static int ok;
-
-int bob_online, alice_online;
-
-/**
- * Check whether peers successfully shut down.
- */
-void
-shutdown_callback (void *cls, const char *emsg)
-{
-  if (emsg != NULL)
-  {
-    if (ok == 0)
-      ok = 2;
-  }
-}
-
-/**
- * Function scheduled to be run on the successful completion of this
- * testcase.  Specifically, called when our get request completes.
- */
-static void
-finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  ok = 0;
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer1!\n");
-  GNUNET_TESTING_daemon_stop (d1, TIMEOUT, &shutdown_callback, NULL,
-                              GNUNET_YES, GNUNET_NO);
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer2!\n");
-  GNUNET_TESTING_daemon_stop (d2, TIMEOUT, &shutdown_callback, NULL,
-                              GNUNET_YES, GNUNET_NO);
-  GNUNET_SCHEDULER_cancel(bob_task);
-  GNUNET_SCHEDULER_cancel(die_task);
-}
-
-/**
- * Continuation for the GNUNET_DHT_get_stop call, so that we don't shut
- * down the peers without freeing memory associated with GET request.
- */
-static void
-end_badly_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  if (d1 != NULL)
-    GNUNET_TESTING_daemon_stop (d1, TIMEOUT, &shutdown_callback, NULL,
-                                GNUNET_YES, GNUNET_NO);
-  if (d2 != NULL)
-    GNUNET_TESTING_daemon_stop (d2, TIMEOUT, &shutdown_callback, NULL,
-                                GNUNET_YES, GNUNET_NO);
-}
-
-/**
- * Check if the get_handle is being used, if so stop the request.  Either
- * way, schedule the end_badly_cont function which actually shuts down the
- * test.
- */
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Failing test with error: `%s'!\n",
-              (char *) cls);
-  GNUNET_SCHEDULER_cancel(bob_task);
-  GNUNET_SCHEDULER_add_now (&end_badly_cont, NULL);
-  ok = 1;
-}
-
-static void
-do_lookup(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  //do lookup here
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                (GNUNET_TIME_UNIT_SECONDS, 30),
-                                 &finish_testing, NULL);
-}
-
-static void
-gns_started(void *cls, const struct GNUNET_PeerIdentity *id,
-            const struct GNUNET_CONFIGURATION_Handle *cfg,
-            struct GNUNET_TESTING_Daemon *d, const char *emsg)
-{
-  if (NULL != emsg)
-  {
-    if (d == d1)
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO, "GNS failed to start alice\n");
-    else
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO, "GNS failed to start bob\n");
-    return;
-  }
-  if (d == d1)
-  {
-    /* start gns for bob */
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "GNS started on alice\n");
-    GNUNET_TESTING_daemon_start_service (d2, "gns", TIMEOUT, &gns_started,
-                                        NULL);
-    return;
-  }
-
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "GNS started on bob\n");
-
-  /* start the lookup tests */
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                  (GNUNET_TIME_UNIT_SECONDS, 1),
-                                  &do_lookup, NULL);
-}
-
-/**
- * This function is called whenever a connection attempt is finished between 
two of
- * the started peers (started with GNUNET_TESTING_daemons_start).  The total
- * number of times this function is called should equal the number returned
- * from the GNUNET_TESTING_connect_topology call.
- *
- * The emsg variable is NULL on success (peers connected), and non-NULL on
- * failure (peers failed to connect).
- */
-void
-notify_connect (void *cls, const struct GNUNET_PeerIdentity *first,
-                   const struct GNUNET_PeerIdentity *second, uint32_t distance,
-                   const struct GNUNET_CONFIGURATION_Handle *first_cfg,
-                   const struct GNUNET_CONFIGURATION_Handle *second_cfg,
-                   struct GNUNET_TESTING_Daemon *first_daemon,
-                   struct GNUNET_TESTING_Daemon *second_daemon,
-                   const char *emsg)
-{
-  if (emsg == NULL)
-  {
-    total_connections++;
-#if VERBOSE
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                "connected peer %s to peer %s, distance %u\n",
-                first_daemon->shortname, second_daemon->shortname, distance);
-#endif
-  }
-#if VERBOSE
-  else
-  {
-    failed_connections++;
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                "Failed to connect peer %s to peer %s with error :\n%s\n",
-                first_daemon->shortname, second_daemon->shortname, emsg);
-  }
-#endif
-
-  if (total_connections == expected_connections)
-  {
-#if VERBOSE
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                "Created %d total connections, which is our target number!  
Starting next phase of testing.\n",
-                total_connections);
-#endif
-    GNUNET_SCHEDULER_cancel (die_task);
-    die_task =
-        GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test lookup");
-    
-    /* start gns for alice */
-    GNUNET_TESTING_daemon_start_service (d1, "gns", TIMEOUT, &gns_started, 
NULL);
-    
-  }
-  else if (total_connections + failed_connections == expected_connections)
-  {
-    GNUNET_SCHEDULER_cancel (die_task);
-    die_task =
-        GNUNET_SCHEDULER_add_now (&end_badly,
-                                  "from topology_callback (too many failed 
connections)");
-  }
-}
-
-/**
- * Set up some data, and call API PUT function
- */
-static void
-alice_idle (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  
-  alice_online = 1;
-  if (!bob_online)
-  {
-    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                  (GNUNET_TIME_UNIT_SECONDS, 2),
-                                   &alice_idle, NULL);
-    return;
-  }
-
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connecting peers\n");
-  GNUNET_TESTING_daemons_connect (d1, d2, TIMEOUT, 5, 1,
-                                         &notify_connect, NULL);
-}
-
-static void
-bob_idle (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  /* he's lazy FIXME forever */
-  bob_online = 1;
-  bob_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                  (GNUNET_TIME_UNIT_SECONDS, 20),
-                                   &bob_idle, NULL);
-}
-
-
-
-
-/**
- * Callback which is called whenever a peer is started (as a result of the
- * GNUNET_TESTING_daemons_start call.
- *
- * @param cls closure argument given to GNUNET_TESTING_daemons_start
- * @param id the GNUNET_PeerIdentity of the started peer
- * @param cfg the configuration for this specific peer (needed to connect
- *            to the DHT)
- * @param d the handle to the daemon started
- * @param emsg NULL if peer started, non-NULL on error
- */
-static void
-alice_started (void *cls, const struct GNUNET_PeerIdentity *id,
-                        const struct GNUNET_CONFIGURATION_Handle *cfg,
-                        struct GNUNET_TESTING_Daemon *d, const char *emsg)
-{
-  if (emsg != NULL)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Failed to start daemon with error: `%s'\n", emsg);
-    return;
-  }
-  GNUNET_assert (id != NULL);
-  
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                (GNUNET_TIME_UNIT_SECONDS, 2),
-                                &alice_idle, NULL);
-}
-
-static void
-bob_started (void *cls, const struct GNUNET_PeerIdentity *id,
-                        const struct GNUNET_CONFIGURATION_Handle *cfg,
-                        struct GNUNET_TESTING_Daemon *d, const char *emsg)
-{
-  if (emsg != NULL)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Failed to start daemon with error: `%s'\n", emsg);
-    return;
-  }
-  GNUNET_assert (id != NULL);
-  
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                (GNUNET_TIME_UNIT_SECONDS, 2),
-                                &bob_idle, NULL);
-}
-
-static void
-run (void *cls, char *const *args, const char *cfgfile,
-     const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
-
-  struct GNUNET_NAMESTORE_Handle* namestore_handle;
-  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey, bob_pkey;
-  struct GNUNET_CRYPTO_RsaPrivateKey *alice_key, *bob_key;
-  char* bob_keyfile;
-  char* alice_keyfile;
-
-  /* Get path from configuration file */
-  if (GNUNET_YES !=
-      GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome",
-                                             &test_directory))
-  {
-    ok = 404;
-    return;
-  }
-
-  /* Get number of peers to start from configuration (should be two) */
-  if (GNUNET_SYSERR ==
-      GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
-                                             &num_peers))
-    num_peers = DEFAULT_NUM_PEERS;
-
-  /* Set peers_left so we know when all peers started */
-  peers_left = num_peers;
-  
-  /* Somebody care to explain? */
-  uint16_t port = 6000;
-  uint32_t upnum = 23;
-  uint32_t fdnum = 42;
-  
-  /**
-   * Modify some config options for bob
-   * namely swap keys and disable dns hijacking
-   */
-  struct GNUNET_CONFIGURATION_Handle *cfg2 = GNUNET_TESTING_create_cfg(cfg,
-                                              23, &port, &upnum,
-                                              NULL, &fdnum);
-  
-  GNUNET_CONFIGURATION_set_value_string (cfg2, "paths", "servicehome",
-                                         "/tmp/test-gnunetd-gns-peer-2/");
-  GNUNET_CONFIGURATION_set_value_string (cfg2, "gns", "HIJACK_DNS",
-                                        "NO");
-  GNUNET_CONFIGURATION_set_value_string (cfg2, "gns", "ZONEKEY",
-                                         "/tmp/bobkey");
-  
-  /* put records into namestore */
-  namestore_handle = GNUNET_NAMESTORE_connect(cfg);
-  if (NULL == namestore_handle)
-  {
-    GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n");
-    ok = -1;
-    return;
-  }
-
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "gns",
-                                                          "ZONEKEY",
-                                                          &alice_keyfile))
-  {
-    GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get alice's key from 
cfg\n");
-    ok = -1;
-    return;
-  }
-
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg2, "gns",
-                                                          "ZONEKEY",
-                                                          &bob_keyfile))
-  {
-    GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get bob's key from cfg\n");
-    ok = -1;
-    return;
-  }
-  
-  alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile);
-  bob_key = GNUNET_CRYPTO_rsa_key_create_from_file (bob_keyfile);
-
-  GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey);
-  GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey);
-
-  struct GNUNET_NAMESTORE_RecordData rd;
-  rd.data = &bob_pkey;
-  rd.expiration = GNUNET_TIME_absolute_get_forever ();
-  rd.data_size = sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded);
-  rd.record_type = GNUNET_GNS_RECORD_PKEY;
-
-  GNUNET_NAMESTORE_record_create (namestore_handle,
-                                  alice_key,
-                                  "bob",
-                                  &rd,
-                                  NULL,
-                                  NULL);
-  
-  rd.data = &alice_pkey;
-  GNUNET_NAMESTORE_record_create (namestore_handle,
-                                  bob_key,
-                                  "alice",
-                                  &rd,
-                                  NULL,
-                                  NULL);
-
-  char* ip = "127.0.0.1";
-  struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr));
-  GNUNET_assert(1 == inet_pton (AF_INET, ip, web));
-
-  rd.data_size = sizeof(struct in_addr);
-  rd.data = web;
-  rd.record_type = GNUNET_DNSPARSER_TYPE_A;
-
-  GNUNET_NAMESTORE_record_create (namestore_handle,
-                                  bob_key,
-                                  "www",
-                                  &rd,
-                                  NULL,
-                                  NULL);
-  
-  /* Set up a task to end testing if peer start fails */
-  die_task =
-      GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
-                                    "didn't start all daemons in reasonable 
amount of time!!!");
-  
-  alice_online = 0;
-  bob_online = 0;
-  expected_connections = 1;
-  
-  /* Start alice */
-  d1 = GNUNET_TESTING_daemon_start(cfg, TIMEOUT, GNUNET_NO, NULL, NULL, 0,
-                                   NULL, NULL, NULL, &alice_started, NULL);
-  
-  
-  //Start bob
-  d2 = GNUNET_TESTING_daemon_start(cfg2, TIMEOUT, GNUNET_NO, NULL, NULL, 0,
-                                   NULL, NULL, NULL, &bob_started, NULL);
-
-
-}
-
-static int
-check ()
-{
-  int ret;
-
-  /* Arguments for GNUNET_PROGRAM_run */
-  char *const argv[] = { "test-gns-twopeer",    /* Name to give running binary 
*/
-    "-c",
-    "test_gns_twopeer.conf",       /* Config file to use */
-#if VERBOSE
-    "-L", "DEBUG",
-#endif
-    NULL
-  };
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_OPTION_END
-  };
-  /* Run the run function as a new program */
-  ret =
-      GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
-                          "test-gns-twopeer", "nohelp", options, &run,
-                          &ok);
-  if (ret != GNUNET_OK)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "`test-gns-twopeer': Failed with error code %d\n", ret);
-  }
-  return ok;
-}
-
-int
-main (int argc, char *argv[])
-{
-  int ret;
-
-  GNUNET_log_setup ("test-gns-twopeer",
-#if VERBOSE
-                    "DEBUG",
-#else
-                    "WARNING",
-#endif
-                    NULL);
-  ret = check ();
-  /**
-   * Need to remove base directory, subdirectories taken care
-   * of by the testing framework.
-   */
-  return ret;
-}
-
-/* end of test_gns_twopeer.c */

Added: gnunet/src/gns/testdb/sqlite-alice.db
===================================================================
(Binary files differ)


Property changes on: gnunet/src/gns/testdb/sqlite-alice.db
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: gnunet/src/gns/testdb/sqlite-alice.db.bak
===================================================================
(Binary files differ)


Property changes on: gnunet/src/gns/testdb/sqlite-alice.db.bak
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: gnunet/src/gns/testdb/sqlite-bob.db
===================================================================
(Binary files differ)


Property changes on: gnunet/src/gns/testdb/sqlite-bob.db
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: gnunet/src/gns/testdb/sqlite-dave.db
===================================================================
(Binary files differ)


Property changes on: gnunet/src/gns/testdb/sqlite-dave.db
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: 
gnunet/src/gns/testkeys/KAILNI4SSH8M6QR6S8QRSGBBLMA8377HL6F60TEMO7S7TT1OR8CG.zkey
===================================================================
(Binary files differ)


Property changes on: 
gnunet/src/gns/testkeys/KAILNI4SSH8M6QR6S8QRSGBBLMA8377HL6F60TEMO7S7TT1OR8CG.zkey
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: 
gnunet/src/gns/testkeys/KRPVFMVBFKEGUS6KL8SFPEUMORFPP9ERE6AC98KO9NADBMPF7TOG.zkey
===================================================================
(Binary files differ)


Property changes on: 
gnunet/src/gns/testkeys/KRPVFMVBFKEGUS6KL8SFPEUMORFPP9ERE6AC98KO9NADBMPF7TOG.zkey
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: 
gnunet/src/gns/testkeys/N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey
===================================================================
(Binary files differ)


Property changes on: 
gnunet/src/gns/testkeys/N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream




reply via email to

[Prev in Thread] Current Thread [Next in Thread]